From a9cd3ff1a5edeabd2598834869072030947e7889 Mon Sep 17 00:00:00 2001 From: TuhinNair <59875893+TuhinNair@users.noreply.github.com> Date: Sat, 9 May 2020 02:25:23 +0700 Subject: [PATCH] Fix #671: `updatekeys` checks for config file flag (#672) * update 'updatekeys' subcommand to use config (if exists) from commandline * Fix #671: `updatekeys` checks for config file flag The 'updatekeys' subcommand did not check for the config flag in the command line. Add that check and if found use it to set configPath. * Fix #671: `updatekeys` checks for config file flag The 'updatekeys' subcommand did not check for the config global string flag. Add that check and if found use it to set configPath. * Fix #671: `updatekeys` checks for config file flag The 'updatekeys' subcommand did not check for the config global string flag. Add that check and if found use it to set configPath. Edit: Remove mistake file addition * Update cmd/sops/main.go Co-authored-by: Adrian Utrilla --- cmd/sops/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 0b5e4ce11..ee03072c3 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -474,9 +474,15 @@ func main() { }, }, keyserviceFlags...), Action: func(c *cli.Context) error { - configPath, err := config.FindConfigFile(".") - if err != nil { - return common.NewExitError(err, codes.ErrorGeneric) + var err error + var configPath string + if c.GlobalString("config") != "" { + configPath = c.GlobalString("config") + } else { + configPath, err = config.FindConfigFile(".") + if err != nil { + return common.NewExitError(err, codes.ErrorGeneric) + } } if c.NArg() < 1 { return common.NewExitError("Error: no file specified", codes.NoFileSpecified)