-
Notifications
You must be signed in to change notification settings - Fork 1.8k
pkg/generator: fold apis/**.go generators into renderPkg() #40
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
Conversation
Manual Test:
|
pkg/generator/generator.go
Outdated
return ioutil.WriteFile(filepath.Join(apiDir, types), buf.Bytes(), 0644) | ||
} | ||
|
||
func renderSubDirFiles(stubDir string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubDir is confusing. Can you rename it better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry my mistake. it should be stubDir
pkg/generator/generator.go
Outdated
return err | ||
} | ||
if err := ioutil.WriteFile(filepath.Join(sDir, handler), buf.Bytes(), 0644); err != nil { | ||
if err := ioutil.WriteFile(filepath.Join(apiDir, doc), buf.Bytes(), 0644); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0644
define const
pkg/generator/generator.go
Outdated
if err := os.MkdirAll(filepath.Join(g.projectName, apisDir, apiDirName(g.apiVersion), version(g.apiVersion)), defaultFileMode); err != nil { | ||
v := version(g.apiVersion) | ||
apiDir := filepath.Join(g.projectName, apisDir, apiDirName(g.apiVersion), v) | ||
if err := os.MkdirAll(apiDir, defaultFileMode); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultFileMode -> defaultFileModeForFolder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defaultDirFileMode
is more concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
pkg/generator/generator.go
Outdated
return nil | ||
|
||
buf = &bytes.Buffer{} | ||
if err := renderApisRegister(buf, kind, groupName, version); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderAPIDirRegisterFile
Or renderAPIRegisterFile
. But change renderAPIDirFiles
-> renderAPIFiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk, I am going to follow this convention:
if rendering a dir such as renderPkg
, no need to add Dir
suffix.
If rendering a file such as renderApisRegister
, then we want to be more specific as in renderAPIRegisterFile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have another pr to refactor other render*
functions to follow above convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
Latest test output:
|
all fixed! PTAL cc/ @hongchaodeng |
LGTM |
) | ||
|
||
// Doc contains all the customized data needed to generate apis/../doc.go for a new operator | ||
// Doc contains all the customized data needed to generate apis/<version>/doc.go for a new operator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious but is the comment supposed to be apis/<apiDirName>/<version>/doc.go
since the example generated file is at pkg/apis/play/v1alpha1/doc.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hasbro17 good catch! will fix this in a new pr.
Additions: - chore: bump go 1.17, k8s 1.23, and kubebuilder 3.3 (#69) - chore(deps): update to Quarkus SDK extension 3.0.2 and Quarkus 2.6.3 (#70) - chore(deps): update to use Quarkus JOSDK extension 3.0.1 (#67) - Remove useless file (#65) - chore: bump k8s 1.22.2 and kubebuilder 3.2 (#64) - exposed exnpoints for micrometer metrics (#45) - modified the Quarkus operator SDK version and tutorial too (#40) - chore: bump fabric8 5.8.0 & quarkus 2.4.0 (#42) - modified the doc file and removed file after generation (#41) - release: fix release script to understand release branches (#38) Bug Fixes: - Fix for wrongly generated file name (#73) Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
allows command new to generate all necessary files under pkg/apis/**.
and refactor the code in renderPkg() to make it more readable.
change naming apis -> api