From 25918ae8d6580180ccb6790ee08ba02a62f6d885 Mon Sep 17 00:00:00 2001 From: Aaron Turner Date: Tue, 31 Oct 2023 21:20:12 -0700 Subject: [PATCH] Remove deprecated features Remove all code & documentation references to deprecated features. Fixes: #663 --- CHANGELOG.md | 11 +++- cmd/aws-sso/main.go | 1 - cmd/aws-sso/setup_wizard_cmd.go | 11 +--- docs/config.md | 1 - sso/settings.go | 103 ++++++++++---------------------- sso/settings_test.go | 33 +--------- sso/testdata/settings.yaml | 1 - 7 files changed, 42 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d394b6eb..12b542d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,15 +17,22 @@ * `aws-sso` commands other than `cache` and `login` no longer can trigger a cache refresh or update of `~/.aws/config` file -### Removed Commands and Flags +### Removed Commands, Config Options and Flags * Remove `config`, `config-profiles` and `completions` commands and replace with `setup` - * Remove `flush` command. Use `logout` + * Remove `flush` command. Use `logout` instead * Remove `--no-cache` flag * Remove `CacheRefresh` configuration option. `aws-sso` will only update the cache when you ask it to via `aws-sso cache` * Remove `tags --force-update` flag * Remove `AutoConfigCheck` configuration option. + * Remove references to all deprecated features: + * `AccountIdStr()` function for `ProfileFormat`. + * `AccountIdStr` field is replaced by `AccountIdPad` in `list` command and `ListFields` in config.yaml + * `ARN` field is replaced by `Arn` in `list` command and `ListFields` in config.yaml + * `ExpiresStr` field is replaced by `Expires` in `list` command and `ListFields` in config.yaml + * `FirefoxOpenUrlInContainer` config option + * `ConfigUrlAction` config option ## [v1.14.2] - 2023-10-19 diff --git a/cmd/aws-sso/main.go b/cmd/aws-sso/main.go index 48a4e2d2..71f0aba6 100644 --- a/cmd/aws-sso/main.go +++ b/cmd/aws-sso/main.go @@ -89,7 +89,6 @@ var DEFAULT_CONFIG map[string]interface{} = map[string]interface{}{ "ConsoleDuration": 60, "DefaultRegion": "us-east-1", "DefaultSSO": "Default", - "FirefoxOpenUrlInContainer": false, "FullTextSearch": true, "HistoryLimit": 10, "HistoryMinutes": 1440, // 24hrs diff --git a/cmd/aws-sso/setup_wizard_cmd.go b/cmd/aws-sso/setup_wizard_cmd.go index 2b7a002e..4dc7380b 100644 --- a/cmd/aws-sso/setup_wizard_cmd.go +++ b/cmd/aws-sso/setup_wizard_cmd.go @@ -65,16 +65,7 @@ func setupWizard(ctx *RunContext, reconfig, addSSO, advanced bool) error { `) if reconfig { - // migrate old boolean flag to enum - if s.FirefoxOpenUrlInContainer { - s.UrlAction = url.OpenUrlContainer - } - - // upgrade deprecated config option - if s.ConfigUrlAction != "" && s.ConfigProfilesUrlAction == "" { - s.ConfigProfilesUrlAction, _ = url.NewConfigProfilesAction(s.ConfigUrlAction) - s.ConfigUrlAction = "" - } + // Usually this is where we do migrations & upgrades for deprecations // skips: // - SSORegion // - DefaultRegion diff --git a/docs/config.md b/docs/config.md index d105ef50..a9120d91 100644 --- a/docs/config.md +++ b/docs/config.md @@ -378,7 +378,6 @@ By default, `ProfileFormat` is set to `{{ .AccountIdPad }}:{{ .RoleName }}`. AWS SSO CLI uses [sprig](http://masterminds.github.io/sprig/) for most of its functions, but a few custom functions are available: - * `AccountIdStr(x)` -- Converts the `.AccountId` variable to a string. Deprecated. Use `.AccountIdPad` variable instead. * `EmptyString(x)` -- Returns true/false if the value `x` is an empty string * `FirstItem([]x)` -- Returns the first item in a list that is not an empty string * `StringsJoin(x, []y)` -- Joins the items in `y` with the string `x` diff --git a/sso/settings.go b/sso/settings.go index 6c68d37c..8300defc 100644 --- a/sso/settings.go +++ b/sso/settings.go @@ -44,37 +44,35 @@ const ( ) type Settings struct { - configFile string // name of this file - cacheFile string // name of cache file; always passed in via CLI args - Cache *Cache `yaml:"-"` // our cache data - SSO map[string]*SSOConfig `koanf:"SSOConfig" yaml:"SSOConfig,omitempty"` - DefaultSSO string `koanf:"DefaultSSO" yaml:"DefaultSSO,omitempty"` // specify default SSO by key - SecureStore string `koanf:"SecureStore" yaml:"SecureStore,omitempty"` // json or keyring - DefaultRegion string `koanf:"DefaultRegion" yaml:"DefaultRegion,omitempty"` - ConsoleDuration int32 `koanf:"ConsoleDuration" yaml:"ConsoleDuration,omitempty"` - JsonStore string `koanf:"JsonStore" yaml:"JsonStore,omitempty"` - Threads int `koanf:"Threads" yaml:"Threads,omitempty"` - MaxBackoff int `koanf:"MaxBackoff" yaml:"MaxBackoff,omitempty"` - MaxRetry int `koanf:"MaxRetry" yaml:"MaxRetry,omitempty"` - FirefoxOpenUrlInContainer bool `koanf:"FirefoxOpenUrlInContainer" yaml:"FirefoxOpenUrlInContainer,omitempty"` // deprecated - UrlAction url.Action `koanf:"UrlAction" yaml:"UrlAction"` - Browser string `koanf:"Browser" yaml:"Browser,omitempty"` - ConfigUrlAction string `koanf:"ConfigUrlAction" yaml:"ConfigUrlAction,omitempty"` // deprecated - ConfigProfilesBinaryPath string `koanf:"ConfigProfilesBinaryPath" yaml:"ConfigProfilesBinaryPath,omitempty"` - ConfigProfilesUrlAction url.ConfigProfilesAction `koanf:"ConfigProfilesUrlAction" yaml:"ConfigProfilesUrlAction,omitempty"` - UrlExecCommand []string `koanf:"UrlExecCommand" yaml:"UrlExecCommand,omitempty"` // string or list - LogLevel string `koanf:"LogLevel" yaml:"LogLevel,omitempty"` - LogLines bool `koanf:"LogLines" yaml:"LogLines,omitempty"` - HistoryLimit int64 `koanf:"HistoryLimit" yaml:"HistoryLimit,omitempty"` - HistoryMinutes int64 `koanf:"HistoryMinutes" yaml:"HistoryMinutes,omitempty"` - ProfileFormat string `koanf:"ProfileFormat" yaml:"ProfileFormat,omitempty"` - AccountPrimaryTag []string `koanf:"AccountPrimaryTag" yaml:"AccountPrimaryTag,omitempty"` - FirstTag string `koanf:"FirstTag" yaml:"FirstTag,omitempty"` - PromptColors PromptColors `koanf:"PromptColors" yaml:"PromptColors,omitempty"` // go-prompt colors - ListFields []string `koanf:"ListFields" yaml:"ListFields,omitempty"` - ConfigVariables map[string]interface{} `koanf:"ConfigVariables" yaml:"ConfigVariables,omitempty"` - EnvVarTags []string `koanf:"EnvVarTags" yaml:"EnvVarTags,omitempty"` - FullTextSearch bool `koanf:"FullTextSearch" yaml:"FullTextSearch"` + configFile string // name of this file + cacheFile string // name of cache file; always passed in via CLI args + Cache *Cache `yaml:"-"` // our cache data + SSO map[string]*SSOConfig `koanf:"SSOConfig" yaml:"SSOConfig,omitempty"` + DefaultSSO string `koanf:"DefaultSSO" yaml:"DefaultSSO,omitempty"` // specify default SSO by key + SecureStore string `koanf:"SecureStore" yaml:"SecureStore,omitempty"` // json or keyring + DefaultRegion string `koanf:"DefaultRegion" yaml:"DefaultRegion,omitempty"` + ConsoleDuration int32 `koanf:"ConsoleDuration" yaml:"ConsoleDuration,omitempty"` + JsonStore string `koanf:"JsonStore" yaml:"JsonStore,omitempty"` + Threads int `koanf:"Threads" yaml:"Threads,omitempty"` + MaxBackoff int `koanf:"MaxBackoff" yaml:"MaxBackoff,omitempty"` + MaxRetry int `koanf:"MaxRetry" yaml:"MaxRetry,omitempty"` + UrlAction url.Action `koanf:"UrlAction" yaml:"UrlAction"` + Browser string `koanf:"Browser" yaml:"Browser,omitempty"` + ConfigProfilesBinaryPath string `koanf:"ConfigProfilesBinaryPath" yaml:"ConfigProfilesBinaryPath,omitempty"` + ConfigProfilesUrlAction url.ConfigProfilesAction `koanf:"ConfigProfilesUrlAction" yaml:"ConfigProfilesUrlAction,omitempty"` + UrlExecCommand []string `koanf:"UrlExecCommand" yaml:"UrlExecCommand,omitempty"` // string or list + LogLevel string `koanf:"LogLevel" yaml:"LogLevel,omitempty"` + LogLines bool `koanf:"LogLines" yaml:"LogLines,omitempty"` + HistoryLimit int64 `koanf:"HistoryLimit" yaml:"HistoryLimit,omitempty"` + HistoryMinutes int64 `koanf:"HistoryMinutes" yaml:"HistoryMinutes,omitempty"` + ProfileFormat string `koanf:"ProfileFormat" yaml:"ProfileFormat,omitempty"` + AccountPrimaryTag []string `koanf:"AccountPrimaryTag" yaml:"AccountPrimaryTag,omitempty"` + FirstTag string `koanf:"FirstTag" yaml:"FirstTag,omitempty"` + PromptColors PromptColors `koanf:"PromptColors" yaml:"PromptColors,omitempty"` // go-prompt colors + ListFields []string `koanf:"ListFields" yaml:"ListFields,omitempty"` + ConfigVariables map[string]interface{} `koanf:"ConfigVariables" yaml:"ConfigVariables,omitempty"` + EnvVarTags []string `koanf:"EnvVarTags" yaml:"EnvVarTags,omitempty"` + FullTextSearch bool `koanf:"FullTextSearch" yaml:"FullTextSearch"` } // GetDefaultRegion scans the config settings file to pick the most local DefaultRegion from the tree @@ -220,47 +218,8 @@ func (s *Settings) Validate() error { // applyDeprecations migrates old config options to the new one and returns true // if we made a change func (s *Settings) applyDeprecations() bool { - var change = false - var err error - - // Upgrade ConfigUrlAction to ConfigProfilesUrlAction because we want to - // deprecate ConfigUrlAction. - if s.ConfigUrlAction != "" && s.ConfigProfilesUrlAction == "" { - s.ConfigProfilesUrlAction, err = url.NewConfigProfilesAction(s.ConfigUrlAction) - if err != nil { - log.Warnf("Invalid value for ConfigUrlAction: %s", s.ConfigUrlAction) - } - s.ConfigUrlAction = string(url.Undef) // disable old value so it is omitempty - change = true - } - - // Upgrade FirefoxOpenUrlInContainer to UrlAction = open-url-in-container - if s.FirefoxOpenUrlInContainer { - s.UrlAction = url.OpenUrlContainer - s.FirefoxOpenUrlInContainer = false // disable old value so it is omitempty - change = true - } - - // ExpiresStr => Expires in v1.11.0 - // AccountIdStr => AccountIdPad v1.11.0 - // ARN => Arn v1.11.0 - if len(s.ListFields) > 0 { - for i, v := range s.ListFields { - switch v { - case "ExpiresStr": - s.ListFields[i] = "Expires" - case "AccountIdStr": - s.ListFields[i] = "AccountIdPad" - case "ARN": - s.ListFields[i] = "Arn" - } - } - } - - // AccountIdStr .AccountId => .AccountIdPad in v1.11.0 - s.ProfileFormat = strings.ReplaceAll(s.ProfileFormat, "AccountIdStr .AccountId", ".AccountIdPad") - - return change + // no deprecations yet in v2.0 :) + return false } // Save overwrites the current config file with our settings (not recommended) diff --git a/sso/settings_test.go b/sso/settings_test.go index ee2dc14e..5508ed3e 100644 --- a/sso/settings_test.go +++ b/sso/settings_test.go @@ -61,14 +61,6 @@ func (suite *SettingsTestSuite) TestLoadSettings() { t := suite.T() assert.Equal(t, TEST_SETTINGS_FILE, suite.settings.ConfigFile()) - - // ensure we upgraded ConfigUrlAction to ConfigProfilesUrlAction - assert.Equal(t, "", suite.settings.ConfigUrlAction) - assert.Equal(t, url.ConfigProfilesOpen, suite.settings.ConfigProfilesUrlAction) - - // ensure we upgraded FirefoxOpenUrlInContainer - assert.False(t, suite.settings.FirefoxOpenUrlInContainer) - assert.Equal(t, url.OpenUrlContainer, suite.settings.UrlAction) } func (suite *SettingsTestSuite) TestGetSelectedSSO() { @@ -331,30 +323,7 @@ func TestCreatedAt(t *testing.T) { } func TestApplyDeprecations(t *testing.T) { - s := &Settings{ - ListFields: []string{"Foo", "Bar", "ExpiresStr", "AccountIdStr", "ARN"}, - ProfileFormat: "{{ AccountIdStr .AccountId }}:{{ .RoleName }}", - FirefoxOpenUrlInContainer: true, - ConfigProfilesUrlAction: url.ConfigProfilesUndef, - ConfigUrlAction: string(url.Exec), - } - - r := s.applyDeprecations() - assert.True(t, r) - - // Upgrade ConfigUrlAction to ConfigProfilesUrlAction - assert.Equal(t, string(url.Undef), s.ConfigUrlAction) - assert.Equal(t, url.ConfigProfilesExec, s.ConfigProfilesUrlAction) - - // Upgrade FirefoxOpenUrlInContainer to UrlAction - assert.Equal(t, url.OpenUrlContainer, s.UrlAction) - assert.Equal(t, false, s.FirefoxOpenUrlInContainer) - - // ExpiresStr => Expires, etc - assert.Equal(t, []string{"Foo", "Bar", "Expires", "AccountIdPad", "Arn"}, s.ListFields) - - // AccountIdStr .AccountId => .AccountIdPad - assert.Equal(t, "{{ .AccountIdPad }}:{{ .RoleName }}", s.ProfileFormat) + // as of v2.0 it does nothing... } func TestGetExecutable(t *testing.T) { diff --git a/sso/testdata/settings.yaml b/sso/testdata/settings.yaml index 8e01c119..a4cc67cb 100644 --- a/sso/testdata/settings.yaml +++ b/sso/testdata/settings.yaml @@ -60,7 +60,6 @@ SSOConfig: DefaultSSO: Default Browser: /Applications/Firefox.app UrlAction: print -FirefoxOpenUrlInContainer: true SecureStore: json JsonStore: ./testdata/store.json ProfileFormat: '{{.AccountName}}/{{.RoleName}}'