{"id":18510707,"url":"https://github.com/operator-framework/api","last_synced_at":"2025-05-15T10:03:26.240Z","repository":{"id":36965724,"uuid":"200927350","full_name":"operator-framework/api","owner":"operator-framework","description":"Contains the API definitions used by OLM and Marketplace","archived":false,"fork":false,"pushed_at":"2025-05-13T14:35:53.000Z","size":21147,"stargazers_count":32,"open_issues_count":26,"forks_count":78,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-13T15:51:15.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/operator-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-06T21:32:57.000Z","updated_at":"2025-05-13T14:35:58.000Z","dependencies_parsed_at":"2023-02-17T07:10:26.630Z","dependency_job_id":"210a1ffe-a49f-4ebf-9832-e360e5271dbc","html_url":"https://github.com/operator-framework/api","commit_stats":{"total_commits":219,"total_committers":50,"mean_commits":4.38,"dds":0.8995433789954338,"last_synced_commit":"047ab0bc86ca87529fa395c43c1f33eb7345d45f"},"previous_names":["operator-framework/operator-api"],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operator-framework%2Fapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operator-framework%2Fapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operator-framework%2Fapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operator-framework%2Fapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/operator-framework","download_url":"https://codeload.github.com/operator-framework/api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T15:24:37.731Z","updated_at":"2025-05-15T10:03:21.140Z","avatar_url":"https://github.com/operator-framework.png","language":"Go","readme":"Api\n--\n\nContains the API definitions used by [Operator Lifecycle Manager][olm] (OLM) and [Marketplace Operator][marketplace]\n\n## Certificate of Origin\nBy contributing to this project you agree to the Developer Certificat of Origin (DCO).  This document was created by the Linux Kernel community and is a simple statement that you, as a contributor, have the legal right to make the contribution.  See the [DCO][DCO] file for details.\n\n## `pkg/validation`: Operator Manifest Validation\n\n`pkg/validation` exposes a convenient set of interfaces to validate Kubernetes object manifests, primarily for use in an Operator project.\n\nThe Validators are static checks (linters) that can scan the manifests and provide\nwith low-cost valuable results to ensure the quality of the package of distributions\n(bundle or package formats) which will be distributed via OLM.\n\nThe validators implemented in this project aims to provide common validators\n(which can be useful or required for any solution which will be distributed via [Operator Lifecycle Manager][olm]).\n([More info](https://pkg.go.dev/github.com/operator-framework/api@master/pkg/validation))\n\nNote that [Operator-SDK][sdk] leverage in this project. By using it you can\ntest your bundle against the spec criteria (Default Validators) by running:\n\n```sh\n$ operator-sdk bundle validate \u003cbundle-path\u003e\n```\n\nAlso, [Operator-SDK][sdk] allows you check your bundles against the Optional Validators\nprovided by using the flag option `--select-optional` such as the following example:\n\n```sh\n$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=\u003ck8s-version\u003e\n```\n\nFor further information see the [doc][sdk-command-doc].\n\n### Example of usage:\n\nNote that you can leverage in this project to call and indeed create your own validators.\nFollowing an example.\n\n```go\n import (\n   ...\n    apimanifests \"github.com/operator-framework/api/pkg/manifests\"\n    apivalidation \"github.com/operator-framework/api/pkg/validation\"\n    \"github.com/operator-framework/api/pkg/validation/errors\"\n   ...\n  )\n\n // Load the directory (which can be in packagemanifest or bundle format)\n bundle, err := apimanifests.GetBundleFromDir(path)\n if err != nil {\n   ...\n   return nil\n }\n\n // Call all default validators and the OperatorHubValidator\n validators := apivalidation.DefaultBundleValidators\n validators = validators.WithValidators(apivalidation.OperatorHubValidator)\n\n objs := bundle.ObjectsToValidate()\n\n results := validators.Validate(objs...)\n nonEmptyResults := []errors.ManifestResult{}\n\n for _, result := range results {\n    if result.HasError() || result.HasWarn() {\n        nonEmptyResults = append(nonEmptyResults, result)\n    }\n }\n // return the results\n return nonEmptyResults\n```\n\n#### Passing optional key/values to the validators\n\nValidators may accept pass optional key/values which will be used in the checks made.\nThese values are global and if the key/value pair provided is not used for 1 or more\nvalidators called then, it is ignored.\n\nThe following example calls `AlphaDeprecatedAPIsValidator`, which allows us to inform\nthe K8s version intended to publish the OLM Bundle:\n\n```go\n\tvalidators := apivalidation.DefaultBundleValidators\n\tvalidators = validators.WithValidators(apivalidation.OperatorHubValidator)\n\tvalidators = validators.WithValidators(apivalidation.ObjectValidator)\n\tvalidators = validators.WithValidators(apivalidation.AlphaDeprecatedAPIsValidator)\n\tvalidators = validators.WithValidators(apivalidation.GoodPracticesValidator)\n\n\tobjs := auditBundle.Bundle.ObjectsToValidate()\n\n\t// Pass the --optional-values. e.g. --optional-values=\"k8s-version=1.22\"\n\t// or --optional-values=\"image-path=bundle.Dockerfile\"\n\tvar optionalValues = map[string]string{\n\t\t\"k8s-version\":\"1.22\",\n\t}\n\tobjs = append(objs, optionalValues)\n\n\tresults := validators.Validate(objs...)\n\tnonEmptyResults := []errors.ManifestResult{}\n\n\tfor _, result := range results {\n\t\tif result.HasError() || result.HasWarn() {\n\t\t\tnonEmptyResults = append(nonEmptyResults, result)\n\t\t}\n\t}\n```\n\n**How the optional key/values are informed via the CLI?**\n\nBy using [Operator-SDK][sdk] you can pass a list of key/values via the flag `--optional-values`, for example,\nto validate that your manifests can work with a Kubernetes cluster of a particular version using the `k8s-version`:\n\n```sh\n$ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=1.22\n```\n\n## API CLI Usage\n\nYou can install the `operator-verify` tool from source using:\n\n`$ make install`\n\nTo verify your ClusterServiceVersion yaml,\n\n`$ operator-verify manifests /path/to/filename.yaml`\n\n[sdk]: https://github.com/operator-framework/operator-sdk\n[olm]: https://github.com/operator-framework/operator-lifecycle-manager\n[marketplace]: https://github.com/operator-framework/operator-marketplace\n[bundle]: https://github.com/operator-framework/operator-registry/blob/v1.19.5/docs/design/operator-bundle.md\n[sdk-command-doc]: https://master.sdk.operatorframework.io/docs/cli/operator-sdk_bundle_validate/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperator-framework%2Fapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foperator-framework%2Fapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperator-framework%2Fapi/lists"}