Skip to content

Commit

Permalink
add: new community validator to check bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Macedo committed May 23, 2021
1 parent 03e8c95 commit c1fcf52
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 10 deletions.
16 changes: 16 additions & 0 deletions changelog/fragments/community-validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
Added new bundle validator to check the bundle against the Community Operator criteria.
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "addition"
# Is this a breaking change?
breaking: false
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ replace (
github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.10.0
golang.org/x/text => golang.org/x/text v0.3.3 // Required to fix CVE-2020-14040
sigs.k8s.io/kubebuilder/v3 => sigs.k8s.io/kubebuilder/v3 v3.0.0-alpha.0.0.20210518234629-191170994550
github.com/operator-framework/api => github.com/camilamacedo86/api v0.0.0-20210523180106-3a7b2b0b1f69
)

exclude github.com/spf13/viper v1.3.2 // Required to fix CVE-2018-1098
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0Bsq
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA=
github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/camilamacedo86/api v0.0.0-20210523180106-3a7b2b0b1f69 h1:A3hfVHAWW60CyPTYwQ5N7nEDN8p9lQ/T46cmHE6M3oU=
github.com/camilamacedo86/api v0.0.0-20210523180106-3a7b2b0b1f69/go.mod h1:L7IvLd/ckxJEJg/t4oTTlnHKAJIP/p51AvEslW3wYdY=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down
22 changes: 19 additions & 3 deletions internal/cmd/operator-sdk/bundle/validate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,33 @@ To build and validate a *pullable* bundle image:
To list and run optional validators, which are specified by a label selector:
$ operator-sdk bundle validate --list-optional
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation
suite=operatorframework
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation.
suite=operatorframework,communityoperatorframework
community name=community Community Operator bundle validation.
suite=communityoperatorframework
To validate a bundle against the entire suite of validators for Operator Framework, in addition to required bundle validators:
$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
**NOTE:** The OperatorHub.io validator in the operatorframework optional suite allows you to validate that your manifests can work with a Kubernetes cluster of a particular version using the k8s-version optional key value:
$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=1.22
To validate a bundle against the validator for operatorhub.io specifically, in addition to required bundle validators:
$ operator-sdk bundle validate ./bundle --select-optional name=operatorhub
**NOTE:** This validator allows check the bundle against an specific Kubernetes cluster version using the k8s-version optional key value:
$ operator-sdk bundle validate ./bundle --select-optional name=operatorhub --optional-values=k8s-version=1.22
To validate a bundle against the validator for Community Operators specifically, in addition to required bundle validators. This validator allows check the bundle image. In this way, inform the path-index optional key value:
$ operator-sdk bundle validate ./bundle --select-optional name=community --optional-values=index-path=bundle.Dockerfile
**NOTE:** Community Operators are the operators which will be distributed on the OKD/OCP catalogs. More info: https://github.com/operator-framework/community-operators/
`
)

Expand Down
11 changes: 10 additions & 1 deletion internal/cmd/operator-sdk/bundle/validate/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ var optionalValidators = validators{
nameKey: "operatorhub",
suiteKey: "operatorframework",
},
desc: "OperatorHub.io metadata validation",
desc: "OperatorHub.io metadata validation. ",
},
{
Validator: apivalidation.CommunityOperatorValidator,
name: "community",
labels: map[string]string{
nameKey: "community",
},
desc: "Community Operator bundle validation.",
},
}

Expand Down Expand Up @@ -117,6 +125,7 @@ func (vals validators) run(bundle *apimanifests.Bundle, sel labels.Selector, opt
}

// Pass the --optional-values. e.g. --optional-values="k8s-version=1.22"
// or --optional-values="image-path=bundle.Dockerfile"
objs = append(objs, optionalValues)

for _, v := range vals {
Expand Down
22 changes: 19 additions & 3 deletions website/content/en/docs/cli/operator-sdk_bundle_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,33 @@ To build and validate a *pullable* bundle image:
To list and run optional validators, which are specified by a label selector:
$ operator-sdk bundle validate --list-optional
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation
suite=operatorframework
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation.
suite=operatorframework,communityoperatorframework
community name=community Community Operator bundle validation.
suite=communityoperatorframework
To validate a bundle against the entire suite of validators for Operator Framework, in addition to required bundle validators:
$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
**NOTE:** The OperatorHub.io validator in the operatorframework optional suite allows you to validate that your manifests can work with a Kubernetes cluster of a particular version using the k8s-version optional key value:
$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=1.22
To validate a bundle against the validator for operatorhub.io specifically, in addition to required bundle validators:
$ operator-sdk bundle validate ./bundle --select-optional name=operatorhub
**NOTE:** This validator allows check the bundle against an specific Kubernetes cluster version using the k8s-version optional key value:
$ operator-sdk bundle validate ./bundle --select-optional name=operatorhub --optional-values=k8s-version=1.22
To validate a bundle against the validator for Community Operators specifically, in addition to required bundle validators. This validator allows check the bundle image. In this way, inform the path-index optional key value:
$ operator-sdk bundle validate ./bundle --select-optional name=community --optional-values=index-path=bundle.Dockerfile
**NOTE:** Community Operators are the operators which will be distributed on the OKD/OCP catalogs. More info: https://github.com/operator-framework/community-operators/
```

Expand Down
14 changes: 11 additions & 3 deletions website/content/en/docs/olm-integration/generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,11 @@ You can list all available optional validators by setting the `--list-optional`

```console
$ operator-sdk bundle validate --list-optional
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation
suite=operatorframework
NAME LABELS DESCRIPTION
operatorhub name=operatorhub OperatorHub.io metadata validation.
suite=operatorframework,communityoperatorframework
community name=community Community Operator bundle validation.
suite=communityoperatorframework
...
```

Expand Down Expand Up @@ -254,6 +256,12 @@ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
Documentation on optional validators:
- [`operatorhub`][operatorhub_validator]

**Note**: The `Community` validator allows you to validate your `bundle.Dockerfile` configuration against its specific criteria using the `image-path` optional key value:

```sh
operator-sdk bundle validate ./bundle --select-optional name=community --optional-values=image-path=bundle.Dockerfile
```

### Package manifests format

A [package manifests][package-manifests] format consists of on-disk manifests (CSV, CRDs and other supported kinds)
Expand Down

0 comments on commit c1fcf52

Please sign in to comment.