-
Notifications
You must be signed in to change notification settings - Fork 84
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
feat: avoid importing kubectl deps when using ApplysetApplier #331
Conversation
/assign @justinsb |
2eb6c43
to
1966900
Compare
e27854e
to
55e9816
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.
Looks good, but I think if we can avoid go:build without_kubectl_deps
except in one file that builds the default object, I think this PR gets simpler.
@@ -1,3 +1,6 @@ | |||
//go:build without_kubectl_deps | |||
// +build without_kubectl_deps |
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.
Dumb question: why is this one needed? I would have expected only to see go:build !without_kubectl_deps
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.
oh, because this test needs to import and use the ApplysetApplier
(see code). Without this building tag, go test
won't successfully import the applier package.
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.
The Applyset applier should always be present, I think.
@@ -1,3 +1,6 @@ | |||
//go:build !without_kubectl_deps |
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.
Maybe we do this by applier, because there are two "dependencies" on kubectl - there is execing kubectl, and there is calling into the kubectl code.
So maybe we have two tags: without_kubectl_applier
(or without_exec_applier
) and without_direct_applier
?
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.
Sure thing! Yeah, I was thinking about to define the tags for 3 kinds rather than 2, but on my side I don't have a dedicated use case that need to distinguish exec and direct kubectl.
3f15434
to
3cb08fe
Compare
qq: but I think this will cause the
|
@@ -1,3 +1,6 @@ | |||
//go:build without_direct_applier && !without_exec_applier |
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.
So I would only expect to see these negated (except for globals.go). Otherwise (in this case) users must specify without_direct_applier to get the exec applier.
So I would expect to see this to be //go:build !without_exec_applier
@@ -0,0 +1,23 @@ | |||
//go:build without_exec_applier && without_direct_applier |
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.
This makes sense, this is the one file where I would expect to see these not negated, because we want complete coverage of all the build tags in the various global_....go
files.
1384f65
to
15664d9
Compare
applier := applier.NewApplySetApplier( | ||
metav1.PatchOptions{FieldManager: "kdp-test"}, metav1.DeleteOptions{}, applier.ApplysetOptions{}) | ||
|
||
applier := applier.DefaultApplier |
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.
tolerant build tag. Any applier should pass this test.
//go:build !without_exec_applier || !without_direct_applier | ||
// +build !without_exec_applier !without_direct_applier |
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.
this file contains kubectl deps.
//go:build !without_exec_applier || !without_direct_applier | ||
// +build !without_exec_applier !without_direct_applier |
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.
This file contains kubectl deps. Tag to allow skipping importing.
//go:build !without_exec_applier | ||
// +build !without_exec_applier |
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.
This file contains exec.go methods
Thanks @yuwenma - lgtm! /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb, yuwenma 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 |
What this PR does / why we need it:
This PR allows k-d-p operators to not import the kubectl dependent libraries if using
ApplysetApplier
.CI change and test coverage:
Some Test files are tagged with
without_kubectl_deps
specifically. We added a new CI test run in thedev/test
to make sure those tests are run with thewithout_kubectl_deps
tagusage:
Take Guestbook as an example,
go run -tags without_kubectl_deps main.go