Skip to content

Commit c320af1

Browse files
authored
Remove fallback for reading old cli config schema (#1723)
1 parent 4c87fce commit c320af1

File tree

1 file changed

+1
-113
lines changed

1 file changed

+1
-113
lines changed

cli/cmd/lib_cli_config.go

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -112,114 +112,6 @@ var _cliConfigValidation = &cr.StructValidation{
112112
},
113113
}
114114

115-
// This is a copy of _cliConfigValidation except for Provider; it can be deleted when removing the old CLI config conversion check
116-
var _oldCLIConfigValidation = &cr.StructValidation{
117-
TreatNullAsEmpty: true,
118-
StructFieldValidations: []*cr.StructFieldValidation{
119-
{
120-
StructField: "Telemetry",
121-
BoolPtrValidation: &cr.BoolPtrValidation{
122-
Required: false,
123-
},
124-
},
125-
{
126-
StructField: "DefaultEnvironment",
127-
StringValidation: &cr.StringValidation{
128-
Default: "local",
129-
Required: false,
130-
AllowEmpty: true, // will get set to "local" in validate() if empty
131-
},
132-
},
133-
{
134-
StructField: "Environments",
135-
StructListValidation: &cr.StructListValidation{
136-
AllowExplicitNull: true,
137-
StructValidation: &cr.StructValidation{
138-
StructFieldValidations: []*cr.StructFieldValidation{
139-
{
140-
StructField: "Name",
141-
StringValidation: &cr.StringValidation{
142-
Required: true,
143-
MaxLength: 63,
144-
},
145-
},
146-
{
147-
StructField: "Provider",
148-
StringValidation: &cr.StringValidation{
149-
Required: false,
150-
AllowEmpty: true,
151-
},
152-
Parser: func(str string) (interface{}, error) {
153-
return types.ProviderTypeFromString(str), nil
154-
},
155-
},
156-
{
157-
StructField: "OperatorEndpoint",
158-
StringPtrValidation: &cr.StringPtrValidation{
159-
Required: false,
160-
Validator: cr.GetURLValidator(false, false),
161-
},
162-
},
163-
{
164-
StructField: "AWSAccessKeyID",
165-
StringPtrValidation: &cr.StringPtrValidation{
166-
Required: false,
167-
},
168-
},
169-
{
170-
StructField: "AWSSecretAccessKey",
171-
StringPtrValidation: &cr.StringPtrValidation{
172-
Required: false,
173-
},
174-
},
175-
},
176-
},
177-
},
178-
},
179-
},
180-
}
181-
182-
// this checks for the old CLI configuration schema and updates it to the new one
183-
// can be removed for 0.23 or 0.24 release
184-
func convertOldCLIConfig() (cliconfig.CLIConfig, bool) {
185-
cliConfig := cliconfig.CLIConfig{}
186-
errs := cr.ParseYAMLFile(&cliConfig, _oldCLIConfigValidation, _cliConfigPath)
187-
if errors.HasError(errs) {
188-
return cliconfig.CLIConfig{}, false
189-
}
190-
191-
if cliConfig.Telemetry != nil && *cliConfig.Telemetry == true {
192-
cliConfig.Telemetry = nil
193-
}
194-
195-
var hasEnvNamedAWS bool
196-
for _, env := range cliConfig.Environments {
197-
if env.Name == types.AWSProviderType.String() {
198-
hasEnvNamedAWS = true
199-
break
200-
}
201-
}
202-
203-
for _, env := range cliConfig.Environments {
204-
if env.Name == "default" && !hasEnvNamedAWS {
205-
env.Name = types.AWSProviderType.String()
206-
}
207-
208-
// if provider is set, this is not an old CLI config
209-
if env.Provider != types.UnknownProviderType {
210-
return cliconfig.CLIConfig{}, false
211-
}
212-
213-
env.Provider = types.AWSProviderType
214-
}
215-
216-
if err := writeCLIConfig(cliConfig); err != nil {
217-
return cliconfig.CLIConfig{}, false
218-
}
219-
220-
return cliConfig, true
221-
}
222-
223115
func promptForExistingEnvName(promptMsg string) string {
224116
configuredEnvNames, err := listConfiguredEnvNames()
225117
if err != nil {
@@ -1057,11 +949,7 @@ func readCLIConfig() (cliconfig.CLIConfig, error) {
1057949
cliConfig := cliconfig.CLIConfig{}
1058950
errs := cr.ParseYAMLFile(&cliConfig, _cliConfigValidation, _cliConfigPath)
1059951
if errors.HasError(errs) {
1060-
var succeeded bool
1061-
cliConfig, succeeded = convertOldCLIConfig()
1062-
if !succeeded {
1063-
return cliconfig.CLIConfig{}, errors.FirstError(errs...)
1064-
}
952+
return cliconfig.CLIConfig{}, errors.FirstError(errs...)
1065953
}
1066954

1067955
if err := cliConfig.Validate(); err != nil {

0 commit comments

Comments
 (0)