api

module
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2022 License: Apache-2.0

README

Api

Contains the API definitions used by Operator Lifecycle Manager (OLM) and Marketplace Operator

pkg/validation: Operator Manifest Validation

pkg/validation exposes a convenient set of interfaces to validate Kubernetes object manifests, primarily for use in an Operator project.

The Validators are static checks (linters) that can scan the manifests and provide with low-cost valuable results to ensure the quality of the package of distributions (bundle or package formats) which will be distributed via OLM.

The validators implemented in this project aims to provide common validators (which can be useful or required for any solution which will be distributed via Operator Lifecycle Manager). (More info)

Note that Operator-SDK leverage in this project. By using it you can test your bundle against the spec criteria (Default Validators) by running:

$ operator-sdk bundle validate <bundle-path>

Also, Operator-SDK allows you check your bundles against the Optional Validators provided by using the flag option --select-optional such as the following example:

$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=<k8s-version>

For further information see the doc.

Example of usage:

Note that you can leverage in this project to call and indeed create your own validators. Following an example.

 import (
   ...
    apimanifests "github.com/operator-framework/api/pkg/manifests"
    apivalidation "github.com/operator-framework/api/pkg/validation"
    "github.com/operator-framework/api/pkg/validation/errors"
   ...
  )

 // Load the directory (which can be in packagemanifest or bundle format)
 bundle, err := apimanifests.GetBundleFromDir(path)
 if err != nil {
   ...
   return nil
 }

 // Call all default validators and the OperatorHubValidator
 validators := apivalidation.DefaultBundleValidators
 validators = validators.WithValidators(apivalidation.OperatorHubValidator)

 objs := bundle.ObjectsToValidate()

 results := validators.Validate(objs...)
 nonEmptyResults := []errors.ManifestResult{}

 for _, result := range results {
    if result.HasError() || result.HasWarn() {
        nonEmptyResults = append(nonEmptyResults, result)
    }
 }
 // return the results
 return nonEmptyResults

API CLI Usage

You can install the operator-verify tool from source using:

$ make install

To verify your ClusterServiceVersion yaml,

$ operator-verify manifests /path/to/filename.yaml

Directories

Path Synopsis
cmd
Package crds contains CustomResourceDefinition manifests for operator-framework APIs.
Package crds contains CustomResourceDefinition manifests for operator-framework APIs.
pkg
apis/scorecard/v1alpha3
Package v1alpha3 contains resources types for version v1alpha3 of the scorecard.operatorframework.com API group.
Package v1alpha3 contains resources types for version v1alpha3 of the scorecard.operatorframework.com API group.
operators
Package operators contains all resource types of the operators.coreos.com API group.
Package operators contains all resource types of the operators.coreos.com API group.
operators/v1
Package v1 contains resources types for version v1 of the operators.coreos.com API group.
Package v1 contains resources types for version v1 of the operators.coreos.com API group.
operators/v1alpha1
Package v1alpha1 contains resources types for version v1alpha1 of the operators.coreos.com API group.
Package v1alpha1 contains resources types for version v1alpha1 of the operators.coreos.com API group.
operators/v1alpha2
Package v1alpha2 contains resources types for version v1alpha2 of the operators.coreos.com API group.
Package v1alpha2 contains resources types for version v1alpha2 of the operators.coreos.com API group.
operators/v2
Package v2 contains resources types for version v2 of the operators.coreos.com API group.
Package v2 contains resources types for version v2 of the operators.coreos.com API group.
validation
- CustomResourceDefinition documentation: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
- CustomResourceDefinition documentation: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL