diff --git a/internal/commands/templates.go b/internal/commands/templates.go index fc64a1651..b02e5be69 100644 --- a/internal/commands/templates.go +++ b/internal/commands/templates.go @@ -99,41 +99,6 @@ the login command with the --tenant and --region flag: return "" } -func getUsageTemplate() string { - return fmt.Sprintf(`%s{{if .Runnable}} - {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} - {{.CommandPath}} [parameters...]{{end}}{{if gt (len .Aliases) 0}} - -%s - {{.NameAndAliases}}{{end}}{{if .HasExample}} - -%s -{{.Example}}{{end}}{{if .HasAvailableSubCommands}} - -%s{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} - {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} - -%s -{{WrappedLocalFlagUsages . | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}} - -%s -{{WrappedInheritedFlagUsages . | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} - -%s{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} - {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} - -Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}} -`, - ansi.Faint("Usage:"), - ansi.Faint("Aliases:"), - ansi.Faint("Examples:"), - ansi.Faint("Available Resources:"), - ansi.Faint("Flags:"), - ansi.Faint("Global Flags:"), - ansi.Faint("Additional help topics:"), - ) -} - func namespaceUsageTemplate() string { return fmt.Sprintf(`%s{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} diff --git a/internal/config/config.go b/internal/config/config.go index e32afddb9..8932fe570 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -235,9 +235,13 @@ func isProfile(value interface{}) bool { // syncConfig merges a runtimeViper instance with the config file being used. func syncConfig(runtimeViper *viper.Viper) error { - runtimeViper.MergeInConfig() + if err := runtimeViper.MergeInConfig(); err != nil { + return err + } + profilesFile := viper.ConfigFileUsed() runtimeViper.SetConfigFile(profilesFile) + // Ensure we preserve the config file type runtimeViper.SetConfigType(filepath.Ext(profilesFile)) diff --git a/internal/config/profile.go b/internal/config/profile.go index 6be84e196..2ecda1aa1 100644 --- a/internal/config/profile.go +++ b/internal/config/profile.go @@ -151,7 +151,9 @@ func (p *Profile) writeProfile(runtimeViper *viper.Viper) error { runtimeViper.Set(p.GetConfigField("device_name"), strings.TrimSpace(p.DeviceName)) } - runtimeViper.MergeInConfig() + if err := runtimeViper.MergeInConfig(); err != nil { + return err + } runtimeViper.SetConfigFile(profilesFile) @@ -165,16 +167,3 @@ func (p *Profile) writeProfile(runtimeViper *viper.Viper) error { return nil } - -func (p *Profile) safeRemove(v *viper.Viper, key string) *viper.Viper { - if v.IsSet(p.GetConfigField(key)) { - newViper, err := removeKey(v, p.GetConfigField(key)) - if err == nil { - // I don't want to fail the entire login process on not being able to remove - // the old secret_key field so if there's no error - return newViper - } - } - - return v -}