diff --git a/pkg/validations/createvalidations/createvalidations.go b/pkg/validations/createvalidations/createvalidations.go index 7fbd879563e4..a42049530fdc 100644 --- a/pkg/validations/createvalidations/createvalidations.go +++ b/pkg/validations/createvalidations/createvalidations.go @@ -4,14 +4,9 @@ import ( "github.com/aws/eks-anywhere/pkg/validations" ) -// string values of supported validation names that can be skipped. -const ( - VSphereUserPriv = "vsphere-user-privilege" -) - // SkippableValidations represents all the validations we offer for users to skip. var SkippableValidations = []string{ - VSphereUserPriv, + validations.VSphereUserPriv, } func New(opts *validations.Opts) *CreateValidations { diff --git a/pkg/validations/skipvalidations.go b/pkg/validations/skipvalidations.go index af9467e9a5af..74d5272c21b2 100644 --- a/pkg/validations/skipvalidations.go +++ b/pkg/validations/skipvalidations.go @@ -5,6 +5,12 @@ import ( "strings" ) +// string values of supported validation names that can be skipped. +const ( + PDB = "pod-disruption" + VSphereUserPriv = "vsphere-user-privilege" +) + // ValidSkippableValidationsMap returns a map for all valid skippable validations as keys, defaulting values to false. // Defaulting to False means these validations won't be skipped unless set to True. func validSkippableValidationsMap(skippableValidations []string) map[string]bool { diff --git a/pkg/validations/skipvalidations_test.go b/pkg/validations/skipvalidations_test.go index 15492a5b7034..d95369ddb4af 100644 --- a/pkg/validations/skipvalidations_test.go +++ b/pkg/validations/skipvalidations_test.go @@ -24,25 +24,26 @@ func TestValidateSkippableValidation(t *testing.T) { want: nil, wantErr: fmt.Errorf("invalid validation name to be skipped. The supported validations that can be skipped using --skip-validations are %s", strings.Join(upgradevalidations.SkippableValidations[:], ",")), skippedValidations: []string{"test"}, - skippableValidations: []string{upgradevalidations.PDB}, + skippableValidations: upgradevalidations.SkippableValidations, }, { name: "valid upgrade validation param", want: map[string]bool{ - upgradevalidations.PDB: true, + validations.PDB: true, + validations.VSphereUserPriv: false, }, wantErr: nil, - skippedValidations: []string{upgradevalidations.PDB}, - skippableValidations: []string{upgradevalidations.PDB}, + skippedValidations: []string{validations.PDB}, + skippableValidations: upgradevalidations.SkippableValidations, }, { name: "valid create validation param", want: map[string]bool{ - createvalidations.VSphereUserPriv: true, + validations.VSphereUserPriv: true, }, wantErr: nil, - skippedValidations: []string{createvalidations.VSphereUserPriv}, - skippableValidations: []string{createvalidations.VSphereUserPriv}, + skippedValidations: []string{validations.VSphereUserPriv}, + skippableValidations: createvalidations.SkippableValidations, }, } for _, tt := range tests { diff --git a/pkg/validations/upgradevalidations/poddisruptionbudgets.go b/pkg/validations/upgradevalidations/poddisruptionbudgets.go index 811e20871ff0..8f1ba844d25c 100644 --- a/pkg/validations/upgradevalidations/poddisruptionbudgets.go +++ b/pkg/validations/upgradevalidations/poddisruptionbudgets.go @@ -22,7 +22,7 @@ func ValidatePodDisruptionBudgets(ctx context.Context, k validations.KubectlClie } if len(podDisruptionBudgets.Items) != 0 { - return fmt.Errorf("one or more pod disruption budgets were detected on the cluster. Use the --skip-validations=%s flag if you wish to skip the validations for pod disruption budgets and proceed with the upgrade operation", PDB) + return fmt.Errorf("one or more pod disruption budgets were detected on the cluster. Use the --skip-validations=%s flag if you wish to skip the validations for pod disruption budgets and proceed with the upgrade operation", validations.PDB) } return nil diff --git a/pkg/validations/upgradevalidations/poddisruptionbudgets_test.go b/pkg/validations/upgradevalidations/poddisruptionbudgets_test.go index 0fd97acffb67..e5fcc0d6d269 100644 --- a/pkg/validations/upgradevalidations/poddisruptionbudgets_test.go +++ b/pkg/validations/upgradevalidations/poddisruptionbudgets_test.go @@ -55,7 +55,7 @@ func TestValidatePodDisruptionBudgets(t *testing.T) { }, }, }, - wantErr: fmt.Errorf("one or more pod disruption budgets were detected on the cluster. Use the --skip-validations=%s flag if you wish to skip the validations for pod disruption budgets and proceed with the upgrade operation", upgradevalidations.PDB), + wantErr: fmt.Errorf("one or more pod disruption budgets were detected on the cluster. Use the --skip-validations=%s flag if you wish to skip the validations for pod disruption budgets and proceed with the upgrade operation", validations.PDB), }, { name: "PDBs don't exist on cluster", diff --git a/pkg/validations/upgradevalidations/preflightvalidations.go b/pkg/validations/upgradevalidations/preflightvalidations.go index 254b95285d5f..69df88443d27 100644 --- a/pkg/validations/upgradevalidations/preflightvalidations.go +++ b/pkg/validations/upgradevalidations/preflightvalidations.go @@ -105,7 +105,7 @@ func (u *UpgradeValidations) PreflightValidations(ctx context.Context) []validat }) } - if !u.Opts.SkippedValidations[PDB] { + if !u.Opts.SkippedValidations[validations.PDB] { upgradeValidations = append( upgradeValidations, func() *validations.ValidationResult { diff --git a/pkg/validations/upgradevalidations/upgradevalidations.go b/pkg/validations/upgradevalidations/upgradevalidations.go index 8d5a455fa1fb..62690583e7bc 100644 --- a/pkg/validations/upgradevalidations/upgradevalidations.go +++ b/pkg/validations/upgradevalidations/upgradevalidations.go @@ -4,14 +4,10 @@ import ( "github.com/aws/eks-anywhere/pkg/validations" ) -// string values of supported validation names that can be skipped. -const ( - PDB = "pod-disruption" -) - // SkippableValidations represents all the validations we offer for users to skip. var SkippableValidations = []string{ - PDB, + validations.PDB, + validations.VSphereUserPriv, } func New(opts *validations.Opts) *UpgradeValidations {