Skip to content

Commit

Permalink
Allow users to skip api server extra args preflight validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Mar 14, 2024
1 parent 6aee7c2 commit e4b9ef4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/validations/createvalidations/createvalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
// SkippableValidations represents all the validations we offer for users to skip.
var SkippableValidations = []string{
validations.VSphereUserPriv,
validations.APIServerExtraArgs,
}

func New(opts *validations.Opts) *CreateValidations {
Expand Down
11 changes: 11 additions & 0 deletions pkg/validations/createvalidations/preflightvalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,16 @@ func (v *CreateValidations) PreflightValidations(ctx context.Context) []validati
)
}

if !v.Opts.SkippedValidations[validations.APIServerExtraArgs] {
createValidations = append(
createValidations,
func() *validations.ValidationResult {
return &validations.ValidationResult{
Name: "validate api server extra args",
Remediation: "ensure apiServerExtraArgs have only supported flags (service-account-issuer, service-account-jwks-uri)",
Err: validations.ValidateAPIServerExtraArgs(v.Opts.Spec),
}
})
}
return createValidations
}
7 changes: 4 additions & 3 deletions pkg/validations/skipvalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

// string values of supported validation names that can be skipped.
const (
PDB = "pod-disruption"
VSphereUserPriv = "vsphere-user-privilege"
EksaVersionSkew = "eksa-version-skew"
PDB = "pod-disruption"
VSphereUserPriv = "vsphere-user-privilege"
EksaVersionSkew = "eksa-version-skew"
APIServerExtraArgs = "api-server-extra-args"
)

// ValidSkippableValidationsMap returns a map for all valid skippable validations as keys, defaulting values to false.
Expand Down
10 changes: 6 additions & 4 deletions pkg/validations/skipvalidations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ func TestValidateSkippableValidation(t *testing.T) {
{
name: "valid upgrade validation param",
want: map[string]bool{
validations.PDB: true,
validations.VSphereUserPriv: false,
validations.EksaVersionSkew: false,
validations.PDB: true,
validations.VSphereUserPriv: false,
validations.EksaVersionSkew: false,
validations.APIServerExtraArgs: false,
},
wantErr: nil,
skippedValidations: []string{validations.PDB},
Expand All @@ -40,7 +41,8 @@ func TestValidateSkippableValidation(t *testing.T) {
{
name: "valid create validation param",
want: map[string]bool{
validations.VSphereUserPriv: true,
validations.VSphereUserPriv: true,
validations.APIServerExtraArgs: false,
},
wantErr: nil,
skippedValidations: []string{validations.VSphereUserPriv},
Expand Down
11 changes: 11 additions & 0 deletions pkg/validations/upgradevalidations/preflightvalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ func (u *UpgradeValidations) PreflightValidations(ctx context.Context) []validat
}
})
}
if !u.Opts.SkippedValidations[validations.APIServerExtraArgs] {
upgradeValidations = append(
upgradeValidations,
func() *validations.ValidationResult {
return &validations.ValidationResult{
Name: "validate api server extra args",
Remediation: "ensure apiServerExtraArgs have only supported flags (service-account-issuer, service-account-jwks-uri)",
Err: validations.ValidateAPIServerExtraArgs(u.Opts.Spec),
}
})
}
return upgradeValidations
}

Expand Down
1 change: 1 addition & 0 deletions pkg/validations/upgradevalidations/upgradevalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var SkippableValidations = []string{
validations.PDB,
validations.VSphereUserPriv,
validations.EksaVersionSkew,
validations.APIServerExtraArgs,
}

func New(opts *validations.Opts) *UpgradeValidations {
Expand Down

0 comments on commit e4b9ef4

Please sign in to comment.