From 420676ff60d8fa0f410539e25bf1a6c479b3c1cd Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 10:59:00 -0800 Subject: [PATCH 1/3] cmd/operator-sdk: move 'bundle' subcommand out of 'alpha' --- cmd/operator-sdk/alpha/cmd.go | 2 -- cmd/operator-sdk/{alpha => }/bundle/build.go | 0 cmd/operator-sdk/{alpha => }/bundle/cmd.go | 0 cmd/operator-sdk/cli/cli.go | 2 ++ doc/cli/operator-sdk.md | 1 + doc/cli/operator-sdk_alpha.md | 1 - ...{operator-sdk_alpha_bundle.md => operator-sdk_bundle.md} | 6 +++--- ...k_alpha_bundle_build.md => operator-sdk_bundle_build.md} | 6 +++--- 8 files changed, 9 insertions(+), 9 deletions(-) rename cmd/operator-sdk/{alpha => }/bundle/build.go (100%) rename cmd/operator-sdk/{alpha => }/bundle/cmd.go (100%) rename doc/cli/{operator-sdk_alpha_bundle.md => operator-sdk_bundle.md} (67%) rename doc/cli/{operator-sdk_alpha_bundle_build.md => operator-sdk_bundle_build.md} (92%) diff --git a/cmd/operator-sdk/alpha/cmd.go b/cmd/operator-sdk/alpha/cmd.go index 2b62a87009b..de359bb4b6d 100644 --- a/cmd/operator-sdk/alpha/cmd.go +++ b/cmd/operator-sdk/alpha/cmd.go @@ -15,7 +15,6 @@ package alpha import ( - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/bundle" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/cleanup" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/kubebuilder" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm" @@ -35,7 +34,6 @@ func NewCmd() *cobra.Command { kubebuilder.NewCmd(), run.NewCmd(), cleanup.NewCmd(), - bundle.NewCmd(), ) return cmd } diff --git a/cmd/operator-sdk/alpha/bundle/build.go b/cmd/operator-sdk/bundle/build.go similarity index 100% rename from cmd/operator-sdk/alpha/bundle/build.go rename to cmd/operator-sdk/bundle/build.go diff --git a/cmd/operator-sdk/alpha/bundle/cmd.go b/cmd/operator-sdk/bundle/cmd.go similarity index 100% rename from cmd/operator-sdk/alpha/bundle/cmd.go rename to cmd/operator-sdk/bundle/cmd.go diff --git a/cmd/operator-sdk/cli/cli.go b/cmd/operator-sdk/cli/cli.go index 523d03b7261..86781b8a80c 100644 --- a/cmd/operator-sdk/cli/cli.go +++ b/cmd/operator-sdk/cli/cli.go @@ -23,6 +23,7 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/add" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/build" + "github.com/operator-framework/operator-sdk/cmd/operator-sdk/bundle" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate" @@ -64,6 +65,7 @@ func GetCLIRoot() *cobra.Command { root.AddCommand(add.NewCmd()) root.AddCommand(alpha.NewCmd()) root.AddCommand(build.NewCmd()) + root.AddCommand(bundle.NewCmd()) root.AddCommand(completion.NewCmd()) root.AddCommand(generate.NewCmd()) root.AddCommand(migrate.NewCmd()) diff --git a/doc/cli/operator-sdk.md b/doc/cli/operator-sdk.md index ae8dbb6a43b..85f28e0ecd4 100644 --- a/doc/cli/operator-sdk.md +++ b/doc/cli/operator-sdk.md @@ -17,6 +17,7 @@ An SDK for building operators with ease * [operator-sdk add](operator-sdk_add.md) - Adds a controller or resource to the project * [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand * [operator-sdk build](operator-sdk_build.md) - Compiles code and builds artifacts +* [operator-sdk bundle](operator-sdk_bundle.md) - Work with operator bundle metadata and bundle images * [operator-sdk completion](operator-sdk_completion.md) - Generators for shell completions * [operator-sdk generate](operator-sdk_generate.md) - Invokes specific generator * [operator-sdk migrate](operator-sdk_migrate.md) - Adds source code to an operator diff --git a/doc/cli/operator-sdk_alpha.md b/doc/cli/operator-sdk_alpha.md index 868f8d7e0c8..eccadab732a 100644 --- a/doc/cli/operator-sdk_alpha.md +++ b/doc/cli/operator-sdk_alpha.md @@ -15,7 +15,6 @@ Run an alpha subcommand ### SEE ALSO * [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images * [operator-sdk alpha cleanup](operator-sdk_alpha_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk alpha olm](operator-sdk_alpha_olm.md) - Manage the Operator Lifecycle Manager installation in your cluster * [operator-sdk alpha run](operator-sdk_alpha_run.md) - Run an Operator in a variety of environments diff --git a/doc/cli/operator-sdk_alpha_bundle.md b/doc/cli/operator-sdk_bundle.md similarity index 67% rename from doc/cli/operator-sdk_alpha_bundle.md rename to doc/cli/operator-sdk_bundle.md index 95708d84fe1..5d7dd7e3cec 100644 --- a/doc/cli/operator-sdk_alpha_bundle.md +++ b/doc/cli/operator-sdk_bundle.md @@ -1,4 +1,4 @@ -## operator-sdk alpha bundle +## operator-sdk bundle Work with operator bundle metadata and bundle images @@ -18,6 +18,6 @@ https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator- ### SEE ALSO -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand -* [operator-sdk alpha bundle build](operator-sdk_alpha_bundle_build.md) - Build an operator bundle image +* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease +* [operator-sdk bundle build](operator-sdk_bundle_build.md) - Build an operator bundle image diff --git a/doc/cli/operator-sdk_alpha_bundle_build.md b/doc/cli/operator-sdk_bundle_build.md similarity index 92% rename from doc/cli/operator-sdk_alpha_bundle_build.md rename to doc/cli/operator-sdk_bundle_build.md index 52c88e1a00f..03341f482ac 100644 --- a/doc/cli/operator-sdk_alpha_bundle_build.md +++ b/doc/cli/operator-sdk_bundle_build.md @@ -1,4 +1,4 @@ -## operator-sdk alpha bundle build +## operator-sdk bundle build Build an operator bundle image @@ -19,7 +19,7 @@ https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator- NOTE: bundle images are not runnable. ``` -operator-sdk alpha bundle build [flags] +operator-sdk bundle build [flags] ``` ### Examples @@ -64,5 +64,5 @@ $ operator-sdk bundle build \ ### SEE ALSO -* [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images +* [operator-sdk bundle](operator-sdk_bundle.md) - Work with operator bundle metadata and bundle images From 8c1da470a7d859f8f72ed36cc8e9d75a244a0abc Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 11:51:01 -0800 Subject: [PATCH 2/3] CHANGELOG.md: add bundle build addition --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8f06fa624..33d762144c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,10 @@ ### Added - Added [`run`](./doc/cli/operator-sdk_alpha_run.md) and [`cleanup`](./doc/cli/operator-sdk_alpha_cleanup.md) subcommands (under the `alpha` subcommand) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402)) -- Added [`bundle build`](./doc/cli/operator-sdk_alpha_bundle_build.md) (under the `alpha` subcommand) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076)) +- Added [`bundle build`](./doc/cli/operator-sdk_bundle_build.md) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076), [#2438](https://github.com/operator-framework/operator-sdk/pull/2438)) ### Changed + - Changed error wrapping according to Go version 1.13+ [error handling](https://blog.golang.org/go1.13-errors). ([#2355](https://github.com/operator-framework/operator-sdk/pull/2355)) - Added retry logic to the cleanup function from the e2e test framework in order to allow it to be achieved in the scenarios where temporary network issues are faced. ([#2277](https://github.com/operator-framework/operator-sdk/pull/2277)) From a59bb1ff389834d19dc31872eabed592b908a69f Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 14:59:22 -0800 Subject: [PATCH 3/3] better error messaging --- CHANGELOG.md | 2 +- cmd/operator-sdk/bundle/cmd.go | 2 +- .../bundle/{build.go => create.go} | 19 ++++++++++--------- doc/cli/operator-sdk_bundle.md | 2 +- ...build.md => operator-sdk_bundle_create.md} | 16 ++++++++-------- 5 files changed, 21 insertions(+), 20 deletions(-) rename cmd/operator-sdk/bundle/{build.go => create.go} (90%) rename doc/cli/{operator-sdk_bundle_build.md => operator-sdk_bundle_create.md} (85%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d762144c9..587998a5ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Added - Added [`run`](./doc/cli/operator-sdk_alpha_run.md) and [`cleanup`](./doc/cli/operator-sdk_alpha_cleanup.md) subcommands (under the `alpha` subcommand) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402)) -- Added [`bundle build`](./doc/cli/operator-sdk_bundle_build.md) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076), [#2438](https://github.com/operator-framework/operator-sdk/pull/2438)) +- Added [`bundle create`](./doc/cli/operator-sdk_bundle_create.md) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076), [#2438](https://github.com/operator-framework/operator-sdk/pull/2438)) ### Changed diff --git a/cmd/operator-sdk/bundle/cmd.go b/cmd/operator-sdk/bundle/cmd.go index b6ace140a15..db9b25cd9be 100644 --- a/cmd/operator-sdk/bundle/cmd.go +++ b/cmd/operator-sdk/bundle/cmd.go @@ -33,7 +33,7 @@ More information on operator bundle images and metadata: https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator-bundle.md#docker`, } - cmd.AddCommand(newBundleBuildCmd()) + cmd.AddCommand(newCreateCmd()) return cmd } diff --git a/cmd/operator-sdk/bundle/build.go b/cmd/operator-sdk/bundle/create.go similarity index 90% rename from cmd/operator-sdk/bundle/build.go rename to cmd/operator-sdk/bundle/create.go index 7a7b78a566a..574bb9e5466 100644 --- a/cmd/operator-sdk/bundle/build.go +++ b/cmd/operator-sdk/bundle/create.go @@ -29,13 +29,14 @@ import ( "github.com/spf13/cobra" ) -// newBundleBuildCmd returns a command that will build operator bundle image. -func newBundleBuildCmd() *cobra.Command { - c := bundleCmd{} +// newCreateCmd returns a command that will build operator bundle image or +// generate metadata for them. +func newCreateCmd() *cobra.Command { + c := &bundleCmd{} cmd := &cobra.Command{ - Use: "build", - Short: "Build an operator bundle image", - Long: `The 'operator-sdk bundle build' command will build an operator + Use: "create", + Short: "Create an operator bundle image", + Long: `The 'operator-sdk bundle create' command will build an operator bundle image containing operator metadata and manifests, tagged with the provided image tag. @@ -51,7 +52,7 @@ NOTE: bundle images are not runnable.`, Example: `The following invocation will build a test-operator bundle image using Docker. This image will contain manifests for package channels 'stable' and 'beta': -$ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 \ +$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 \ --directory ./deploy/olm-catalog/test-operator \ --package test-operator \ --channels stable,beta \ @@ -60,12 +61,12 @@ $ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 \ Assuming your operator has the same name as your operator and the only channel is 'stable', the above command can be abbreviated to: -$ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 +$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 The following invocation will generate test-operator bundle metadata and Dockerfile without building the image: -$ operator-sdk bundle build \ +$ operator-sdk bundle create \ --generate-only \ --directory ./deploy/olm-catalog/test-operator \ --package test-operator \ diff --git a/doc/cli/operator-sdk_bundle.md b/doc/cli/operator-sdk_bundle.md index 5d7dd7e3cec..6cfad752655 100644 --- a/doc/cli/operator-sdk_bundle.md +++ b/doc/cli/operator-sdk_bundle.md @@ -19,5 +19,5 @@ https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator- ### SEE ALSO * [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk bundle build](operator-sdk_bundle_build.md) - Build an operator bundle image +* [operator-sdk bundle create](operator-sdk_bundle_create.md) - Create an operator bundle image diff --git a/doc/cli/operator-sdk_bundle_build.md b/doc/cli/operator-sdk_bundle_create.md similarity index 85% rename from doc/cli/operator-sdk_bundle_build.md rename to doc/cli/operator-sdk_bundle_create.md index 03341f482ac..a1bd6e7a557 100644 --- a/doc/cli/operator-sdk_bundle_build.md +++ b/doc/cli/operator-sdk_bundle_create.md @@ -1,10 +1,10 @@ -## operator-sdk bundle build +## operator-sdk bundle create -Build an operator bundle image +Create an operator bundle image ### Synopsis -The 'operator-sdk bundle build' command will build an operator +The 'operator-sdk bundle create' command will build an operator bundle image containing operator metadata and manifests, tagged with the provided image tag. @@ -19,7 +19,7 @@ https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator- NOTE: bundle images are not runnable. ``` -operator-sdk bundle build [flags] +operator-sdk bundle create [flags] ``` ### Examples @@ -28,7 +28,7 @@ operator-sdk bundle build [flags] The following invocation will build a test-operator bundle image using Docker. This image will contain manifests for package channels 'stable' and 'beta': -$ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 \ +$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 \ --directory ./deploy/olm-catalog/test-operator \ --package test-operator \ --channels stable,beta \ @@ -37,12 +37,12 @@ $ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 \ Assuming your operator has the same name as your operator and the only channel is 'stable', the above command can be abbreviated to: -$ operator-sdk bundle build quay.io/example/test-operator:v0.1.0 +$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 The following invocation will generate test-operator bundle metadata and Dockerfile without building the image: -$ operator-sdk bundle build \ +$ operator-sdk bundle create \ --generate-only \ --directory ./deploy/olm-catalog/test-operator \ --package test-operator \ @@ -57,7 +57,7 @@ $ operator-sdk bundle build \ -e, --default-channel string The default channel for the bundle image -d, --directory string The directory where bundle manifests are located -g, --generate-only Generate metadata and a Dockerfile on disk without building the bundle image - -h, --help help for build + -h, --help help for create -b, --image-builder string Tool to build container images. One of: [docker, podman, buildah] (default "docker") -p, --package string The name of the package that bundle image belongs to. Set if package name differs from project name (default "operator-sdk") ```