// Module included in the following assemblies: // // * operators/operator_sdk/osdk-cli-reference.adoc [id="osdk-cli-reference-generate_{context}"] = generate The `operator-sdk generate` command invokes a specific generator to generate code as needed. [id="osdk-cli-reference-generate-crds_{context}"] == crds The `generate crds` subcommand generates CRDs or updates them if they exist, under `deploy/crds/__crd.yaml`. OpenAPI V3 validation YAML is generated as a `validation` object. .`generate crds` flags [options="header",cols="1,3"] |=== |Flag |Description |`--crd-version` (string) |CRD version to generate (default `v1beta1`) |`-h`, `--help` |Help for `generate crds` |=== For example: [source,terminal] ---- $ operator-sdk generate crds ---- [source,terminal] ---- $ tree deploy/crds ---- .Example output [source,terminal] ---- ├── deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml └── deploy/crds/app.example.com_appservices_crd.yaml ---- [id="osdk-cli-reference-generate-csv_{context}"] == csv The `csv` subcommand writes a ClusterServiceVersion (CSV) manifest for use with Operator Lifecycle Manager (OLM). It also optionally writes CustomResourceDefinition (CRD) files to `deploy/olm-catalog//`. .`generate csv` flags [options="header",cols="1,3"] |=== |Flag |Description |`--csv-channel` (string) |The channel the CSV should be registered under in the package manifest. |`--csv-config` (string) |The path to the CSV configuration file. Default: `deploy/olm-catalog/csv-config.yaml`. |`--csv-version` (string) |The semantic version of the CSV manifest. Required. |`--default-channel` |Use the channel passed to `--csv-channel` as the package manifests' default channel. Only valid when `--csv-channel` is set. |`--from-version` (string) |The semantic version of CSV manifest to use as a base for a new version. |`--operator-name` |The Operator name to use while generating the CSV. |`--update-crds` |Updates CRD manifests in `deploy//` using the latest CRD manifests. |=== For example: [source,terminal] ---- $ operator-sdk generate csv --csv-version 0.1.0 --update-crds ---- .Example output [source,terminal] ---- INFO[0000] Generating CSV manifest version 0.1.0 INFO[0000] Fill in the following required fields in file deploy/olm-catalog/operator-name/0.1.0/operator-name.v0.1.0.clusterserviceversion.yaml: spec.keywords spec.maintainers spec.provider spec.labels INFO[0000] Created deploy/olm-catalog/operator-name/0.1.0/operator-name.v0.1.0.clusterserviceversion.yaml ---- [id="osdk-cli-reference-generate-k8s_{context}"] == k8s The `k8s` subcommand runs the Kubernetes link:https://github.com/kubernetes/code-generator[code-generators] for all CRD APIs under `pkg/apis/`. Currently, `k8s` only runs `deepcopy-gen` to generate the required `DeepCopy()` functions for all Custom Resource (CR) types. [NOTE] ==== This command must be run every time the API (`spec` and `status`) for a custom resource type is updated. ==== For example: [source,terminal] ---- $ tree pkg/apis/app/v1alpha1/ ---- .Example output [source,terminal] ---- pkg/apis/app/v1alpha1/ ├── appservice_types.go ├── doc.go └── register.go ---- [source,terminal] ---- $ operator-sdk generate k8s ---- .Example output [source,terminal] ---- Running code-generation for Custom Resource (CR) group versions: [app:v1alpha1] Generating deepcopy funcs ---- [source,terminal] ---- $ tree pkg/apis/app/v1alpha1/ ---- .Example output [source,terminal] ---- pkg/apis/app/v1alpha1/ ├── appservice_types.go ├── doc.go ├── register.go └── zz_generated.deepcopy.go ----