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

🐛 fix generate command not respecting --namespaced=false of APIs #3970

Merged
Merged
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
2 changes: 2 additions & 0 deletions pkg/rescaffold/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ func getAPIResourceFlags(resource resource.Resource) []string {
args = append(args, "--resource")
if resource.API.Namespaced {
args = append(args, "--namespaced")
} else {
antonincms marked this conversation as resolved.
Show resolved Hide resolved
args = append(args, "--namespaced=false")
}
}

Expand Down
23 changes: 23 additions & 0 deletions test/e2e/alphagenerate/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ func ReGenerateProject(kbc *utils.TestContext) {
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("create APIs non namespaced with resource and controller")
err = kbc.CreateAPI(
"--group", "crew",
"--version", "v1",
"--kind", "Admiral",
"--namespaced=false",
"--resource",
"--controller",
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("create APIs with deploy-image plugin")
err = kbc.CreateAPI(
"--group", "crew",
Expand Down Expand Up @@ -210,6 +221,18 @@ func ReGenerateProject(kbc *utils.TestContext) {
ExpectWithOffset(1, err).NotTo(HaveOccurred())
ExpectWithOffset(1, fileContainsExpr).To(BeTrue())

By("checking if the project file was generated without namespace: true")
var nonNamespacedFields = fmt.Sprintf(`api:
crdVersion: v1
controller: true
domain: %s
group: crew
kind: Admiral`, kbc.Domain)
fileContainsExpr, err = pluginutil.HasFileContentWith(
filepath.Join(kbc.Dir, "testdir2", "PROJECT"), nonNamespacedFields)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
Expect(fileContainsExpr).To(BeTrue())

By("checking if the project file was generated with the expected deploy-image plugin fields")
var deployImagePlugin = "deploy-image.go.kubebuilder.io/v1-alpha"
fileContainsExpr, err = pluginutil.HasFileContentWith(
Expand Down
Loading