Repository navigation
✨ CRD v1 support - #356
✨ CRD v1 support#356
Conversation
This includes all the basic imports from apiextensions/v1 --> apiextensions/v1beta1 that didn't also have signification code changes.
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
It was previous possible for a generator implementation to become non-hashable by adding non-hashable fields, and since interface values compare by deferencing to their underlying values, this was a problem. This changes it to refer to everything by a *pointer* to a Generator, which just compares the pointer value. Since we're shipping around unique instances anyway, this is fine.
1877101 to
a5b7b1a
Compare
| @@ -1,382 +0,0 @@ | |||
| # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. | |||
| return fmt.Errorf("failed to set versioned schemas for %s: %v", existingInfo.GroupKind, err) | ||
| if err := existingSet.setVersionedSchemata(); err != nil { | ||
| return fmt.Errorf("failed to set versioned schemas for %s: %v", existingSet.GroupKind, err) | ||
| } |
There was a problem hiding this comment.
the top-level field does not exist anymore in v1. You always set schemas, subresources etc. in the versions.
There was a problem hiding this comment.
yep. I can probably make it clearer, but if you look at the source for setGlobalSchema, it only does so if it's looking at a v1beta1 CRD, and delegates back to setVersionedSchemata for the v1 CRD. We might want to rename the methods...
droot
left a comment
There was a problem hiding this comment.
Overall looks good. have minor comments/questions.
| current_dir=$(pwd) | ||
| if ! readlink -f . &>/dev/null; then | ||
| echo "you're probably on OSX. Please install gnu readlink -- otherwise you're missing the most useful readlink flag." | ||
| exit 1 |
|
|
||
| if len(crdVersions) == 0 { | ||
| // put v1beta1 first to make it the "default" file for compatibility purposes | ||
| crdVersions = []string{"v1beta1", "v1"} |
There was a problem hiding this comment.
Not sure if this requires major version bump for controller-tools. In a way, it changes the default behavior. I am fine with bumping up 0.3.0.
There was a problem hiding this comment.
I don't think it's a problem because v1beta1 is still in the same named file.
There was a problem hiding this comment.
we can just not generate v1 at all by default as well
There was a problem hiding this comment.
let's just do that and eventually change to make this the default
|
|
||
| versionedCRDs := make([]interface{}, len(crdVersions)) | ||
| for i, ver := range crdVersions { | ||
| conv, err := AsVersion(crdRaw, schema.GroupVersion{Group: apiext.SchemeGroupVersion.Group, Version: ver}) |
There was a problem hiding this comment.
Summarizing our offline conversation --> so if I am using v1 specific feature (say defaulting), generated v1beta1 CRD will have defaulting specific features enabled, but when submitted to API-Server will result an error.
So current KB projects will run in to this issue when they start using v1 features. Still wondering if there is a better way to handle this transition.
This updates crd-gen to support generating CRDs of multiple "encodings" of the CRD itself (i.e. versions of the CRD object). Currently that means v1 and v1beta1. It defaults to all known versions, each getting their own file. The first version specified (v1beta1 by default) gets a non-suffixed, file, the rest are suffixed with their version.
The internal_version stuff shouldn't've had its own go.mod or go generate command -- it's intentionally part of the parent test suite.
This updates the testdata for CRD v1. All the changes are just description wrapping. We only test generation of CRD v1, since we now rely entirely on the k/apiextensions-apiserver conversion logic to do the hoisting of the common versions (and have separate tests for that).
This makes deepcopy-gen's testdata's go:generate comment use the run script to run controller-gen, meaning people updating it will always get the local copy of controller-gen without having to build it separately.
The webhook was missing generated help for its generator marker. This fixes that.
This updates schemapatcher to match the changes in crd-gen. It'll now patch all CRD versions present, and only hoist when in the legacy (v1beta1) version.
This updates the schemapatcher testdata to work with the previous commit, which introduced multi-CRD-version support.
Run `go mod tidy`, remove unused dep support now that go 1.13 is around.
a5b7b1a to
88a61ae
Compare
This introduces CRD v1 support, as well as support for generating CRDs in multiple versions of the CRD type itself (
apiextensions/v1andapiextensions/v1beta1currently).crd-gen and schemapatcher both have support for the new format.
The default in crd-gen is now to generate both v1beta1 and v1, with the first specified version (or v1beta1 if default) getting an unsuffixed file name, and the rest getting something that looks like
<old-name>.<crd-version>.yaml.This also contains a couple of utility updates, such as fixing up some helpers for regenerating testdata and some missed generator help generation.
Fixes #352