From a216cf2a65c02a03016ed6e80c1032dcd458c7f6 Mon Sep 17 00:00:00 2001 From: Ville Vesilehto Date: Sat, 12 Oct 2024 07:20:48 +0300 Subject: [PATCH] fix: errcheck for parsing CLI flags --- cmd/vault-plugin-auth-alicloud/main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/vault-plugin-auth-alicloud/main.go b/cmd/vault-plugin-auth-alicloud/main.go index 213cdb8..ac85db1 100644 --- a/cmd/vault-plugin-auth-alicloud/main.go +++ b/cmd/vault-plugin-auth-alicloud/main.go @@ -15,7 +15,10 @@ import ( func main() { apiClientMeta := &api.PluginAPIClientMeta{} flags := apiClientMeta.FlagSet() - flags.Parse(os.Args[1:]) + + if err := flags.Parse(os.Args[1:]); err != nil { + fatal(err) + } tlsConfig := apiClientMeta.GetTLSConfig() tlsProviderFunc := api.VaultPluginTLSProvider(tlsConfig) @@ -27,9 +30,12 @@ func main() { TLSProviderFunc: tlsProviderFunc, }) if err != nil { - logger := hclog.New(&hclog.LoggerOptions{}) - - logger.Error("plugin shutting down", "error", err) - os.Exit(1) + fatal(err) } } + +func fatal(err error) { + logger := hclog.New(&hclog.LoggerOptions{}) + logger.Error("plugin shutting down", "error", err) + os.Exit(1) +}