Add VolumeGroupSnapshot API definition, including CRD, client,

informer and lister generated code.
Update ./client/hack/README with instructions to update the client
directory.
This commit is contained in:
Raunak Pradip Shah
2023-02-24 14:26:45 +05:30
parent 0559478fc0
commit 0f5bcc4ff3
122 changed files with 6142 additions and 89 deletions

View File

@@ -26,7 +26,7 @@ Make sure to run this script after making changes to /client/apis/volumesnapshot
```
* Checkout latest release version
```bash
git checkout v0.25.2
git checkout v0.26.0
```
* Ensure the file `generate-groups.sh` exists
@@ -52,6 +52,40 @@ Once you run the script, you will get an output as follows:
```
The following changes need to be made manually after running the above script:
* The `SharedInformerFactory` interface in `./informers/factory.go` will have two functions named `Snapshot()`. Modify one to `GroupSnapshot()` and fix all references to that function in `informers/generic.go`.
```bash
Snapshot() volumegroupsnapshot.Interface
Snapshot() volumesnapshot.Interface
}
func (f *sharedInformerFactory) Snapshot() volumegroupsnapshot.Interface {
return volumegroupsnapshot.New(f, f.namespace, f.tweakListOptions)
}
func (f *sharedInformerFactory) Snapshot() volumesnapshot.Interface {
return volumesnapshot.New(f, f.namespace, f.tweakListOptions)
}
```
will become
```bash
GroupSnapshot() volumegroupsnapshot.Interface
Snapshot() volumesnapshot.Interface
}
func (f *sharedInformerFactory) GroupSnapshot() volumegroupsnapshot.Interface {
return volumegroupsnapshot.New(f, f.namespace, f.tweakListOptions)
}
func (f *sharedInformerFactory) Snapshot() volumesnapshot.Interface {
return volumesnapshot.New(f, f.namespace, f.tweakListOptions)
}
```
## update-crd.sh
NOTE: We need to keep both v1beta1 and v1 snapshot APIs but set served and storage version of v1beta1 to false. Please copy back the v1beta1 manifest back to the files as this script will remove it.
@@ -116,7 +150,7 @@ Update the restoreSize property to use type string only:
* In `client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml`, we need to add the `oneOf` constraint to make sure only one of `persistentVolumeClaimName` and `volumeSnapshotContentName` is specified in the `source` field of the `spec` of `VolumeSnapshot`.
```
```bash
source:
description: source specifies where a snapshot will be created from. This field is immutable after creation. Required.
properties:
@@ -135,7 +169,7 @@ Update the restoreSize property to use type string only:
* In `client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml `, we need to add the `oneOf` constraint to make sure only one of `snapshotHandle` and `volumeHandle` is specified in the `source` field of the `spec` of `VolumeSnapshotContent`.
```
```bash
source:
description: source specifies from where a snapshot will be created. This field is immutable after creation. Required.
properties:
@@ -149,7 +183,7 @@ Update the restoreSize property to use type string only:
oneOf:
- required: ["snapshotHandle"]
- required: ["volumeHandle"]
volumeSnapshotClassName:
sourceVolumeMode:
```
* Add the VolumeSnapshot namespace to the `additionalPrinterColumns` section. Refer https://github.com/kubernetes-csi/external-snapshotter/pull/535 for more details.

View File

@@ -28,7 +28,7 @@ then
TMP_DIR=$(mktemp -d);
cd $TMP_DIR;
go mod init tmp;
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.8.0;
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3;
rm -rf $TMP_DIR;
CONTROLLER_GEN=$(which controller-gen)
fi
@@ -39,7 +39,7 @@ then
exit 1;
fi
$CONTROLLER_GEN crd:crdVersions=v1 paths=${SCRIPT_ROOT}/apis/volumesnapshot/v1
$CONTROLLER_GEN crd paths=${SCRIPT_ROOT}/apis/...
# To use your own boilerplate text use:
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt

View File

@@ -26,7 +26,7 @@ SCRIPT_ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
# instead of the $GOPATH directly. For normal projects this can be dropped.
${GOPATH}/src/k8s.io/code-generator/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/kubernetes-csi/external-snapshotter/client/v6 github.com/kubernetes-csi/external-snapshotter/client/v6/apis \
volumesnapshot:v1 \
"volumesnapshot:v1 volumegroupsnapshot:v1alpha1" \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt
# To use your own boilerplate text use: