Skip to content

Commit

Permalink
Consume new optional validators
Browse files Browse the repository at this point in the history
Signed-off-by: kevinrizza <krizza@redhat.com>
  • Loading branch information
kevinrizza committed Dec 13, 2023
1 parent b914c0b commit 2b68396
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
34 changes: 30 additions & 4 deletions internal/cmd/operator-sdk/bundle/validate/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,43 @@ const (
suiteKey = "suite"
)

// optionalValidators is a list of validators with 0their name, labels for CLI usage, and a light description.
// optionalValidators is a list of validators with their name, labels for CLI usage, and a light description.
var optionalValidators = validators{
{
Validator: apivalidation.OperatorHubValidator,
name: "operatorhub",
Validator: apivalidation.OperatorHubV2Validator,
name: "operatorhubv2",
labels: map[string]string{
nameKey: "operatorhub",
nameKey: "operatorhubv2",
suiteKey: "operatorframework",
},
desc: "OperatorHub.io metadata validation. ",
},
{
Validator: apivalidation.StandardCapabilitiesValidator,
name: "capabilities",
labels: map[string]string{
nameKey: "capabilities",
suiteKey: "operatorframework",
},
desc: "OperatorHub.io capabilities metadata validation. ",
},
{
Validator: apivalidation.StandardCategoriesValidator,
name: "categories",
labels: map[string]string{
nameKey: "categories",
suiteKey: "operatorframework",
},
desc: "OperatorHub.io categories metadata validation. ",
},
{
Validator: apivalidation.OperatorHubValidator,

Check failure on line 66 in internal/cmd/operator-sdk/bundle/validate/optional.go

View workflow job for this annotation

GitHub Actions / sanity

SA1019: apivalidation.OperatorHubValidator is deprecated: Use OperatorHubV2Validator, StandardCapabilitiesValidator and StandardCategoriesValidator for equivalent functionality. (staticcheck)
name: "operatorhub",
labels: map[string]string{
nameKey: "operatorhub",
},
desc: "Deprecated OperatorHub.io metadata validation. ",
},
{
Validator: apivalidation.CommunityOperatorValidator,
name: "community",
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/operator-sdk/bundle/validate/optional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var _ = Describe("Running optional validators", func() {
It("runs a validator for one selector on an empty bundle", func() {
bundle = &apimanifests.Bundle{}
sel = labels.SelectorFromSet(map[string]string{
nameKey: "operatorhub",
suiteKey: "operatorframework",
})
results = vals.run(bundle, sel, map[string]string{"k8s-version": "1.22"})
Expect(results).To(HaveLen(1))
Expand All @@ -61,7 +61,7 @@ var _ = Describe("Running optional validators", func() {
bundle = &apimanifests.Bundle{}
bundle.CSV = &v1alpha1.ClusterServiceVersion{}
sel = labels.SelectorFromSet(map[string]string{
nameKey: "operatorhub",
suiteKey: "operatorframework",
})
results = vals.run(bundle, sel, nil)
Expect(results).To(HaveLen(1))
Expand All @@ -84,14 +84,14 @@ var _ = Describe("Running optional validators", func() {
})
It("returns an error for an unmatched selector with no validators", func() {
sel = labels.SelectorFromSet(map[string]string{
nameKey: "operatorhub",
suiteKey: "operatorframework",
})
err = vals.checkMatches(sel)
Expect(err).To(HaveOccurred())
})
It("returns no error for an unmatched selector with all optional validators", func() {
sel = labels.SelectorFromSet(map[string]string{
nameKey: "operatorhub",
suiteKey: "operatorframework",
})
vals = optionalValidators
err = vals.checkMatches(sel)
Expand Down

0 comments on commit 2b68396

Please sign in to comment.