-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
⚠️ controller-tools v0.2.0 scaffolding update #682
⚠️ controller-tools v0.2.0 scaffolding update #682
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12 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 |
see also kubernetes-sigs/controller-tools#190 |
233c626
to
b681f06
Compare
hey, look 🎉 modules 🎉 (required some temporary branches) |
b094e61
to
227eded
Compare
Skim through it, looking good overall. Have a few questions related to go-modules. Will take a detailed look soon.
We haven't made that call yet, so lets discuss. |
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.
1da248f
to
000587d
Compare
For posterity: we discussed a bit in person, and came to the consensus that just go-getting it with modules is a fine option, and easier to manage than wrangling it as an explicit dependency. |
000587d
to
bc7bada
Compare
@@ -17,7 +17,7 @@ limitations under the License. | |||
// Package v2alpha1 contains API Schema definitions for the creatures v2alpha1 API group | |||
// +k8s:openapi-gen=true | |||
// +k8s:deepcopy-gen=package,register | |||
// +k8s:conversion-gen=sigs.k8s.io/kubebuilder/test/project/pkg/apis/creatures | |||
// +k8s:conversion-gen=project/pkg/apis/creatures | |||
// +k8s:defaulter-gen=TypeMeta |
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.
These markers actually can be removed.
Same comment for all the doc comments below.
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.
these are all v1 scaffolding, which shouldn't change under this PR.
@@ -2,7 +2,7 @@ | |||
# since it depends on service name and namespace that are out of this kustomize package. | |||
# It should be run by config/default | |||
resources: | |||
- bases/crew_firstmate.yaml | |||
- bases/crew.testproject.org_firstmates.yaml |
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.
It looks strange with mixture of .
and _
.
If I understand what's happening here correctly,
before:
group=crew
domainName=testproject.org
after:
group=crew.testproject.org
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.
it's how controller-tools generates its. I think it's fine -- the _
separates group from resource nicely. We could switch to <resource>.<group>
in CT, but I'm not sure it's worth it.
@@ -36,7 +36,7 @@ type EnableWebhookPatch struct { | |||
// GetInput implements input.File | |||
func (p *EnableWebhookPatch) GetInput() (input.Input, error) { | |||
if p.Path == "" { | |||
p.Path = filepath.Join("config", "crds", "patches", | |||
p.Path = filepath.Join("config", "crd", "patches", |
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.
Is there a convention to use singular or plural?
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.
it was by default just the name of the generator in CT. Since we're overriding it anyway, it can be whatever
kind: Service | ||
version: v1 | ||
name: webhook-service | ||
# vars: |
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.
Why comment these?
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 we don't scaffold the webhook service, kustomize barfs on these variables.
bc7bada
to
cf87637
Compare
This switches dependencies over to Go modules, dropping dep. This does so *only* for kubebuilder itself, not generated code.
This removes the vendor directory, since it's not needed by modules.
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.
reviewing commit by commit, first commit switch kb deps over to modules
looks good.
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.
reviewed Move test project to testdata
commit, looks good. minor nits about adding some comments.
@@ -139,7 +140,7 @@ cd ${go_workspace}/src/sigs.k8s.io/kubebuilder | |||
go test ./cmd/... ./pkg/... | |||
|
|||
# test project v1 | |||
test_project project 1 | |||
GO111MODULE=auto test_project gopath/src/project 1 |
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.
Comment explaining use of auto
for GO111MODULE
will help why is that being done for version 1 project.
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.
Reviewed Actually move test projects to testdata
commit, have some minor comments.
.gitattributes
Outdated
@@ -1 +1,2 @@ | |||
test/*.tgz filter=lfs diff=lfs merge=lfs -text |
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.
may be we can take out the first line ?
@@ -20,14 +20,15 @@ import ( | |||
"flag" | |||
"os" | |||
|
|||
"project/pkg/apis" | |||
"project/pkg/controller" | |||
"project/pkg/webhook" |
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.
These imports look wrong.
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.
why?
@@ -23,13 +23,14 @@ import ( | |||
"sync" | |||
"testing" | |||
|
|||
"project/pkg/apis" |
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.
is this import correct ? (or may be, because we set the gopath when we run test).
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.
yes, because we're at $GOPATH/src/project
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.
Reviewed Switch v2 Scaffolding to Use Go Modules
commit, have a few minor comments.
@@ -5,7 +5,7 @@ os: | |||
- osx | |||
|
|||
go: | |||
- "1.11" | |||
- "1.12" |
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.
we should ensure the version check we have is also bumped up to 1.12.
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.
nah, it's just for building KB, I believe. Everything else works fine with Go 1.11 (in fact, building KB also would work fine, except that Travis's Go 1.11 is slightly old and has a bug).
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.
reviewed Scaffold v1 with controller-runtime v0.1.8
, have one minor comment.
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.
Reviewed Fix imports.Process being confused on v1
, looks good.
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.
reviewed Switch v2 scaffolding to controller-tools 0.2.0
. Looks good except @mengqiy's comment about disabling some manifests.
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.
Reviewed Switch to current directory in tests
, looks good.
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.
reviewed the last commit fixup! Switch kb dependencies over to modules
, and looks good.
Go tooling ignores testdata, so the Go module manipulation commands (pretty much everything that Go does) will ignore the test projects. The v1 scaffolding needs to be in its own gopath, otherwise the tooling will ignore the vendor directory.
Dep is having a conniption over v0.1.10 and a mismatch in patch versions on kubernetes libs, so I'll stick on v0.1.8 here for the v1 scaffolding. |
This performs the move of the actual files that's set up in the previous commit.
This switches the v2 scaffolding to use Go modules. Currently, a custom fork of controller-runtime is being used. We'll need to merge that to controller-runtime master before merging this.
A change was introduced to the v1 scaffolding at some point that broke new scaffolding on v0.1.1, so upgrade to v0.1.8 to fix it again.
imports.Process makes some dubious assumptions about how import paths correspond to package names (not wanting to believe that a normal import path could possibly end in v1), and fails to properly double-check its work. Introduce an explicit alias to work around that.
This switches the v2 scaffolding to make use of (the upcoming) controller-tools v0.2.0, which has rewritten generators and a bundled deepcopy. It's currently using a prerelease version. controller-tools is now consumed as a binary, available via `go get` with modules turned on.
Lots of the module stuff (and more) depends on the "context" of the module, so being in the right directory when we run the imports.Process from the tests is important.
cf87637
to
82451fb
Compare
comments should be addressed |
fixed a pluralization bug in the mean time |
The golden file unit tests are borked again. The pass locally for me, so 🤷♀️ . I'm half tempted to just nix them entirely and replace them with some bash that does the same thing, since the |
They're roughly equivalent of generated_golden.sh and git status --porcelain, so we should just do that.
This updates the v2 scaffolding to support the upcoming v0.2.0 controller-tools branch. It disables webhook-related things, since v2 scaffolding doesn't scaffold webhook Go code yet and it was breaking stuff.
It also assumes controller-gen is packaged as a binary. Since we've got Go modules, we can just
GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@<temporary-branch-for-now>
, which is what this does.Still waiting on: