Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] bundle: fix bundle create, bump operator-registry v1.6.0 #2715

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
- The methods `ctx.GetOperatorNamespace()` and `ctx.GetWatchNamespace()` was added `pkg/test` in order to replace `ctx.GetNamespace()` which is deprecated. ([#2617](https://github.com/operator-framework/operator-sdk/pull/2617))
- The `--crd-version` flag was added to the `new`, `add api`, `add crd`, and `generate crds` commands so that users can opt-in to `v1` CRDs. ([#2684](https://github.com/operator-framework/operator-sdk/pull/2684))
- The printout for the compatible Kubernetes Version [#2446](https://github.com/operator-framework/operator-sdk/pull/2446)
- Add the new flag `--output-dir` to the command [`operator-sdk bundle create`](./doc/cli/operator-sdk_bundle_create.md). ([#2715](https://github.com/operator-framework/operator-sdk/pull/2715))

### Changed

- The scorecard when creating a Custom Resource, will produce a message to the user if that CR already exists. ([#2683](https://github.com/operator-framework/operator-sdk/pull/2683))
- Upgrade the `operator-registry` dependency version from `v1.5.7`to `v1.6.0` to update `bundle create` behaviour. ([#2662](https://github.com/operator-framework/operator-sdk/pull/2662))
- **Breaking Change:** [`operator-sdk bundle create --generate-only`](./doc/cli/operator-sdk_bundle_create.md) now writes a Dockerfile to `<project-root>/bundle.Dockerfile` and copies bundle manifests directly from the argument to `--directory`. ([#2715](https://github.com/operator-framework/operator-sdk/pull/2715))

### Deprecated

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ test-ci: test-markdown test-sanity test-unit install test-subcommand test-e2e ##
.PHONY: test-subcommand test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install

test-subcommand: test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install
./hack/tests/subcommand-bundle.sh

test-subcommand-local:
./hack/tests/subcommand.sh
Expand Down
51 changes: 11 additions & 40 deletions cmd/operator-sdk/bundle/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
package bundle

import (
"os"
"path/filepath"

"github.com/operator-framework/operator-registry/pkg/lib/bundle"
"github.com/spf13/cobra"
)

//nolint:structcheck
type bundleCmd struct {
directory string
packageName string
imageTag string
imageBuilder string
defaultChannel string
channels []string
generateOnly bool
}

func NewCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "bundle",
Expand All @@ -39,39 +46,3 @@ https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator-
)
return cmd
}

type bundleCmd struct {
directory string
packageName string
imageTag string
imageBuilder string
defaultChannel string
channels []string
generateOnly bool
}

// cleanupFuncs returns a set of general funcs to clean up after a bundle
// subcommand.
func (c bundleCmd) cleanupFuncs() (fs []func()) {
metaDir := filepath.Join(c.directory, bundle.MetadataDir)
dockerFile := filepath.Join(c.directory, bundle.DockerFile)
metaExists := isExist(metaDir)
dockerFileExists := isExist(dockerFile)
fs = append(fs,
func() {
if !metaExists {
_ = os.RemoveAll(metaDir)
}
},
func() {
if !dockerFileExists {
_ = os.RemoveAll(dockerFile)
}
})
return fs
}

func isExist(path string) bool {
_, err := os.Stat(path)
return os.IsExist(err)
}
Loading