Skip to content

Commit

Permalink
Merge pull request #1116 from felixfontein/update-keys-input-type
Browse files Browse the repository at this point in the history
Support --input-type for updatekeys
  • Loading branch information
ajvb authored Sep 1, 2022
2 parents f35e983 + 566d51a commit 9124783
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cmd/sops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ func main() {
},
cli.StringFlag{
Name: "input-type",
Usage: "currently json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
},
cli.StringFlag{
Name: "output-type",
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",
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",
},
cli.StringFlag{
Name: "filename",
Expand Down Expand Up @@ -508,6 +508,10 @@ func main() {
Name: "yes, y",
Usage: `pre-approve all changes and run non-interactively`,
},
cli.StringFlag{
Name: "input-type",
Usage: "currently ini, json, yaml, dotenv and binary are supported. If not set, sops will use the file's extension to determine the type",
},
}, keyserviceFlags...),
Action: func(c *cli.Context) error {
var err error
Expand All @@ -529,6 +533,7 @@ func main() {
KeyServices: keyservices(c),
Interactive: !c.Bool("yes"),
ConfigPath: configPath,
InputType: c.String("input-type"),
})
if cliErr, ok := err.(*cli.ExitError); ok && cliErr != nil {
return cliErr
Expand Down
3 changes: 2 additions & 1 deletion cmd/sops/subcommand/updatekeys/updatekeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Opts struct {
KeyServices []keyservice.KeyServiceClient
Interactive bool
ConfigPath string
InputType string
}

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

func updateFile(opts Opts) error {
store := common.DefaultStoreForPath(opts.InputPath)
store := common.DefaultStoreForPathOrFormat(opts.InputPath, opts.InputType)
log.Printf("Syncing keys for file %s", opts.InputPath)
tree, err := common.LoadEncryptedFile(store, opts.InputPath)
if err != nil {
Expand Down

0 comments on commit 9124783

Please sign in to comment.