From 3677c7c4e3dd6b6d4bc5e3968850c777f667eb53 Mon Sep 17 00:00:00 2001 From: Alex Lokshin Date: Fri, 9 Feb 2024 11:02:41 -0500 Subject: [PATCH] fix: Unable to get k8s cluster configuration (#3017) Co-authored-by: alexlokshin-czi --- cli/COVERAGE | 2 +- cli/cmd/COVERAGE | 2 +- cli/cmd/config.go | 10 +++------- cli/cmd/root.go | 1 + shared/backend/aws/backend.go | 15 +++++++++++++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cli/COVERAGE b/cli/COVERAGE index d56bb3138f..9b8f0cc1c0 100644 --- a/cli/COVERAGE +++ b/cli/COVERAGE @@ -1 +1 @@ -20.76 \ No newline at end of file +20.67 \ No newline at end of file diff --git a/cli/cmd/COVERAGE b/cli/cmd/COVERAGE index 3b5b5d8f0b..bd1523922a 100644 --- a/cli/cmd/COVERAGE +++ b/cli/cmd/COVERAGE @@ -1 +1 @@ -11.0 \ No newline at end of file +10.8 \ No newline at end of file diff --git a/cli/cmd/config.go b/cli/cmd/config.go index 56effbd7c6..b8c496ef93 100644 --- a/cli/cmd/config.go +++ b/cli/cmd/config.go @@ -22,15 +22,11 @@ var ( stack string fromEnv string fromStack string - logger *logrus.Logger reveal bool v2 bool ) func init() { - logger = logrus.New() - logger.SetLevel(logrus.InfoLevel) - rootCmd.AddCommand(configCmd) config.ConfigureCmdWithBootstrapConfig(configCmd) configCmd.PersistentFlags().StringVarP(&stack, "stack", "s", "", "Specify the stack that this applies to") @@ -187,7 +183,7 @@ var configGetCmd = &cobra.Command{ Short: "get config", Long: "Get the config for the given app, env, stack, and key", SilenceUsage: true, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PreRunE: func(cmd *cobra.Command, args []string) error { checklist := util.NewValidationCheckList() return util.ValidateEnvironment(cmd.Context(), checklist.TerraformInstalled, @@ -263,7 +259,7 @@ var configSetCmd = &cobra.Command{ Short: "set config", Long: "Set the config for the given app, env, stack, and key to the provided value", SilenceUsage: true, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PreRunE: func(cmd *cobra.Command, args []string) error { checklist := util.NewValidationCheckList() return util.ValidateEnvironment(cmd.Context(), checklist.TerraformInstalled, @@ -333,7 +329,7 @@ var configDeleteCmd = &cobra.Command{ Short: "delete config", Long: "Delete the config for the given app, env, stack, and key", SilenceUsage: true, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PreRunE: func(cmd *cobra.Command, args []string) error { checklist := util.NewValidationCheckList() return util.ValidateEnvironment(cmd.Context(), checklist.TerraformInstalled, diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 8f1f0fcddc..30794ae702 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -50,6 +50,7 @@ var rootCmd = &cobra.Command{ return errors.Wrap(err, "missing verbose flag") } if verbose { + log.Info("Running in verbose mode") log.SetLevel(log.DebugLevel) log.SetReportCaller(true) } diff --git a/shared/backend/aws/backend.go b/shared/backend/aws/backend.go index 139510a6c9..6b365d5985 100644 --- a/shared/backend/aws/backend.go +++ b/shared/backend/aws/backend.go @@ -111,6 +111,20 @@ func NewAWSBackend( // Create an AWS session if we don't have one if b.awsConfig == nil { + logrus.Debug("Creating an AWS Config:\n") + if b.awsRegion != nil { + logrus.Debugf("\tRegion: %s\n", *b.awsRegion) + } + if b.awsProfile != nil { + logrus.Debugf("\tProfile: %s\n", *b.awsProfile) + } + if b.awsAccountID != nil { + logrus.Debugf("\tAccountID: %s\n", *b.awsAccountID) + } + if b.awsRoleArn != nil { + logrus.Debugf("\tRoleArn: %s\n", *b.awsRoleArn) + } + options := []func(*configv2.LoadOptions) error{ configv2.WithRegion(*b.awsRegion), configv2.WithRetryer(func() aws.Retryer { @@ -176,6 +190,7 @@ func NewAWSBackend( } if b.eksclient == nil { + logrus.Debugf("Creating an EKS client: region=%s. \n", b.awsConfig.Region) b.eksclient = eks.NewFromConfig(*b.awsConfig) }