From c2ab4e4c1824b3f685048c3d964f56c4e8deccb1 Mon Sep 17 00:00:00 2001 From: Jonathan Vogt Date: Tue, 30 Apr 2024 17:06:38 +0200 Subject: [PATCH] fix missing status --- cmd/get.go | 5 ++--- cmd/root.go | 3 --- cmd/status.go | 12 ++++++++---- sample_config.yaml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index af3c2fc..6747a24 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -53,12 +53,12 @@ func init() { ) // Mark the old flag as deprecated. - err := cmdGet.Flags().MarkDeprecated("write-to-file", "please use output-file instead.") + err := cmdGet.Flags().MarkDeprecated("write-to-file", "please use output instead.") if err != nil { // we don't have a logger yet, so we can't use it but need to print the error to the console fmt.Printf("Error marking flag as deprecated: %v", err) } - err = cmdGet.Flags().MarkDeprecated("shell", "please use output-environment instead.") + err = cmdGet.Flags().MarkDeprecated("shell", "please use output instead.") if err != nil { // we don't have a logger yet, so we can't use it but need to print the error to the console fmt.Printf("Error marking flag as deprecated: %v", err) @@ -149,7 +149,6 @@ func writeCredentialsToFile(creds *aws.Credentials, app, file string) error { if err != nil { return fmt.Errorf("expanding config file path: %v", err) } - // Create the `global.credentials-path` directory if it doesn't exist. credsFileParentDir := filepath.Dir(path) if _, err := os.Stat(credsFileParentDir); os.IsNotExist(err) { log.Log.Warnf("Credentials directory '%s' does not exist - creating it", credsFileParentDir) diff --git a/cmd/root.go b/cmd/root.go index 11caa1d..d285fdc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -127,9 +127,6 @@ func initConfig(cmd *cobra.Command) error { } } - // // Set default config values - // viper.SetDefault("global.credentials-path", filepath.Join(home, ".aws", "credentials")) - // viper.SetDefault("global.cache.path", filepath.Join(home, ".aws", "credentials-cache")) } if err := viper.ReadInConfig(); err != nil { diff --git a/cmd/status.go b/cmd/status.go index d0d909e..12e60ca 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -23,12 +23,12 @@ var readFromFile string func init() { RootCmd.AddCommand(cmdStatus) cmdStatus.Flags().StringVarP( - &readFromFile, "read-from-file", "r", "", + &readFromFile, "read-from-file", "r", "~/.aws/credentials", "Read credentials from this file instead of the default (~/.aws/credentials)", ) - err := viper.BindPFlag("global.credentials-path", cmdStatus.Flags().Lookup("read-from-file")) + err := viper.BindPFlag("global.output", cmdStatus.Flags().Lookup("read-from-file")) if err != nil { - log.Log.Fatalf("Error binding flag global.credentials-path: %v", err) + log.Log.Fatalf("Error binding flag global.output: %v", err) } } @@ -42,10 +42,14 @@ var cmdStatus = &cobra.Command{ } func printStatus() { - credentialFile, err := homedir.Expand(viper.GetString("global.credentials-path")) + credentialFile, err := homedir.Expand(viper.GetString("global.output")) if err != nil { log.Log.Fatalf("Failed to expand home: %s", err) } + log.Log.Trace("Credential file: ", credentialFile) + if credentialFile == "credential_process" || credentialFile == "environment" { + return + } profiles, err := aws.GetValidProfiles(credentialFile) if err != nil { diff --git a/sample_config.yaml b/sample_config.yaml index 31a653d..94db778 100644 --- a/sample_config.yaml +++ b/sample_config.yaml @@ -13,7 +13,7 @@ apps: url: https://xxxxxxxx.oktapreview.com/home/amazon_aws/xxxxxxxxxxxxxxxxxxxx/137 global: aws-region: us-east-1 - credentials-path: ~/.aws/credentials + output: ~/.aws/credentials selected-app: sample-app-1 accounts: "0000000000000": Dev