1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/osdk-cli-reference-add.adoc

144 lines
3.6 KiB
Plaintext
Raw Normal View History

2019-05-13 08:55:00 +10:00
[id="osdk-cli-reference-add_{context}"]
2018-11-20 09:27:37 -05:00
= add
The `operator-sdk add` command adds a controller or resource to the project. The
command must be run from the Operator project root directory.
.`add` subcommands
[options="header",cols="1,3"]
|===
|Subcommand |Description
|`api`
2019-02-14 11:31:01 -05:00
|Adds a new API definition for a new Custom Resource (CR) under `pkg/apis` and
generates the Customer Resource Definition (CRD) and Custom Resource (CR) files
2018-11-20 09:27:37 -05:00
under `deploy/crds/`. If the API already exists at `pkg/apis/<group>/<version>`,
then the command does not overwrite and returns an error.
|`controller`
|Adds a new controller under `pkg/controller/<kind>/`. The controller expects to
use the CR type that should already be defined under
`pkg/apis/<group>/<version>` via the `operator-sdk add api --kind=<kind>
--api-version=<group/version>` command. If the controller package for that
`Kind` already exists at `pkg/controller/<kind>`, then the command does not
overwrite and returns an error.
|`crd`
a|Adds a CRD and the CR files. The `<project-name>/deploy` path must already
exist. The `--api-version` and `--kind` flags are required to generate the new
Operator application.
* Generated CRD filename: `<project-name>/deploy/crds/<group>_<version>_<kind>_crd.yaml`
* Generated CR filename: `<project-name>/deploy/crds/<group>_<version>_<kind>_cr.yaml`
|===
2019-06-27 10:01:29 -04:00
.`add api` flags
2018-11-20 09:27:37 -05:00
[options="header",cols="1,3"]
|===
|Flag |Description
|`--api-version` (string)
|CRD `APIVersion` in the format `$GROUP_NAME/$VERSION` (e.g.,
`app.example.com/v1alpha1`).
|`--crd-version`
|CRD version to generate, like `v1`. Default setting is `v1beta1`.
|`--kind` (string)
|CRD `Kind`. For example, `AppService`.
|===
.`add crd` flags
[options="header",cols="1,3"]
|===
|Flag |Description
|`--api-version` (string)
|CRD `APIVersion` in the format `$GROUP_NAME/$VERSION`. For example, `app.example.com/v1alpha1`.
|`--crd-version`
|CRD version to generate, like `v1`. Default setting is `v1beta1`.
2018-11-20 09:27:37 -05:00
|`--kind` (string)
|CRD `Kind`. For example, `AppService`.
2018-11-20 09:27:37 -05:00
|===
For example:
[source,terminal]
2018-11-20 09:27:37 -05:00
----
$ operator-sdk add api --api-version app.example.com/v1alpha1 --kind AppService
----
.Example output
[source,terminal]
----
2018-11-20 09:27:37 -05:00
Create pkg/apis/app/v1alpha1/appservice_types.go
Create pkg/apis/addtoscheme_app_v1alpha1.go
Create pkg/apis/app/v1alpha1/register.go
Create pkg/apis/app/v1alpha1/doc.go
Create deploy/crds/app_v1alpha1_appservice_cr.yaml
Create deploy/crds/app_v1alpha1_appservice_crd.yaml
2019-02-14 11:31:01 -05:00
Running code-generation for Custom Resource (CR) group versions: [app:v1alpha1]
2018-11-20 09:27:37 -05:00
Generating deepcopy funcs
----
2018-11-20 09:27:37 -05:00
[source,terminal]
----
2018-11-20 09:27:37 -05:00
$ tree pkg/apis
----
.Example output
[source,terminal]
----
2018-11-20 09:27:37 -05:00
pkg/apis/
├── addtoscheme_app_appservice.go
├── apis.go
└── app
└── v1alpha1
├── doc.go
├── register.go
└── types.go
2018-11-20 09:27:37 -05:00
----
[source,terminal]
2018-11-20 09:27:37 -05:00
----
$ operator-sdk add controller --api-version app.example.com/v1alpha1 --kind AppService
----
.Example output
[source,terminal]
----
2018-11-20 09:27:37 -05:00
Create pkg/controller/appservice/appservice_controller.go
Create pkg/controller/add_appservice.go
----
2018-11-20 09:27:37 -05:00
[source,terminal]
----
2018-11-20 09:27:37 -05:00
$ tree pkg/controller
----
.Example output
[source,terminal]
----
2018-11-20 09:27:37 -05:00
pkg/controller/
├── add_appservice.go
├── appservice
│   └── appservice_controller.go
└── controller.go
----
[source,terminal]
2018-11-20 09:27:37 -05:00
----
$ operator-sdk add crd --api-version app.example.com/v1alpha1 --kind AppService
----
.Example output
[source,terminal]
----
2019-02-14 11:31:01 -05:00
Generating Custom Resource Definition (CRD) files
2018-11-20 09:27:37 -05:00
Create deploy/crds/app_v1alpha1_appservice_crd.yaml
Create deploy/crds/app_v1alpha1_appservice_cr.yaml
----