From 8f186bcb37e4214f4d35fc8c8187151e40138fcc Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 27 Aug 2022 15:52:02 +0200 Subject: [PATCH 1/2] input-type and output-type description do not mention ini format. --- cmd/sops/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 80f1f132e..882baa79b 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -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", From 566d51a25bf1f66154152c91adc1260082b40b55 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 27 Aug 2022 15:52:29 +0200 Subject: [PATCH 2/2] Add --input-type option to updatekeys. --- cmd/sops/main.go | 5 +++++ cmd/sops/subcommand/updatekeys/updatekeys.go | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 882baa79b..58c38e350 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -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 @@ -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 diff --git a/cmd/sops/subcommand/updatekeys/updatekeys.go b/cmd/sops/subcommand/updatekeys/updatekeys.go index 143bcfe60..2b00989c0 100644 --- a/cmd/sops/subcommand/updatekeys/updatekeys.go +++ b/cmd/sops/subcommand/updatekeys/updatekeys.go @@ -19,6 +19,7 @@ type Opts struct { KeyServices []keyservice.KeyServiceClient Interactive bool ConfigPath string + InputType string } // UpdateKeys update the keys for a given file @@ -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 {