generate: add bundle subcommand for new project layouts#3065
generate: add bundle subcommand for new project layouts#3065estroz merged 2 commits intooperator-framework:masterfrom
bundle subcommand for new project layouts#3065Conversation
c94c126 to
de0633e
Compare
bundle subcommand for new project layouts
de0633e to
e801396
Compare
|
/cc @hasbro17 |
hasbro17
left a comment
There was a problem hiding this comment.
Still going through but had a question on the --manifest-root flag.
| "Only set if creating a new bundle or upgrading your operator") | ||
| fs.StringVar(&c.inputDir, "input-dir", "", "Directory to read an existing bundle format from") | ||
| fs.StringVar(&c.outputDir, "output-dir", "", "Directory to write the bundle format to") | ||
| fs.StringVar(&c.manifestRoot, "manifest-root", "", "Root directory for operator manifests, ex. Deployment and RBAC") |
There was a problem hiding this comment.
@estroz So this is effectively --deploy-dir right?
I guess this is subjective but manifests immediately made me think of the bundle manifests directory.
I wonder if a better name wouldn't be operator-manifests-dir similar to crds-dir even if it's more verbose.
Also correct me if I'm wrong but this dir is used for Custom Resource manifests collection, and not the crd dir as mentioned below:
| fs.StringVar(&c.manifestRoot, "manifest-root", "", "Root directory for operator manifests, ex. Deployment and RBAC") | |
| fs.StringVar(&c.manifestRoot, "manifest-root", "", "Root directory for operator manifests: Deployment, RBAC and CustomResources.") |
There was a problem hiding this comment.
operator-manifests-dir doesn't seem different enough to me. Perhaps a better solution is to be explicit about the difference between --input-dir and --manifest-root in flag help.
288b773 to
0da8689
Compare
hasbro17
left a comment
There was a problem hiding this comment.
LGTM
The Gomega tests are a joy to read. A far cry from our current csv unit tests. Great work on making it so readable.
Just one nit on making the internal errors constants.
Also I still think having the flags --manifests for bundle generation and manifest-root for operator manifests makes it seems like they're related when they're not.
But not going to hold up this PR over that since the flags have enough descriptions to highlight the difference.
|
|
||
| BeforeEach(func() { | ||
| tmp, err = ioutil.TempDir(".", "") | ||
| ExpectWithOffset(1, err).ToNot(HaveOccurred()) |
There was a problem hiding this comment.
Why are we using ExpectWithOffset()?
Does Expect(err).ToNot(HaveOccurred()) not work here?
There was a problem hiding this comment.
Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argument that is used to modify the call-stack offset when computing line numbers.
This is most useful in helper functions that make assertions. If you want Gomega's error message to refer to the calling line in the test (as opposed to the line in the helper function) set the first argument of `ExpectWithOffset` appropriately.
Seems like this is to bubble up error to the line number of the caller and not the helper itself.
There was a problem hiding this comment.
Exactly, and I've named all test helper functions that use gomega Expect*() functions with the Helper suffix.
0da8689 to
24ab500
Compare
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVar(&c.kustomize, "kustomize", false, "Generate kustomize bases") |
There was a problem hiding this comment.
| cmd.Flags().BoolVar(&c.kustomize, "kustomize", false, "Generate kustomize bases") | |
| cmd.Flags().BoolVar(&c.kustomize, "kustomize", false, "If set, generate ONLY the kustomize config bases") |
There was a problem hiding this comment.
If you set --kustomize --manifests, both bases and manifests will be generated. I think giving this a simple help description is ok for now.
There was a problem hiding this comment.
My suggestion is made clear that if we set the option than means that only that will be exec which in POV not so intuitive as described here: https://github.com/operator-framework/operator-sdk/pull/2860/files#r427888547
There was a problem hiding this comment.
If you only set --kustomize, only kustomize bases are generated, as you'd expect. If you set another flag with --kustomize like --manifests, then both kustomize bases and manifests will be generated. I think that's what you're trying to say right?
| } | ||
|
|
||
| cmd.Flags().BoolVar(&c.kustomize, "kustomize", false, "Generate kustomize bases") | ||
| cmd.Flags().BoolVar(&c.manifests, "manifests", false, "Generate bundle manifests") |
There was a problem hiding this comment.
| cmd.Flags().BoolVar(&c.manifests, "manifests", false, "Generate bundle manifests") | |
| cmd.Flags().BoolVar(&c.manifests, "manifests", false, "If set, generate ONLY the bundle manifests") |
|
|
||
| cmd.Flags().BoolVar(&c.kustomize, "kustomize", false, "Generate kustomize bases") | ||
| cmd.Flags().BoolVar(&c.manifests, "manifests", false, "Generate bundle manifests") | ||
| cmd.Flags().BoolVar(&c.metadata, "metadata", false, "Generate bundle metadata and Dockerfile") |
There was a problem hiding this comment.
| cmd.Flags().BoolVar(&c.metadata, "metadata", false, "Generate bundle metadata and Dockerfile") | |
| cmd.Flags().BoolVar(&c.metadata, "metadata", false, "If set, generate ONLY the bundle metadata and its Dockerfile") |
c08c8c0 to
10527e2
Compare
| if err := fs.MarkHidden("manifest-root"); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
There was a problem hiding this comment.
Can we just improve the info to clarifies by giving examples over what from where is expected usually? Eg. Directory to read an existing bundle format from. Eg
There was a problem hiding this comment.
For --manifest-root? The help lists deploy and config as example values to pass. I expect we can improve this flag in #2860.
for a "new" project layout. cmd/operator-sdk/generate: bundle command; CustomResourceDefinition update behvior lives here internal/generate/clusterserviceversion: modular ClusterServiceVersion generator
10527e2 to
ace0487
Compare
Description of the change:
operator-sdk generate bundlewith:--kustomize: createsconfig/bundle/kustomization.yaml, and creates or updatesconfig/bundle/baseswith UI metadata. The base contains no manifests. This command will read API type data to generatecustomresourcedefinitionsmetadata using GVK's inPROJECT.--manifests: reads either from stdin or on-disk files and applies them to a base to write CSV and CRD manifests toconfig/bases/manifests. This command emulateskustomize build.--metadata: calls the same generator as the currentbundle create --generate-only.Motivation for the change: See #2860.
Depends on #3064.