pkg/generator: fold apis/**.go generators into renderPkg()#40
pkg/generator: fold apis/**.go generators into renderPkg()#40fanminshi merged 2 commits intooperator-framework:masterfrom fanminshi:hook_gen_apis
Conversation
|
Manual Test: |
| return ioutil.WriteFile(filepath.Join(apiDir, types), buf.Bytes(), 0644) | ||
| } | ||
|
|
||
| func renderSubDirFiles(stubDir string) error { |
There was a problem hiding this comment.
SubDir is confusing. Can you rename it better?
There was a problem hiding this comment.
sorry my mistake. it should be stubDir
| 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 { |
| 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.
defaultFileMode -> defaultFileModeForFolder
There was a problem hiding this comment.
I think defaultDirFileMode is more concise.
| return nil | ||
|
|
||
| buf = &bytes.Buffer{} | ||
| if err := renderApisRegister(buf, kind, groupName, version); err != nil { |
There was a problem hiding this comment.
renderAPIDirRegisterFile
Or renderAPIRegisterFile. But change renderAPIDirFiles -> renderAPIFiles
There was a problem hiding this comment.
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.
I will have another pr to refactor other render* functions to follow above convention.
|
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.
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.
@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