Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: new community validator to check bundles #4939

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 in the alpha stage. For futher information run `operator-sdk bundle validate --list-optional` and `operator-sdk bundle validate --help`.

# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "addition"

# Is this a breaking change?
breaking: false
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2
github.com/onsi/ginkgo v1.15.2
github.com/onsi/gomega v1.11.0
github.com/operator-framework/api v0.8.1
github.com/operator-framework/api v0.8.2-0.20210526151024-41d37db9141f
github.com/operator-framework/java-operator-plugins v0.0.0-20210525141944-8303c38a876d
github.com/operator-framework/operator-lib v0.4.1
github.com/operator-framework/operator-registry v1.15.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,8 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/operator-framework/api v0.3.22/go.mod h1:GVNiB6AQucwdZz3ZFXNv9HtcLOzcFnr6O/QldzKG93g=
github.com/operator-framework/api v0.5.2/go.mod h1:L7IvLd/ckxJEJg/t4oTTlnHKAJIP/p51AvEslW3wYdY=
github.com/operator-framework/api v0.8.1 h1:eFWAV70bvnQfNFM1dmBOY4y5u/WGZHV/SVDDl5WNsMk=
github.com/operator-framework/api v0.8.1/go.mod h1:L7IvLd/ckxJEJg/t4oTTlnHKAJIP/p51AvEslW3wYdY=
github.com/operator-framework/api v0.8.2-0.20210526151024-41d37db9141f h1:VX19pxX9NNJNoh0kfS0PSzK4lOInXh4+4VNlbaED/gg=
github.com/operator-framework/api v0.8.2-0.20210526151024-41d37db9141f/go.mod h1:L7IvLd/ckxJEJg/t4oTTlnHKAJIP/p51AvEslW3wYdY=
github.com/operator-framework/java-operator-plugins v0.0.0-20210525141944-8303c38a876d h1:HE4CQY27vaQWQnk7oD2mku417tKyOz6UQHOUNVCuFHU=
github.com/operator-framework/java-operator-plugins v0.0.0-20210525141944-8303c38a876d/go.mod h1:QFcG224Nx8VMwBEqxpZbT17LkISNzlOjY1/r4OQBYic=
github.com/operator-framework/operator-lib v0.4.1 h1:Eh4JHs+LAWeC85ZMHXJ9RXg7G5grYx8J29TkOw8003s=
Expand Down
21 changes: 18 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,32 @@ 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
community name=community (stage: alpha) Community Operator bundle validation.

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

(stage: alpha) 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with this index-path keyword? It's pointing to a bundle dockerfile...

@camilamacedo86


**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: "(stage: alpha) 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
21 changes: 18 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,32 @@ 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
community name=community (stage: alpha) Community Operator bundle validation.

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

(stage: alpha) 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
13 changes: 10 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,10 @@ 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
community name=community (stage: alpha) Community Operator bundle validation
...
```

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

**Note**: (stage: alpha) 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