From 8ac2e79b79a15fab3a498a01bbac1ec814cc92d2 Mon Sep 17 00:00:00 2001 From: Braxton Schafer Date: Thu, 8 Jun 2023 15:21:42 -0500 Subject: [PATCH 1/2] fix: update CRD yaml files to include object meta Previously, the CRD yaml files did not include the objectmeta field (metadata) that the CRD definitions themselves do include. This was causing issues for tools that parse only the schema, such as linters. This updates all of the yaml files to include the metadata field in their schemae. --- ...oupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml | 4 +++- ...upsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml | 4 +++- .../groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml | 4 +++- .../crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml | 4 +++- .../crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml | 4 +++- .../config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml index bbdf7629..61a3787e 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io spec: @@ -53,6 +53,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object parameters: additionalProperties: type: string diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml index 2e18f920..5a619dcc 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io spec: @@ -35,6 +35,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object spec: description: Spec defines properties of a VolumeGroupSnapshotContent created by the underlying storage system. Required. diff --git a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml index d4139afa..cb1b97c6 100644 --- a/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml +++ b/client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumegroupsnapshots.groupsnapshot.storage.k8s.io spec: @@ -34,6 +34,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object spec: description: Spec defines the desired characteristics of a group snapshot requested by a user. Required. diff --git a/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml index 56a8e148..c614ab38 100644 --- a/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml +++ b/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumesnapshotclasses.snapshot.storage.k8s.io spec: @@ -65,6 +65,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object parameters: additionalProperties: type: string diff --git a/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml index d6181ed9..aaeb5f4a 100644 --- a/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml +++ b/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumesnapshotcontents.snapshot.storage.k8s.io spec: @@ -71,6 +71,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object spec: description: spec defines properties of a VolumeSnapshotContent created by the underlying storage system. Required. diff --git a/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml index 3e7f9966..ec419163 100644 --- a/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml +++ b/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml @@ -3,8 +3,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814" + controller-gen.kubebuilder.io/version: v0.12.0 creationTimestamp: null name: volumesnapshots.snapshot.storage.k8s.io spec: @@ -74,6 +74,8 @@ spec: object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string + metadata: + type: object spec: description: 'spec defines the desired characteristics of a snapshot requested by a user. More info: https://kubernetes.io/docs/concepts/storage/volume-snapshots#volumesnapshots From 7308dc454cb05d790fc3b316ba033c0a7e0da178 Mon Sep 17 00:00:00 2001 From: Braxton Schafer Date: Thu, 8 Jun 2023 15:23:57 -0500 Subject: [PATCH 2/2] doc: update crd generation to keep metadata --- client/hack/README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/client/hack/README.md b/client/hack/README.md index d27cdaad..1a29f082 100644 --- a/client/hack/README.md +++ b/client/hack/README.md @@ -66,16 +66,6 @@ Follow these steps to update the CRD: * Add api-approved.kubernetes.io annotation value in all yaml files in the metadata section with the PR where the API is approved by the API reviewers. The current approved PR for snapshot v1 API is https://github.com/kubernetes-csi/external-snapshotter/pull/419. Refer to https://github.com/kubernetes/enhancements/pull/1111 for details about this annotation. -* Remove any metadata sections from the yaml file which does not belong to the generated type. -For example, the following command will add a metadata section for a nested object, remove any newly added metadata sections. TODO(xiangqian): this is to make sure the generated CRD is compatible with apiextensions.k8s.io/v1. Once controller-gen supports generating CRD with apiextensions.k8s.io/v1, switch to use the correct version of controller-gen and remove the last step from this README. - -```bash -./hack/update-crd.sh; git diff -+ metadata: -+ description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' - type: object -``` - * Update the restoreSize property to string in snapshot.storage.k8s.io_volumesnapshots.yaml The generated yaml file contains restoreSize property anyOf as described below: @@ -180,4 +170,4 @@ Update the restoreSize property to use type string only: - required: ["persistentVolumeNames"] - required: ["volumeGroupSnapshotHandle"] volumeGroupSnapshotClassName: -``` \ No newline at end of file +```