Skip to content

Commit 9124783

Browse files
authored
Merge pull request #1116 from felixfontein/update-keys-input-type
Support --input-type for updatekeys
2 parents f35e983 + 566d51a commit 9124783

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

cmd/sops/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ func main() {
189189
},
190190
cli.StringFlag{
191191
Name: "input-type",
192-
Usage: "currently json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
192+
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
193193
},
194194
cli.StringFlag{
195195
Name: "output-type",
196-
Usage: "currently json, yaml, dotenv and binary are supported. If not set, sops will use the input file's extension to determine the output format",
196+
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the input file's extension to determine the output format",
197197
},
198198
cli.StringFlag{
199199
Name: "filename",
@@ -508,6 +508,10 @@ func main() {
508508
Name: "yes, y",
509509
Usage: `pre-approve all changes and run non-interactively`,
510510
},
511+
cli.StringFlag{
512+
Name: "input-type",
513+
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
514+
},
511515
}, keyserviceFlags...),
512516
Action: func(c *cli.Context) error {
513517
var err error
@@ -529,6 +533,7 @@ func main() {
529533
KeyServices: keyservices(c),
530534
Interactive: !c.Bool("yes"),
531535
ConfigPath: configPath,
536+
InputType: c.String("input-type"),
532537
})
533538
if cliErr, ok := err.(*cli.ExitError); ok && cliErr != nil {
534539
return cliErr

cmd/sops/subcommand/updatekeys/updatekeys.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Opts struct {
1919
KeyServices []keyservice.KeyServiceClient
2020
Interactive bool
2121
ConfigPath string
22+
InputType string
2223
}
2324

2425
// UpdateKeys update the keys for a given file
@@ -39,7 +40,7 @@ func UpdateKeys(opts Opts) error {
3940
}
4041

4142
func updateFile(opts Opts) error {
42-
store := common.DefaultStoreForPath(opts.InputPath)
43+
store := common.DefaultStoreForPathOrFormat(opts.InputPath, opts.InputType)
4344
log.Printf("Syncing keys for file %s", opts.InputPath)
4445
tree, err := common.LoadEncryptedFile(store, opts.InputPath)
4546
if err != nil {

0 commit comments

Comments
 (0)