-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
pkg/plugin/v3: add plugin v3-alpha
#1551
pkg/plugin/v3: add plugin v3-alpha
#1551
Conversation
/test pull-kubebuilder-e2e-k8s-1-17-0 |
A thought on bumping plugin version stages, ex.
Nothing needs to be done in this PR regarding ^. |
190ab2f
to
e0adaee
Compare
We may want to consider adding e2e test for plugin version |
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.
Hi @estroz,
As we spoke, following my POV.
- We do not need to make v2 plugins support V2 and V3 projects
v2 plugin just support v2 projects
v3-alpha and future versions support V3* projects.
It would make the things simpler and remove the need to change the generate_tesdata.sh script.
- We do not copy all plugin/v2 scaffold files to plugin/v3
It is possible to have inplugin/v3
only what is diff as it is done between v1 to v2. See here.
The above suggestions are applied in the PR; #1498 where is possible to check that all will work as expected.
I hope that it helps to reach out to the final decision.
If the answer to 1 is no (alpha implies the plugin is unstable), then the previous stable plugin version should be the default ( If the answer to 2 is no, then we should copy all scaffolds to a new plugin whenever we create one. If yes (or a given scaffold can be considered stable in the long term), then we should selectively copy scaffolds. Regardless #1498 makes changes unrelated to creating a new plugin version, which we should make separately from creation. |
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.
looked over the scaffolding code, only skimmed the templates. comments inline (expect some of it's copy-pasted from v2, but there's some stuff that was surprising)
|
||
// (used only to gen api with --pattern=addon) | ||
// KbDeclarativePatternVersion is the sigs.k8s.io/kubebuilder-declarative-pattern version | ||
const KbDeclarativePatternVersion = "v0.0.0-20200522144838-848d48e5b073" |
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.
do we need this? I'm assuming going forward we just want --plugin declarative
or something
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 this attempts to fix a CI issue where the testdata scaffolded with addons enabled will pull the latest kubebuilder-declarative-pattern commit, which messes up git diff
.
We should probably scaffold a tools.go
containing a pinned version of this. I could also see kustomize and controller-tools versions being pinned this way, which are currently dealt with in the Makefile.
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 fix was done in https://github.com/kubernetes-sigs/kubebuilder/pull/1527/files?
I just n understand why we are changing its implementation here. Should not we just keep the scope to add new plugin version in this PR? I mean, why change it 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.
This won't be changed here, just added a TODO.
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.
OK. Yep, we have an issue tracked for we create a plugin for that. See: #1543. The solution made was just to fix it until we are able to move forward and provide a plugin for that.
c/c @DirectXMan12
if os.Getenv("KUBEBUILDER_ENABLE_PLUGINS") != "" { | ||
fs.StringVar(&p.pattern, "pattern", "", | ||
"generates an API following an extension pattern (addon)") | ||
} |
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.
ditto here
reader := bufio.NewReader(os.Stdin) | ||
if !p.resourceFlag.Changed { | ||
fmt.Println("Create Resource [y/n]") | ||
p.doResource = util.YesNo(reader) |
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.
at some point we should re-evaluate the yes/no stuff. IIRC we had wanted to do it for v2, but didn't want to break compat
return err | ||
} | ||
|
||
err = util.RunCmd("Running make", "make") |
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.
shouldn't this be conditional on the make flag defined in the other file?
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.
Currently there's no init --make
flag unlike create api
. Perhaps we should add one.
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.
Should we not here just replicate so the code to v3? IMO we should not change any impl in this pr just add the v3-alpha plugin and then we can check each case/scenario in new pr's.
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 won't be changed here, just added a TODO.
s.config.AddResource(s.resource.GVK()) | ||
|
||
if err := machinery.NewScaffold(s.plugins...).Execute( | ||
s.newUniverse(), |
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.
shouldn't we be passing the universe between scaffold calls 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.
I think that it also can be a TODO @estroz ?
bpFile.License = s.license | ||
bpFile.Owner = s.owner | ||
if err := machinery.NewScaffold().Execute( | ||
s.newUniverse(""), |
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.
ditto here and elsewhere re: re-using the universe
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 that it also can be a TODO @estroz ?
Per the meeting, IIRC we decided that the answer was "no", and that the default scaffolding for the v3 project version was going to be v2 till v3 stable was ready |
testdata: modify project-v3.* testdata to use go/v3-alpha plugin, since project-v2.* already tests plugin go/v2 generate_testdata.sh: add --plugin option
e0adaee
to
3eba593
Compare
@DirectXMan12 fixed what was easy/reasonable and added TODO's for the rest. |
project will prompt the user to run 'dep ensure' after writing the project files. | ||
` | ||
ctx.Examples = fmt.Sprintf(` # Scaffold a project using the apache2 license with "The Kubernetes authors" as owners | ||
%s init --project-version=2 --domain example.org --license apache2 --owner "The Kubernetes authors" |
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.
%s init --project-version=2 --domain example.org --license apache2 --owner "The Kubernetes authors" | |
%s init --project-version=3-alpha --domain example.org --license apache2 --owner "The Kubernetes authors" |
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.
Follow-up
) | ||
|
||
func (p *initPlugin) UpdateContext(ctx *plugin.Context) { | ||
ctx.Description = `Initialize a new project including vendor/ directory and Go package directories. |
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.
ctx.Description = `Initialize a new project including vendor/ directory and Go package directories. | |
ctx.Description = `Initialize a new project including Go package directories. |
I should be removed already.
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.
Follow-up
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 a few nits. Otherwise
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, estroz 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 |
/lgtm |
A new plugin version
v3-alpha
will contain all new plugin/scaffold changes/features. Since plugin versionv2
is tested with project version 2, we probably should just test the new plugin with project version3-alpha
. This won't necessarily be the case going forward, ex. once4-alpha
is created we should generate separate testdata./cc @DirectXMan12 @camilamacedo86 @joelanford @mengqiy