Skip to content

generate csv: support manifests/ format with --make-manifests#2776

Merged
estroz merged 10 commits intooperator-framework:masterfrom
estroz:feature/csv-supports-manifests
Apr 14, 2020
Merged

generate csv: support manifests/ format with --make-manifests#2776
estroz merged 10 commits intooperator-framework:masterfrom
estroz:feature/csv-supports-manifests

Conversation

@estroz
Copy link
Member

@estroz estroz commented Apr 3, 2020

Description of the change: generate csv --make-manifests will generate a manifests/ directory at <deploy-dir>/olm-catalog/<operator-name/manifests or, if --output-dir is set, <output-dir>/manifests. Previous behavior is the same, except setting --output-dir will direct the generator to check if a CSV bundle exists in the output directory before checking the default <deploy-dir>/olm-catalog/<operator-name> directory.

hack/tests: add generate csv subcommand tests that check behavior and not content of generated files (this is done in unit tests)

Motivation for the change: The new manifests/metadata format is supported by operator-sdk bundle create. generate csv should align in a backwards-compatible way so operator authors can choose between versioning their bundles on disk vs. in VCS. --make-manifests=true by default, so to get previous behavior you must set --make-manifests=false. The only other change to previous behavior, checking the output dir for bundles first, ensures you do not have to maintain both a default bundle location and an output directory.

Relates to #2746

/kind feature

@estroz estroz added the olm-integration Issue relates to the OLM integration label Apr 3, 2020
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 3, 2020
Copy link
Contributor

@jmccormick2001 jmccormick2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog?

@@ -16,16 +16,14 @@ package olmcatalog

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most changes to this file are cosmetic except for setting bundleGenerator.noUpdate, which prevents the generator from reading a CSV to update from so we can check a newly-generated CSV against the expected CSV in testdata.

@dmesser
Copy link
Contributor

dmesser commented Apr 3, 2020 via email

@estroz
Copy link
Member Author

estroz commented Apr 3, 2020

@dmesser totally possible and is amenable to a followup. That's effectively the same as:

$ operator-sdk generate csv --csv-version 0.1.0 --make-manifests \
	--output-dir /tmp/foo
$ operator-sdk bundle create quay.io/example/memcached-operator:v0.1.0 \
	--directory /tmp/foo/manifests
$ rm -rf /tmp/foo

If we can eventually persist all UI-centric information to disk, ex. in a config file + doc.go files, CSV generation can be completely in-memory.

@dmesser
Copy link
Contributor

dmesser commented Apr 6, 2020

@estroz For the sake of simplicity, could we not imagine bundle create being capable of doing both in one step? e.g.

operator-sdk bundle create --version 0.1.0

which creates the bundle layout, annotaitons and CSV metadata on disk (in a default directory or specified by --directory). Followed-up by a:

operator-sdk bundle build quay.io/example/memcached-operator:v0.1.0

which is equivalent to

podman build -f bundle/Dockerfile bundle/

to support pipelines without daemons.

@joelanford
Copy link
Member

For the sake of simplicity, could we not imagine bundle create being capable of doing both in one step?

We've been own that road with operator-sdk build (see #1600). Makefile is a great way to solve this. For example:

BUNDLE_IMAGE="quay.io/example/test-operator-bundle"
OPERATOR_VERSION="v0.1.0"

.PHONY: csv bundle-image bundle-push scorecard

csv: manifests # manifests target generates CRDs, roles, etc.
	operator-sdk generate csv --version=${OPERATOR_VERSION} --make-manifests

bundle-image: csv
	operator-sdk bundle create ${BUNDLE_IMAGE}:${OPERATOR_VERSION} \
		--directory ./deploy/olm-catalog/test-operator

bundle-push: bundle-image
	docker push ${BUNDLE_IMAGE}:${OPERATOR_VERSION}

scorecard: bundle-image
	operator-sdk scorecard --bundle=${BUNDLE_IMAGE}:${OPERATOR_VERSION}

Run make bundle-push and you're done :)

We would theoretically be able to inject extra targets into the Makefile generation of operator-sdk init to give users the "best practice" make targets for OLM integration, but then users could tweak to their heart's content without us having to support every conceivable tweak to the workflow.

I think this would also help us focus more on the UX of the individual commands, which would ideally be simple on their own AND be able to be composed into really powerful workflows.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 7, 2020
@estroz estroz force-pushed the feature/csv-supports-manifests branch from 2b1c1be to ab96702 Compare April 9, 2020 05:22
@estroz estroz closed this Apr 9, 2020
@estroz estroz reopened this Apr 9, 2020
@estroz estroz force-pushed the feature/csv-supports-manifests branch 2 times, most recently from ef7d578 to a792e08 Compare April 9, 2020 17:57
@estroz estroz force-pushed the feature/csv-supports-manifests branch from a792e08 to 8425255 Compare April 9, 2020 18:10
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 10, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2020
@estroz estroz force-pushed the feature/csv-supports-manifests branch from c8f2583 to d856b86 Compare April 14, 2020 06:39
@estroz estroz force-pushed the feature/csv-supports-manifests branch from 241ecbc to cbaf9d7 Compare April 14, 2020 06:58
@estroz estroz changed the title generate csv: support manifests/ format with --make-manifests generate csv: support manifests/ format with --make-manifests Apr 14, 2020
@estroz estroz merged commit 180be9b into operator-framework:master Apr 14, 2020
@estroz estroz deleted the feature/csv-supports-manifests branch April 14, 2020 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. olm-integration Issue relates to the OLM integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants