-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix(import): missing versions when importing multi-version crd #387
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: iliapolo <epolon@amazon.com>
Signed-off-by: iliapolo <epolon@amazon.com>
Signed-off-by: iliapolo <epolon@amazon.com>
Signed-off-by: iliapolo <epolon@amazon.com>
vinayak-kukreja
approved these changes
Jul 20, 2022
cdk8s-automation
pushed a commit
that referenced
this pull request
Jul 21, 2022
For some reason, we were assuming a CRD can only contain a single version. We were extracting the first version from the `versions` property and operating solely on that. This PR considers all versions in the CRD and appends the version to the FQN to avoid name collisions. Note that for backwards compatibility, the first version remains un-sufixed. So, for a CRD with kind `MyCrd` and versions `['v1alpha1', 'v1beta1']`, we will get: ```ts // for the first version - unsufixed export class MyCrd extends ApiObject { ... }; export interface MyCrdProps { readonly metadata?: ApiObjectMetadata; readonly spec?: MyCrdSpec; }; // for the second version - sufixed export class MyCrdV1Beta1 extends ApiObject { ... }; export interface MyCrdV1Beta1Props { readonly metadata?: ApiObjectMetadata; readonly spec?: MyCrdV1Beta1Spec; } ``` Where we only used to have: ```ts export class MyCrd extends ApiObject { ... }; export interface MyCrdProps { readonly metadata?: ApiObjectMetadata; readonly spec?: MyCrdSpec; }; ``` Fixes #386 (cherry picked from commit 74cb37e) Signed-off-by: Eli Polonsky <epolon@amazon.com>
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
mergify bot
pushed a commit
that referenced
this pull request
Jul 21, 2022
…#404) # Backport This will backport the following commits from `2.x` to `1.x`: - [fix(import): missing versions when importing multi-version crd (#387)](#387) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
mergify bot
pushed a commit
that referenced
this pull request
Jun 29, 2023
…different obejcts (#1042) When a CRD has multiple objects that represent the same *kind* but for different versions, `cdk8s import` will fail with a vague "already exists" error. For example: ```yaml apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta1 schema: openAPIV3Schema: ... --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta2 schema: openAPIV3Schema: ... ``` Note that if the two versions are defined within the same object, import will succeed. For example: ```yaml apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta1 schema: openAPIV3Schema: ... - name: v1beta2 schema: openAPIV3Schema: ... ``` This is actually a followup to #387.
cdk8s-automation
pushed a commit
that referenced
this pull request
Jun 29, 2023
…different obejcts (#1042) When a CRD has multiple objects that represent the same *kind* but for different versions, `cdk8s import` will fail with a vague "already exists" error. For example: ```yaml apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta1 schema: openAPIV3Schema: ... --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta2 schema: openAPIV3Schema: ... ``` Note that if the two versions are defined within the same object, import will succeed. For example: ```yaml apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: tenants.capsule.clastix.io spec: group: capsule.clastix.io names: kind: Tenant listKind: TenantList plural: tenants shortNames: - tnt singular: tenant scope: Cluster versions: - name: v1beta1 schema: openAPIV3Schema: ... - name: v1beta2 schema: openAPIV3Schema: ... ``` This is actually a followup to #387. (cherry picked from commit 18e6eda) Signed-off-by: Eli Polonsky <epolon@amazon.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some reason, we were assuming a CRD can only contain a single version. We were extracting the first version from the
versions
property and operating solely on that.This PR considers all versions in the CRD and appends the version to the FQN to avoid name collisions.
Note that for backwards compatibility, the first version remains un-sufixed.
So, for a CRD with kind
MyCrd
and versions['v1alpha1', 'v1beta1']
, we will get:Where we only used to have:
Fixes #386