From 9b13e876fa3db30eaf44df4a2af4d51aa675b30a Mon Sep 17 00:00:00 2001 From: Nic Manoogian Date: Mon, 12 Feb 2024 18:26:56 -0500 Subject: [PATCH] Address gosec issues --- pkg/cmd/activity.go | 4 +- pkg/cmd/configs.go | 64 +++++++++++++++++++++++-------- pkg/cmd/configs_logs.go | 32 ++++++++++++---- pkg/cmd/configs_tokens.go | 45 ++++++++++++++++------ pkg/cmd/enclave_configs.go | 56 ++++++++++++++++++++------- pkg/cmd/enclave_configs_logs.go | 33 ++++++++++++---- pkg/cmd/enclave_configs_tokens.go | 41 +++++++++++++++----- pkg/cmd/enclave_environments.go | 9 ++++- pkg/cmd/enclave_projects.go | 12 ++++-- pkg/cmd/enclave_secrets.go | 41 +++++++++++++++----- pkg/cmd/enclave_setup.go | 8 +++- pkg/cmd/environments.go | 20 +++++++--- pkg/cmd/open.go | 16 ++++++-- pkg/cmd/projects.go | 12 ++++-- pkg/cmd/run.go | 22 ++++++++--- pkg/cmd/secrets.go | 61 +++++++++++++++++++++-------- pkg/cmd/secrets_notes.go | 8 +++- pkg/cmd/setup.go | 8 +++- pkg/controllers/secrets.go | 6 +-- pkg/tui/common/logging.go | 2 +- pkg/tui/gui/cmp_configs.go | 2 +- pkg/tui/gui/cmp_prompt_help.go | 4 +- pkg/tui/gui/cmp_prompt_intro.go | 4 +- pkg/tui/gui/cmp_prompt_save.go | 4 +- pkg/tui/gui/cmp_secret_view.go | 2 +- pkg/tui/gui/cmp_secrets.go | 12 +++--- pkg/tui/gui/cmp_secrets_filter.go | 2 +- pkg/tui/gui/dispatch.go | 12 +++--- pkg/tui/gui/gui.go | 4 +- pkg/tui/gui/layout.go | 2 +- pkg/tui/tui_app.go | 2 +- 31 files changed, 400 insertions(+), 150 deletions(-) diff --git a/pkg/cmd/activity.go b/pkg/cmd/activity.go index 16149505..99078984 100644 --- a/pkg/cmd/activity.go +++ b/pkg/cmd/activity.go @@ -84,7 +84,9 @@ func activityLogIDsValidArgs(cmd *cobra.Command, args []string, toComplete strin func init() { activityGetCmd.Flags().String("log", "", "activity log id") - activityGetCmd.RegisterFlagCompletionFunc("log", activityLogIDsValidArgs) + if err := activityGetCmd.RegisterFlagCompletionFunc("log", activityLogIDsValidArgs); err != nil { + utils.HandleError(err) + } activityCmd.AddCommand(activityGetCmd) activityCmd.Flags().IntP("number", "n", 20, "max number of logs to display") diff --git a/pkg/cmd/configs.go b/pkg/cmd/configs.go index e9beed58..99224b44 100644 --- a/pkg/cmd/configs.go +++ b/pkg/cmd/configs.go @@ -355,29 +355,45 @@ func unlockedConfigNamesValidArgs(cmd *cobra.Command, args []string, toComplete func init() { configsCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsCmd.Flags().StringP("environment", "e", "", "config environment") - configsCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs) + if err := configsCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs); err != nil { + utils.HandleError(err) + } configsCmd.Flags().IntP("number", "n", 100, "max number of configs to display") configsCmd.Flags().Int("page", 1, "page to display") configsGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsGetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsCmd.AddCommand(configsGetCmd) configsCreateCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsCreateCmd.Flags().String("name", "", "config name") configsCreateCmd.Flags().StringP("environment", "e", "", "config environment") - configsCreateCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs) + if err := configsCreateCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs); err != nil { + utils.HandleError(err) + } configsCmd.AddCommand(configsCreateCmd) configsUpdateCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsUpdateCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsUpdateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsUpdateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsUpdateCmd.Flags().String("name", "", "config name") if err := configsUpdateCmd.MarkFlagRequired("name"); err != nil { utils.HandleError(err) @@ -386,30 +402,46 @@ func init() { configsCmd.AddCommand(configsUpdateCmd) configsDeleteCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsDeleteCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") configsCmd.AddCommand(configsDeleteCmd) configsLockCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsLockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsLockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLockCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsLockCmd.RegisterFlagCompletionFunc("config", lockedConfigNamesValidArgs) + if err := configsLockCmd.RegisterFlagCompletionFunc("config", lockedConfigNamesValidArgs); err != nil { + utils.HandleError(err) + } configsLockCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") configsCmd.AddCommand(configsLockCmd) configsUnlockCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsUnlockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsUnlockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsUnlockCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsUnlockCmd.RegisterFlagCompletionFunc("config", unlockedConfigNamesValidArgs) + if err := configsUnlockCmd.RegisterFlagCompletionFunc("config", unlockedConfigNamesValidArgs); err != nil { + utils.HandleError(err) + } configsUnlockCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") configsCmd.AddCommand(configsUnlockCmd) configsCloneCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsCloneCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsCloneCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsCloneCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsCloneCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsCloneCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsCloneCmd.Flags().String("name", "", "new config name") configsCmd.AddCommand(configsCloneCmd) diff --git a/pkg/cmd/configs_logs.go b/pkg/cmd/configs_logs.go index 93b80a7d..e3676a81 100644 --- a/pkg/cmd/configs_logs.go +++ b/pkg/cmd/configs_logs.go @@ -118,26 +118,42 @@ func configLogIDsValidArgs(cmd *cobra.Command, args []string, toComplete string) func init() { configsLogsCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsLogsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsLogsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLogsCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsLogsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsLogsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsLogsCmd.Flags().Int("page", 1, "log page to display") configsLogsCmd.Flags().IntP("number", "n", 20, "max number of logs to display") configsCmd.AddCommand(configsLogsCmd) configsLogsGetCmd.Flags().String("log", "", "audit log id") - configsLogsGetCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs) + if err := configsLogsGetCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLogsGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsLogsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsLogsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLogsGetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsLogsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsLogsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsLogsCmd.AddCommand(configsLogsGetCmd) configsLogsRollbackCmd.Flags().String("log", "", "audit log id") - configsLogsRollbackCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs) + if err := configsLogsRollbackCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLogsRollbackCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsLogsRollbackCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsLogsRollbackCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsLogsRollbackCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsLogsRollbackCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsLogsRollbackCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsLogsCmd.AddCommand(configsLogsRollbackCmd) } diff --git a/pkg/cmd/configs_tokens.go b/pkg/cmd/configs_tokens.go index 406b56a1..6b89c62d 100644 --- a/pkg/cmd/configs_tokens.go +++ b/pkg/cmd/configs_tokens.go @@ -189,38 +189,61 @@ func configTokenSlugsValidArgs(cmd *cobra.Command, args []string, toComplete str func init() { configsTokensCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsTokensCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsTokensCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsTokensCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsTokensCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsCmd.AddCommand(configsTokensCmd) configsTokensGetCmd.Flags().String("slug", "", "service token slug") - configsTokensGetCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs) + if err := configsTokensGetCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsTokensGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsTokensGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensGetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsTokensGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsTokensGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsTokensCmd.AddCommand(configsTokensGetCmd) configsTokensCreateCmd.Flags().String("name", "", "service token name") configsTokensCreateCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsTokensCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsTokensCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensCreateCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsTokensCreateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsTokensCreateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsTokensCreateCmd.Flags().Bool("plain", false, "print only the token, without formatting") configsTokensCreateCmd.Flags().Bool("copy", false, "copy the token to your clipboard") configsTokensCreateCmd.Flags().Duration("max-age", 0, "token will expire after specified duration, (e.g. '3h', '15m')") configsTokensCreateCmd.Flags().String("access", "read", "the token's access. one of [\"read\", \"read/write\"]") - configsTokensCreateCmd.RegisterFlagCompletionFunc("access", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + err := configsTokensCreateCmd.RegisterFlagCompletionFunc("access", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{"read", "read/write"}, cobra.ShellCompDirectiveDefault }) + if err != nil { + utils.HandleError(err) + } configsTokensCmd.AddCommand(configsTokensCreateCmd) configsTokensRevokeCmd.Flags().String("slug", "", "service token slug") - configsTokensRevokeCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs) + if err := configsTokensRevokeCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensRevokeCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - configsTokensRevokeCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := configsTokensRevokeCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } configsTokensRevokeCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - configsTokensRevokeCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := configsTokensRevokeCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } configsTokensCmd.AddCommand(configsTokensRevokeCmd) } diff --git a/pkg/cmd/enclave_configs.go b/pkg/cmd/enclave_configs.go index 9a43c5c7..940f2bb9 100644 --- a/pkg/cmd/enclave_configs.go +++ b/pkg/cmd/enclave_configs.go @@ -92,29 +92,45 @@ var enclaveConfigsUnlockCmd = &cobra.Command{ func init() { enclaveConfigsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCmd.Flags().StringP("environment", "e", "", "config environment") - enclaveConfigsCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs) + if err := enclaveConfigsCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCmd.Flags().IntP("number", "n", 100, "max number of configs to display") enclaveConfigsCmd.Flags().Int("page", 1, "page to display") enclaveConfigsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCmd.AddCommand(enclaveConfigsGetCmd) enclaveConfigsCreateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCreateCmd.Flags().String("name", "", "config name") enclaveConfigsCreateCmd.Flags().StringP("environment", "e", "", "config environment") - enclaveConfigsCreateCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs) + if err := enclaveConfigsCreateCmd.RegisterFlagCompletionFunc("environment", configEnvironmentIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCmd.AddCommand(enclaveConfigsCreateCmd) enclaveConfigsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsUpdateCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsUpdateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsUpdateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsUpdateCmd.Flags().String("name", "", "config name") if err := enclaveConfigsUpdateCmd.MarkFlagRequired("name"); err != nil { utils.HandleError(err) @@ -123,23 +139,35 @@ func init() { enclaveConfigsCmd.AddCommand(enclaveConfigsUpdateCmd) enclaveConfigsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") enclaveConfigsCmd.AddCommand(enclaveConfigsDeleteCmd) enclaveConfigsLockCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsLockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsLockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLockCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsLockCmd.RegisterFlagCompletionFunc("config", lockedConfigNamesValidArgs) + if err := enclaveConfigsLockCmd.RegisterFlagCompletionFunc("config", lockedConfigNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLockCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") enclaveConfigsCmd.AddCommand(enclaveConfigsLockCmd) enclaveConfigsUnlockCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsUnlockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsUnlockCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsUnlockCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsUnlockCmd.RegisterFlagCompletionFunc("config", unlockedConfigNamesValidArgs) + if err := enclaveConfigsUnlockCmd.RegisterFlagCompletionFunc("config", unlockedConfigNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsUnlockCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") enclaveConfigsCmd.AddCommand(enclaveConfigsUnlockCmd) diff --git a/pkg/cmd/enclave_configs_logs.go b/pkg/cmd/enclave_configs_logs.go index 9976b17c..52a97d73 100644 --- a/pkg/cmd/enclave_configs_logs.go +++ b/pkg/cmd/enclave_configs_logs.go @@ -16,6 +16,7 @@ limitations under the License. package cmd import ( + "github.com/DopplerHQ/cli/pkg/utils" "github.com/spf13/cobra" ) @@ -51,26 +52,42 @@ var enclaveConfigsLogsRollbackCmd = &cobra.Command{ func init() { enclaveConfigsLogsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsLogsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsLogsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsLogsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsLogsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsCmd.Flags().Int("page", 1, "log page to display") enclaveConfigsLogsCmd.Flags().IntP("number", "n", 20, "max number of logs to display") enclaveConfigsCmd.AddCommand(enclaveConfigsLogsCmd) enclaveConfigsLogsGetCmd.Flags().String("log", "", "audit log id") - enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs) + if err := enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsLogsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsCmd.AddCommand(enclaveConfigsLogsGetCmd) enclaveConfigsLogsRollbackCmd.Flags().String("log", "", "audit log id") - enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs) + if err := enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("log", configLogIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsRollbackCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsRollbackCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsLogsRollbackCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsLogsCmd.AddCommand(enclaveConfigsLogsRollbackCmd) } diff --git a/pkg/cmd/enclave_configs_tokens.go b/pkg/cmd/enclave_configs_tokens.go index 6803d247..1b1752f7 100644 --- a/pkg/cmd/enclave_configs_tokens.go +++ b/pkg/cmd/enclave_configs_tokens.go @@ -16,6 +16,7 @@ limitations under the License. package cmd import ( + "github.com/DopplerHQ/cli/pkg/utils" "github.com/spf13/cobra" ) @@ -62,34 +63,54 @@ var enclaveConfigsTokensRevokeCmd = &cobra.Command{ func init() { enclaveConfigsTokensCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsTokensCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsTokensCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsTokensCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsTokensCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsCmd.AddCommand(enclaveConfigsTokensCmd) enclaveConfigsTokensGetCmd.Flags().String("slug", "", "service token slug") - enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs) + if err := enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsTokensGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensCmd.AddCommand(enclaveConfigsTokensGetCmd) enclaveConfigsTokensCreateCmd.Flags().String("name", "", "service token name") enclaveConfigsTokensCreateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsTokensCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsTokensCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensCreateCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsTokensCreateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsTokensCreateCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensCreateCmd.Flags().Bool("plain", false, "print only the token, without formatting") enclaveConfigsTokensCreateCmd.Flags().Bool("copy", false, "copy the token to your clipboard") enclaveConfigsTokensCreateCmd.Flags().String("access", "read", "the token's access. one of [\"read\", \"read/write\"]") enclaveConfigsTokensCmd.AddCommand(enclaveConfigsTokensCreateCmd) enclaveConfigsTokensRevokeCmd.Flags().String("slug", "", "service token slug") - enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs) + if err := enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("slug", configTokenSlugsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensRevokeCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensRevokeCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveConfigsTokensRevokeCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveConfigsTokensCmd.AddCommand(enclaveConfigsTokensRevokeCmd) } diff --git a/pkg/cmd/enclave_environments.go b/pkg/cmd/enclave_environments.go index dcecc55f..977f6c9b 100644 --- a/pkg/cmd/enclave_environments.go +++ b/pkg/cmd/enclave_environments.go @@ -16,6 +16,7 @@ limitations under the License. package cmd import ( + "github.com/DopplerHQ/cli/pkg/utils" "github.com/spf13/cobra" ) @@ -41,11 +42,15 @@ var enclaveEnvironmentsGetCmd = &cobra.Command{ func init() { enclaveEnvironmentsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveEnvironmentsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveEnvironmentsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveEnvironmentsCmd.AddCommand(enclaveEnvironmentsGetCmd) enclaveEnvironmentsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveEnvironmentsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveEnvironmentsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveEnvironmentsCmd.Flags().IntP("number", "n", 100, "max number of environments to display") enclaveEnvironmentsCmd.Flags().Int("page", 1, "page to display") enclaveCmd.AddCommand(enclaveEnvironmentsCmd) diff --git a/pkg/cmd/enclave_projects.go b/pkg/cmd/enclave_projects.go index e9431dc5..da45b5ab 100644 --- a/pkg/cmd/enclave_projects.go +++ b/pkg/cmd/enclave_projects.go @@ -75,7 +75,9 @@ func init() { enclaveProjectsCmd.Flags().Int("page", 1, "page to display") enclaveProjectsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveProjectsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveProjectsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveProjectsCmd.AddCommand(enclaveProjectsGetCmd) enclaveProjectsCreateCmd.Flags().String("name", "", "project name") @@ -84,11 +86,15 @@ func init() { enclaveProjectsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") enclaveProjectsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveProjectsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveProjectsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveProjectsCmd.AddCommand(enclaveProjectsDeleteCmd) enclaveProjectsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveProjectsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveProjectsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveProjectsUpdateCmd.Flags().String("name", "", "project name") if err := enclaveProjectsUpdateCmd.MarkFlagRequired("name"); err != nil { utils.HandleError(err) diff --git a/pkg/cmd/enclave_secrets.go b/pkg/cmd/enclave_secrets.go index 95635678..1dc96d1f 100644 --- a/pkg/cmd/enclave_secrets.go +++ b/pkg/cmd/enclave_secrets.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/DopplerHQ/cli/pkg/models" + "github.com/DopplerHQ/cli/pkg/utils" "github.com/spf13/cobra" ) @@ -95,17 +96,25 @@ $ doppler enclave secrets download --format=env --no-file`, func init() { enclaveSecretsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSecretsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSecretsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSecretsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSecretsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") enclaveSecretsCmd.Flags().Bool("visibility", false, "include secret visibility in table output") enclaveSecretsCmd.Flags().Bool("only-names", false, "only print the secret names; omit all values") enclaveSecretsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSecretsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSecretsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSecretsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSecretsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsGetCmd.Flags().Bool("plain", false, "print values without formatting") enclaveSecretsGetCmd.Flags().Bool("copy", false, "copy the value(s) to your clipboard") enclaveSecretsGetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") @@ -114,25 +123,37 @@ func init() { enclaveSecretsCmd.AddCommand(enclaveSecretsGetCmd) enclaveSecretsSetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSecretsSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSecretsSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsSetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSecretsSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSecretsSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsSetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") enclaveSecretsSetCmd.Flags().Bool("no-interactive", false, "do not allow entering secret value via interactive mode") enclaveSecretsCmd.AddCommand(enclaveSecretsSetCmd) enclaveSecretsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSecretsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSecretsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSecretsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSecretsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsDeleteCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") enclaveSecretsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") enclaveSecretsCmd.AddCommand(enclaveSecretsDeleteCmd) enclaveSecretsDownloadCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSecretsDownloadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSecretsDownloadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsDownloadCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSecretsDownloadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSecretsDownloadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSecretsDownloadCmd.Flags().String("format", models.JSON.String(), "output format. one of [json, env]") enclaveSecretsDownloadCmd.Flags().String("passphrase", "", "passphrase to use for encrypting the secrets file. the default passphrase is computed using your current configuration.") enclaveSecretsDownloadCmd.Flags().Bool("no-file", false, "print the response to stdout") diff --git a/pkg/cmd/enclave_setup.go b/pkg/cmd/enclave_setup.go index 4e315e5f..1b90e2bd 100644 --- a/pkg/cmd/enclave_setup.go +++ b/pkg/cmd/enclave_setup.go @@ -32,9 +32,13 @@ var enclaveSetupCmd = &cobra.Command{ func init() { enclaveSetupCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - enclaveSetupCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := enclaveSetupCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } enclaveSetupCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - enclaveSetupCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := enclaveSetupCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } enclaveSetupCmd.Flags().Bool("no-interactive", false, "do not prompt for information. if the project or config is not specified, an error will be thrown.") enclaveSetupCmd.Flags().Bool("no-save-token", false, "do not save the token to the config when passed via flag or environment variable.") diff --git a/pkg/cmd/environments.go b/pkg/cmd/environments.go index 1bb83b10..b7e12cfd 100644 --- a/pkg/cmd/environments.go +++ b/pkg/cmd/environments.go @@ -199,27 +199,37 @@ func renameEnvironment(cmd *cobra.Command, args []string) { func init() { environmentsGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - environmentsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := environmentsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } environmentsCmd.AddCommand(environmentsGetCmd) environmentsCreateCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - environmentsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := environmentsCreateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } environmentsCmd.AddCommand(environmentsCreateCmd) environmentsDeleteCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - environmentsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := environmentsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } environmentsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") environmentsCmd.AddCommand(environmentsDeleteCmd) environmentsRenameCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - environmentsRenameCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := environmentsRenameCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } environmentsRenameCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") environmentsRenameCmd.Flags().String("name", "", "new name") environmentsRenameCmd.Flags().String("slug", "", "new slug") environmentsCmd.AddCommand(environmentsRenameCmd) environmentsCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - environmentsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := environmentsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } environmentsCmd.Flags().IntP("number", "n", 100, "max number of environments to display") environmentsCmd.Flags().Int("page", 1, "page to display") rootCmd.AddCommand(environmentsCmd) diff --git a/pkg/cmd/open.go b/pkg/cmd/open.go index 4d6d4c31..0457ae53 100644 --- a/pkg/cmd/open.go +++ b/pkg/cmd/open.go @@ -87,17 +87,25 @@ var openDocsCmd = &cobra.Command{ func init() { openDashboardCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - openDashboardCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := openDashboardCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } openDashboardCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - openDashboardCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := openDashboardCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } openCmd.AddCommand(openDashboardCmd) openCmd.AddCommand(openStatusCmd) openCmd.AddCommand(openGithubCmd) openCmd.AddCommand(openDocsCmd) openCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - openCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := openCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } openCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") - openCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := openCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } rootCmd.AddCommand(openCmd) } diff --git a/pkg/cmd/projects.go b/pkg/cmd/projects.go index 3f97e529..f3c46a00 100644 --- a/pkg/cmd/projects.go +++ b/pkg/cmd/projects.go @@ -212,7 +212,9 @@ func init() { projectsCmd.Flags().Int("page", 1, "page to display") projectsGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - projectsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := projectsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } projectsCmd.AddCommand(projectsGetCmd) projectsCreateCmd.Flags().String("name", "", "project name") @@ -221,11 +223,15 @@ func init() { projectsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") projectsDeleteCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - projectsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := projectsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } projectsCmd.AddCommand(projectsDeleteCmd) projectsUpdateCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - projectsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := projectsUpdateCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } projectsUpdateCmd.Flags().String("name", "", "project name") projectsUpdateCmd.Flags().String("description", "", "project description") if err := projectsUpdateCmd.MarkFlagRequired("name"); err != nil { diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index cd483bbe..13fed4e6 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -240,7 +240,9 @@ doppler run --mount secrets.json -- cat secrets.json`, // killing the process here will cause the cleanup goroutine below to run, thereby unlocking the mutex utils.LogDebug(fmt.Sprintf("Sending SIGTERM to process %d", c.Process.Pid)) - c.Process.Signal(syscall.SIGTERM) + if e := c.Process.Signal(syscall.SIGTERM); e != nil { + utils.LogDebugError(e) + } // wait up to 10 sec for the process to exit for i := 0; i < 10; i++ { if !utils.IsProcessRunning(c.Process) { @@ -563,9 +565,13 @@ func init() { forwardSignals := !isatty.IsTerminal(os.Stdout.Fd()) runCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - runCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := runCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } runCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - runCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := runCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } runCmd.Flags().String("command", "", "command to execute (e.g. \"echo hi\")") // note: requires using "--preserve-env=VALUE", doesn't work with "--preserve-env VALUE" runCmd.Flags().String("preserve-env", "false", "a comma separated list of secrets for which the existing value from the environment, if any, should take precedence over the Doppler secret value. value must be specified with an equals sign (e.g. --preserve-env=\"FOO,BAR\"). specify \"true\" to give precedence to all existing environment values, however this has potential security implications and should be used at your own risk.") @@ -573,9 +579,12 @@ func init() { // https://github.com/spf13/pflag#setting-no-option-default-values-for-flags runCmd.Flags().Lookup("preserve-env").NoOptDefVal = "true" runCmd.Flags().String("name-transformer", "", fmt.Sprintf("output name transformer. one of %v", validEnvCompatNameTransformersList)) - runCmd.RegisterFlagCompletionFunc("name-transformer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + err := runCmd.RegisterFlagCompletionFunc("name-transformer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return models.SecretsEnvCompatNameTransformerTypes, cobra.ShellCompDirectiveDefault }) + if err != nil { + utils.HandleError(err) + } runCmd.Flags().Duration("dynamic-ttl", 0, "(BETA) dynamic secrets will expire after specified duration, (e.g. '3h', '15m')") // fallback flags runCmd.Flags().String("fallback", "", "path to the fallback file. encrypted secrets are written to this file after each successful fetch. secrets will be read from this file if subsequent connections are unsuccessful.") @@ -590,9 +599,12 @@ func init() { // secrets mount flags runCmd.Flags().String("mount", "", "write secrets to an ephemeral file, accessible at DOPPLER_CLI_SECRETS_PATH. when enabled, secrets are NOT injected into the environment") runCmd.Flags().String("mount-format", "json", fmt.Sprintf("file format to use. if not specified, will be auto-detected from mount name. one of %v", models.SecretsMountFormats)) - runCmd.RegisterFlagCompletionFunc("mount-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + err = runCmd.RegisterFlagCompletionFunc("mount-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{projectTemplateFileName}, cobra.ShellCompDirectiveDefault }) + if err != nil { + utils.HandleError(err) + } runCmd.Flags().String("mount-template", "", "template file to use. secrets will be rendered into this template before mount. see 'doppler secrets substitute' for more info.") runCmd.Flags().Int("mount-max-reads", 0, "maximum number of times the mounted secrets file can be read (0 for unlimited)") runCmd.Flags().StringSliceVar(&secretsToInclude, "only-secrets", []string{}, "only include the specified secrets") diff --git a/pkg/cmd/secrets.go b/pkg/cmd/secrets.go index 4da75f8e..9b56e59a 100644 --- a/pkg/cmd/secrets.go +++ b/pkg/cmd/secrets.go @@ -590,17 +590,25 @@ func secretNamesValidArgs(cmd *cobra.Command, args []string, toComplete string) func init() { secretsCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsCmd.Flags().Bool("visibility", false, "include secret visibility in table output") secretsCmd.Flags().Bool("only-names", false, "only print the secret names; omit all values") secretsGetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsGetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsGetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsGetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsGetCmd.Flags().Bool("plain", false, "print values without formatting") secretsGetCmd.Flags().Bool("copy", false, "copy the value(s) to your clipboard") secretsGetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") @@ -609,37 +617,56 @@ func init() { secretsCmd.AddCommand(secretsGetCmd) secretsSetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsSetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsSetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsSetCmd.Flags().Bool("no-interactive", false, "do not allow entering secret value via interactive mode") secretsCmd.AddCommand(secretsSetCmd) secretsUploadCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsUploadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsUploadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsUploadCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsUploadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsUploadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsUploadCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsCmd.AddCommand(secretsUploadCmd) secretsDeleteCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsDeleteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsDeleteCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsDeleteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsDeleteCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsDeleteCmd.Flags().BoolP("yes", "y", false, "proceed without confirmation") secretsCmd.AddCommand(secretsDeleteCmd) secretsDownloadCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsDownloadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsDownloadCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsDownloadCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsDownloadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsDownloadCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsDownloadCmd.Flags().String("format", models.JSON.String(), fmt.Sprintf("output format. one of %s", validFormatList)) secretsDownloadCmd.Flags().String("name-transformer", "", fmt.Sprintf("output name transformer. one of %v", validNameTransformersList)) - secretsDownloadCmd.RegisterFlagCompletionFunc("name-transformer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + err := secretsDownloadCmd.RegisterFlagCompletionFunc("name-transformer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return models.SecretsNameTransformerTypes, cobra.ShellCompDirectiveDefault }) + if err != nil { + utils.HandleError(err) + } secretsDownloadCmd.Flags().String("passphrase", "", "passphrase to use for encrypting the secrets file. the default passphrase is computed using your current configuration.") secretsDownloadCmd.Flags().Bool("no-file", false, "print the response to stdout") secretsDownloadCmd.Flags().Duration("dynamic-ttl", 0, "(BETA) dynamic secrets will expire after specified duration, (e.g. '3h', '15m')") @@ -654,9 +681,13 @@ func init() { secretsCmd.AddCommand(secretsDownloadCmd) secretsSubstituteCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsSubstituteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsSubstituteCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsSubstituteCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsSubstituteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsSubstituteCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsSubstituteCmd.Flags().String("output", "", "path to the output file. by default the rendered text will be written to stdout.") secretsSubstituteCmd.Flags().Duration("dynamic-ttl", 0, "(BETA) dynamic secrets will expire after specified duration, (e.g. '3h', '15m')") secretsCmd.AddCommand(secretsSubstituteCmd) diff --git a/pkg/cmd/secrets_notes.go b/pkg/cmd/secrets_notes.go index 7854ec6b..a5dcfa91 100644 --- a/pkg/cmd/secrets_notes.go +++ b/pkg/cmd/secrets_notes.go @@ -73,9 +73,13 @@ func setSecretNote(cmd *cobra.Command, args []string) { func init() { secretsNotesSetCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - secretsNotesSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := secretsNotesSetCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } secretsNotesSetCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - secretsNotesSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := secretsNotesSetCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } secretsNotesCmd.AddCommand(secretsNotesSetCmd) secretsCmd.AddCommand(secretsNotesCmd) diff --git a/pkg/cmd/setup.go b/pkg/cmd/setup.go index e60d581f..7429da26 100644 --- a/pkg/cmd/setup.go +++ b/pkg/cmd/setup.go @@ -279,9 +279,13 @@ func setupFileErrorCheck(repos []models.ProjectConfig) { func init() { setupCmd.Flags().StringP("project", "p", "", "project (e.g. backend)") - setupCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs) + if err := setupCmd.RegisterFlagCompletionFunc("project", projectIDsValidArgs); err != nil { + utils.HandleError(err) + } setupCmd.Flags().StringP("config", "c", "", "config (e.g. dev)") - setupCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs) + if err := setupCmd.RegisterFlagCompletionFunc("config", configNamesValidArgs); err != nil { + utils.HandleError(err) + } setupCmd.Flags().Bool("no-interactive", false, "do not prompt for information. if the project or config is not specified, an error will be thrown.") setupCmd.Flags().Bool("no-save-token", false, "do not save the token to the config when passed via flag or environment variable.") diff --git a/pkg/controllers/secrets.go b/pkg/controllers/secrets.go index 3bb77422..9191b5a0 100644 --- a/pkg/controllers/secrets.go +++ b/pkg/controllers/secrets.go @@ -449,11 +449,11 @@ func FetchSecrets(localConfig models.ScopedOptions, enableCache bool, fallbackOp canUseFallback := statusCode != 401 && statusCode != 403 && statusCode != 404 if !canUseFallback { utils.LogDebug(fmt.Sprintf("Received %v. Deleting (if exists) %v", statusCode, fallbackOpts.Path)) - os.Remove(fallbackOpts.Path) + _ = os.Remove(fallbackOpts.Path) utils.LogDebug(fmt.Sprintf("Received %v. Deleting (if exists) %v", statusCode, fallbackOpts.LegacyPath)) - os.Remove(fallbackOpts.LegacyPath) + _ = os.Remove(fallbackOpts.LegacyPath) utils.LogDebug(fmt.Sprintf("Received %v. Deleting (if exists) %v", statusCode, metadataPath)) - os.Remove(metadataPath) + _ = os.Remove(metadataPath) } if fallbackOpts.Enable && canUseFallback { diff --git a/pkg/tui/common/logging.go b/pkg/tui/common/logging.go index 3799832e..bdd80b02 100644 --- a/pkg/tui/common/logging.go +++ b/pkg/tui/common/logging.go @@ -44,7 +44,7 @@ func newDebugLogger() *logrus.Logger { if err != nil { log.Fatal(err) } - file, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600) + file, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600) // #nosec G304 if err != nil { log.Fatalf("Unable to log to log file: %v", err) } diff --git a/pkg/tui/gui/cmp_configs.go b/pkg/tui/gui/cmp_configs.go index 301207e2..16807091 100644 --- a/pkg/tui/gui/cmp_configs.go +++ b/pkg/tui/gui/cmp_configs.go @@ -70,7 +70,7 @@ func (self *ConfigsComponent) GetTitle() string { return "Configs (1)" } func (self *ConfigsComponent) OnFocus() { if self.selectedIdx >= len(state.Configs()) { - self.SelectIdx(0) + _ = self.SelectIdx(0) } } diff --git a/pkg/tui/gui/cmp_prompt_help.go b/pkg/tui/gui/cmp_prompt_help.go index e6282b78..87a6c8dc 100644 --- a/pkg/tui/gui/cmp_prompt_help.go +++ b/pkg/tui/gui/cmp_prompt_help.go @@ -54,8 +54,8 @@ func (self *PromptHelpComponent) GetTitle() string { return "Help" } func (self *PromptHelpComponent) GetFocusable() bool { return true } func (self *PromptHelpComponent) OnFocus() { - self.Render() - self.gui.g.SetViewOnTop(self.GetViewName()) + _ = self.Render() + _, _ = self.gui.g.SetViewOnTop(self.GetViewName()) self.GetView().Visible = true } diff --git a/pkg/tui/gui/cmp_prompt_intro.go b/pkg/tui/gui/cmp_prompt_intro.go index 72bf364f..3e4f4559 100644 --- a/pkg/tui/gui/cmp_prompt_intro.go +++ b/pkg/tui/gui/cmp_prompt_intro.go @@ -55,8 +55,8 @@ func (self *PromptIntroComponent) GetTitle() string { return "Welcome" } func (self *PromptIntroComponent) GetFocusable() bool { return true } func (self *PromptIntroComponent) OnFocus() { - self.Render() - self.gui.g.SetViewOnTop(self.GetViewName()) + _ = self.Render() + _, _ = self.gui.g.SetViewOnTop(self.GetViewName()) self.GetView().Visible = true } diff --git a/pkg/tui/gui/cmp_prompt_save.go b/pkg/tui/gui/cmp_prompt_save.go index 8c7f6127..6b34bf78 100644 --- a/pkg/tui/gui/cmp_prompt_save.go +++ b/pkg/tui/gui/cmp_prompt_save.go @@ -55,8 +55,8 @@ func (self *PromptSaveComponent) GetTitle() string { return "Confirm Changes" func (self *PromptSaveComponent) GetFocusable() bool { return true } func (self *PromptSaveComponent) OnFocus() { - self.Render() - self.gui.g.SetViewOnTop(self.GetViewName()) + _ = self.Render() + _, _ = self.gui.g.SetViewOnTop(self.GetViewName()) self.GetView().Visible = true } diff --git a/pkg/tui/gui/cmp_secret_view.go b/pkg/tui/gui/cmp_secret_view.go index 2419510d..87edf63f 100644 --- a/pkg/tui/gui/cmp_secret_view.go +++ b/pkg/tui/gui/cmp_secret_view.go @@ -114,7 +114,7 @@ func CreateSecretViewModel(gui *Gui, secret *state.Secret) (*SecretViewModel, er func (gui *Gui) SecretNameEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { switch { case key == gocui.KeyEnter: - gui.cmps.secrets.FinishEditingCurrentField() + _ = gui.cmps.secrets.FinishEditingCurrentField() return false case key == gocui.KeySpace: key = '_' diff --git a/pkg/tui/gui/cmp_secrets.go b/pkg/tui/gui/cmp_secrets.go index fb05a08f..5e3cfa02 100644 --- a/pkg/tui/gui/cmp_secrets.go +++ b/pkg/tui/gui/cmp_secrets.go @@ -79,7 +79,7 @@ func CreateSecretsComponent(gui *Gui) (*SecretsComponent, error) { return nil }) gui.bindKey("Secrets", 'y', gocui.ModNone, func(v *gocui.View) error { - cmp.YankCurrentField() + _ = cmp.YankCurrentField() return nil }) gui.bindKey("Secrets", 'a', gocui.ModNone, func(v *gocui.View) error { @@ -173,7 +173,7 @@ func (self *SecretsComponent) OnFocus() { if self.activeSVM != nil { toFocus := self.activeSVM.nameView - self.gui.g.SetCurrentView(toFocus.Name()) + _, _ = self.gui.g.SetCurrentView(toFocus.Name()) } } @@ -188,8 +188,8 @@ func (self *SecretsComponent) createSVMs() error { self.svmsForSecretsSetAt = state.SecretsSetAt() for _, oldView := range self.secretVMs { - self.gui.g.DeleteView(oldView.nameView.Name()) - self.gui.g.DeleteView(oldView.valueView.Name()) + _ = self.gui.g.DeleteView(oldView.nameView.Name()) + _ = self.gui.g.DeleteView(oldView.valueView.Name()) } self.scrollDelta = 0 @@ -263,7 +263,7 @@ func (self *SecretsComponent) AppendSVM() error { self.gui.mutexes.SecretViewsMutex.Unlock() // We need to position the new SVM before we can select it - self.gui.layout(self.gui.g) + _ = self.gui.layout(self.gui.g) visibleSVMs := self.visibleSVMs() if err = self.SelectSVM(len(visibleSVMs)-1, true); err != nil { @@ -388,7 +388,7 @@ func (self *SecretsComponent) FinishEditingCurrentField() error { self.gui.g.Cursor = false self.gui.g.CurrentView().Editable = false self.gui.g.CurrentView().ParentView.Editable = false - self.gui.g.CurrentView().SetCursor(0, 0) + _ = self.gui.g.CurrentView().SetCursor(0, 0) return nil } diff --git a/pkg/tui/gui/cmp_secrets_filter.go b/pkg/tui/gui/cmp_secrets_filter.go index 3375e839..ad7f1ee5 100644 --- a/pkg/tui/gui/cmp_secrets_filter.go +++ b/pkg/tui/gui/cmp_secrets_filter.go @@ -72,7 +72,7 @@ func (gui *Gui) SecretsFilterEditor(v *gocui.View, key gocui.Key, ch rune, mod g // As we filter, we want to make sure that we're pinning to the top of the secrets view gui.cmps.secrets.scrollDelta = math.MaxInt - gui.layout(gui.g) + _ = gui.layout(gui.g) gui.cmps.secrets.SetActiveSVM(0) } return rendered diff --git a/pkg/tui/gui/dispatch.go b/pkg/tui/gui/dispatch.go index b078f4e9..a5f0f317 100644 --- a/pkg/tui/gui/dispatch.go +++ b/pkg/tui/gui/dispatch.go @@ -138,8 +138,8 @@ func (gui *Gui) load() { state.SetConfigs(configs) state.SetSecrets(secrets, gui.Opts.EnclaveProject.Value, gui.Opts.EnclaveConfig.Value) - gui.cmps.projects.SelectIdx(selectedProjectIdx) - gui.cmps.configs.SelectIdx(selectedConfigIdx) + _ = gui.cmps.projects.SelectIdx(selectedProjectIdx) + _ = gui.cmps.configs.SelectIdx(selectedConfigIdx) gui.setIsFetching(false) } @@ -171,7 +171,7 @@ func (gui *Gui) selectProject(projectIdx int) { state.SetSecrets(make([]state.Secret, 0), "", "") gui.setIsFetching(false) - gui.focusComponent(gui.cmps.configs) + _ = gui.focusComponent(gui.cmps.configs) } func (gui *Gui) selectConfig(configIdx int) { @@ -199,7 +199,7 @@ func (gui *Gui) selectConfig(configIdx int) { state.SetSecrets(secrets, curProj, curConf) gui.setIsFetching(false) - gui.focusComponent(gui.cmps.secrets) + _ = gui.focusComponent(gui.cmps.secrets) } func (gui *Gui) saveSecrets(changeRequests []models.ChangeRequest) { @@ -220,7 +220,7 @@ func (gui *Gui) saveSecrets(changeRequests []models.ChangeRequest) { }) if err := g.Wait(); err != nil { gui.handleError(err) - gui.focusComponent(gui.cmps.secrets) + _ = gui.focusComponent(gui.cmps.secrets) return } @@ -228,5 +228,5 @@ func (gui *Gui) saveSecrets(changeRequests []models.ChangeRequest) { state.SetSecrets(secrets, curProj, curConf) gui.setIsFetching(false) - gui.focusComponent(gui.cmps.secrets) + _ = gui.focusComponent(gui.cmps.secrets) } diff --git a/pkg/tui/gui/gui.go b/pkg/tui/gui/gui.go index 3d6fa6ce..ddf24d75 100644 --- a/pkg/tui/gui/gui.go +++ b/pkg/tui/gui/gui.go @@ -95,9 +95,9 @@ func (gui *Gui) run() error { // Set the default component focus if configuration.TUIShouldShowIntro() { - gui.focusComponent(gui.cmps.promptIntro) + _ = gui.focusComponent(gui.cmps.promptIntro) } else { - gui.focusComponent(gui.cmps.secrets) + _ = gui.focusComponent(gui.cmps.secrets) } // Fetch the data needed for the initial state of the app diff --git a/pkg/tui/gui/layout.go b/pkg/tui/gui/layout.go index 35f9e301..82a2464a 100644 --- a/pkg/tui/gui/layout.go +++ b/pkg/tui/gui/layout.go @@ -141,7 +141,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { // If possible, we want to pin the Y origin at the top (which improves the behavior of the // textarea as it's resizing). gocui is smart enough to adjust the origin down if the cursor // is out of bounds of the view size. - svm.valueView.SetOriginY(0) + _ = svm.valueView.SetOriginY(0) svm.valueView.RenderTextArea() } diff --git a/pkg/tui/tui_app.go b/pkg/tui/tui_app.go index 9a614c6a..47a4e246 100644 --- a/pkg/tui/tui_app.go +++ b/pkg/tui/tui_app.go @@ -51,5 +51,5 @@ func Start(opts models.ScopedOptions) { gui: gui, } - app.gui.RunAndHandleError() + _ = app.gui.RunAndHandleError() }