Skip to content

Commit

Permalink
fix missing status
Browse files Browse the repository at this point in the history
  • Loading branch information
bitte-ein-bit committed Apr 30, 2024
1 parent 0be2149 commit c2ab4e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2ab4e4

Please sign in to comment.