Skip to content

Commit 4a95c6b

Browse files
committed
[updatekeys] Fix input-type cli flag being ignored
1 parent bb710f3 commit 4a95c6b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/sops/subcommand/updatekeys/updatekeys.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/getsops/sops/v3/cmd/sops/codes"
1010
"github.com/getsops/sops/v3/cmd/sops/common"
11+
"github.com/getsops/sops/v3/cmd/sops/formats"
1112
"github.com/getsops/sops/v3/config"
1213
"github.com/getsops/sops/v3/keyservice"
1314
)
@@ -45,12 +46,23 @@ func updateFile(opts Opts) error {
4546
if err != nil {
4647
return err
4748
}
48-
store := common.DefaultStoreForPath(sc, opts.InputPath)
49+
50+
var store common.Store
51+
52+
if opts.InputType == "" {
53+
store = common.DefaultStoreForPath(sc, opts.InputPath)
54+
} else {
55+
format := formats.FormatFromString(opts.InputType)
56+
store = common.StoreForFormat(format, sc)
57+
}
58+
4959
log.Printf("Syncing keys for file %s", opts.InputPath)
60+
5061
tree, err := common.LoadEncryptedFile(store, opts.InputPath)
5162
if err != nil {
5263
return err
5364
}
65+
5466
conf, err := config.LoadCreationRuleForFile(opts.ConfigPath, opts.InputPath, make(map[string]*string))
5567
if err != nil {
5668
return err

0 commit comments

Comments
 (0)