-
Notifications
You must be signed in to change notification settings - Fork 400
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
✨Add flags to customize API path and contexts #144
Conversation
If I'm way out of left field with this, I am totally open to course corrections. I'm still figuring this tool out totally |
38b5027
to
91f29b6
Compare
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.
comments inline
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.
Change seems reasonable to me, some minor comments.
6cebeec
to
db77456
Compare
@droot @DirectXMan12 I've updated this PR, could either of you please take another look at this? |
bump, any more feedback on this? |
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 for the delay, looks good except a minor change.
pkg/crd/generator/generator.go
Outdated
@@ -112,7 +109,7 @@ func (c *Generator) Do() error { | |||
return fmt.Errorf("failed switching working dir: %v", err) | |||
} | |||
|
|||
if err := b.AddDirRecursive("./pkg/apis"); err != nil { | |||
if err := b.AddDirRecursive(fmt.Sprintf("./%s", c.APIsPath)); 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.
If this is always relative, then we should update the help text for api-path
commandline param to reflect that.
I wish filepath.Join(".", c.APIsPath)
worked for this case, but looks like doesn't.
nit: probably "./" + c.APIsPath
reads better in this case.
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.
@droot updated
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.
minor nit, otherwise looks good
please add a comment somewhere explaining why apis-path
and apis-pkg
being different are useful.
pkg/crd/generator/generator.go
Outdated
@@ -112,7 +109,7 @@ func (c *Generator) Do() error { | |||
return fmt.Errorf("failed switching working dir: %v", err) | |||
} | |||
|
|||
if err := b.AddDirRecursive("./pkg/apis"); err != nil { | |||
if err := b.AddDirRecursive("./%s" + c.APIsPath); 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.
"path/filepath".Join
is probably safer here.
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.
that drops the leading ./
:(
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: damemi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
We have some use cases where API types are defined in a different package or location than the default
pkg/apis
currently hardcoded. For example, we have vendored types in an API library that correspond to CRDs in multiple different repos; this would allow us to establish a workflow such asvendor/org/library/some-api/v1/
)By specifying a known directory and context, we can still use this tool with only minor changes (the optional flags added in this PR) and this gives us more ability to customize it to our use cases.
I'm aware that we could accomplish something similar with
--output-dir
, by going in the opposite direction and running this tool from our API library while specifying the output as those specific repos. But I think controlling the CRD updates from each repo itself couples the CRD update with the corresponding, necessary dependency bump well.