Skip to content

Commit 6e0981c

Browse files
authored
PBM-1387: return empty if not path is set (#1018)
1 parent 36e98ff commit 6e0981c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cmd/pbm/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func runConfig(
8484
case len(c.key) > 0:
8585
k, err := config.GetConfigVar(ctx, conn, c.key)
8686
if err != nil {
87+
if errors.Is(err, config.ErrUnsetConfigPath) {
88+
return confKV{c.key, ""}, nil // unset config path
89+
}
8790
return nil, errors.Wrap(err, "unable to get config key")
8891
}
8992
return confKV{c.key, fmt.Sprint(k)}, nil

pbm/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"go.mongodb.org/mongo-driver/bson/primitive"
1616
"go.mongodb.org/mongo-driver/mongo"
1717
"go.mongodb.org/mongo-driver/mongo/options"
18+
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
1819
"gopkg.in/yaml.v2"
1920

2021
"github.com/percona/percona-backup-mongodb/pbm/compress"
@@ -32,6 +33,7 @@ var (
3233
ErrUnkownStorageType = errors.New("unknown storage type")
3334
ErrMissedConfig = errors.New("missed config")
3435
ErrMissedConfigProfile = errors.New("missed config profile")
36+
ErrUnsetConfigPath = bsoncore.ErrElementNotFound
3537
)
3638

3739
type confMap map[string]reflect.Kind

0 commit comments

Comments
 (0)