Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

internal/pkg/scaffold/crd.go: overwrite CRD manifests for Go operators #1278

Merged
merged 16 commits into from
May 2, 2019

Conversation

estroz
Copy link
Member

@estroz estroz commented Apr 2, 2019

Description of the change: overwrite on-disk CRD manifests for Go operators.

Motivation for the change: controller-tools CRD generator is used for Go operators. This generator supports most OpenAPIv3 validation properties, and other nice-to-have automation, through Go code annotations. Annotations for all validation properties is a WIP. Generating CRD manifests using these annotations is more reproducible and robust than preserving data in on-disk CRD manifests, so they should be overwritten every time a command that scaffolds a CRD manifest is invoked.

Closes #1212, closes #1323

@estroz estroz added the kind/bug Categorizes issue or PR as related to a bug. label Apr 2, 2019
@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 2, 2019
internal/pkg/scaffold/crd.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AlexNPavel AlexNPavel left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 3, 2019
@hasbro17
Copy link
Contributor

Also related #1323

override PROJECT file check by the CRD generator

Gopkg.toml: add controller-tools override (temporary)
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2019
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 16, 2019
@@ -41,6 +39,20 @@ type CRD struct {

// IsOperatorGo is true when the operator is written in Go.
IsOperatorGo bool

once sync.Once
fs afero.Fs // For testing, ex. afero.NewMemMapFs()
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm repeating this pattern from CSV generation for easier testing. In the future this should be refactored into Input so all scaffolds can access a test afero.Fs.

@estroz estroz changed the title internal/pkg/scaffold/crd.go: CRD gets additionalPrinterColumns internal/pkg/scaffold/crd.go: overwrite CRD manifests for Go operators Apr 22, 2019
@estroz estroz requested a review from AlexNPavel April 22, 2019 22:07
@estroz
Copy link
Member Author

estroz commented Apr 30, 2019

/cc @hasbro17 @AlexNPavel @joelanford

@hasbro17
Copy link
Contributor

hasbro17 commented May 1, 2019

Worth mentioning this in the CHANGELOG to warn users expecting to preserve manual edits to the CRD manifest.

Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

LGTM after nit.

@estroz estroz merged commit 94a53be into operator-framework:master May 2, 2019
@estroz estroz deleted the crd-printercolumns branch May 2, 2019 00:00
estroz added a commit to estroz/operator-sdk that referenced this pull request May 2, 2019
operator-framework#1278)

* internal/pkg/scaffold: overwrite CRD's with newly generated ones unless operator is non-go

* internal/pkg/scaffold/crd.go: set names if not empty, and set Repo to
override PROJECT file check by the CRD generator

* Gopkg.toml: add controller-tools override (temporary)

* revendor

* CHANGELOG.md: added kubebuilder annotation bug and change entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate openapi removes shortNames from CRD operator-sdk generate openapi ignores +kubebuilder:printcolumn
5 participants