diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..f3ab914 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +golang 1.20 diff --git a/README.md b/README.md index 422dbb3..e188b2a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,6 @@ Gemini is a Kubernetes CRD and operator for managing `VolumeSnapshots`. This all to create a snapshot of the data on your `PersistentVolumes` on a regular schedule, retire old snapshots, and restore snapshots with minimal downtime. -> Note: Like the VolumeSnapshot API it builds on, Gemini is **currently in beta**. - ## Installation The Gemini Helm chart will install both the CRD and the operator into your cluster @@ -49,6 +47,15 @@ kubectl api-resources | grep volumesnapshots Before getting started with Gemini, it's a good idea to make sure you're able to [create a VolumeSnapshot manually](https://kubernetes.io/docs/concepts/storage/volume-snapshots/#volumesnapshots). +### Upgrading to V2 +Version 2.0 of Gemini updates the CRD from `v1beta1` to `v1`. There are no substantial +changes, but `v1` adds better support for PersistentVolumeClaims on Kubernetes 1.25. + +If you want to keep the v1beta1 CRD available, you can run: +``` +kubectl apply -f https://raw.githubusercontent.com/FairwindsOps/gemini/main/pkg/types/snapshotgroup/v1beta1/crd-with-beta1.yaml +``` +before upgrading, and add `--skip-crds` when running `helm install`. ## Usage @@ -112,7 +119,7 @@ E.g. right after a new snapshot is created, you'll see snapshots for #### Using an Existing PVC -> See the [extended example](/examples/hackmd/README.md) +> See the [extended example](/examples/codimd/README.md) The following example schedules snapshots every 10 minutes for a pre-existing PVC named `postgres`. ```yaml @@ -200,7 +207,7 @@ $ kubectl scale all --all --replicas=1 ``` ## End-to-End Example -To see gemini working end-to-end, check out [the HackMD example](examples/hackmd) +To see gemini working end-to-end, check out [the CodiMD example](examples/codimd) ## Caveats * Like the VolumeSnapshot API it builds on, Gemini is **currently in beta** diff --git a/examples/hackmd/README.md b/examples/codimd/README.md similarity index 54% rename from examples/hackmd/README.md rename to examples/codimd/README.md index 26cdfb1..4fc5556 100644 --- a/examples/hackmd/README.md +++ b/examples/codimd/README.md @@ -1,20 +1,19 @@ -# Gemini Example: HackMD +# Gemini Example: CodiMD > Note: this will not work in a KIND cluster. It has been tested on DigitalOcean. ### Install the controller ```bash -kubectl create ns gemini helm repo add fairwinds-stable https://charts.fairwinds.com/stable -helm install gemini fairwinds-stable/gemini --namespace gemini +helm install gemini fairwinds-stable/gemini --namespace gemini --create-namespace ``` -### Install HackMD +### Install CodiMD ```bash -kubectl create ns notepad -helm install hackmd stable/hackmd -n notepad --version "2.0.*" --set postgresql.postgresqlPassword=thisisnotasecret +helm repo add codimd https://helm.codimd.dev/ +helm upgrade --install codimd codimd/codimd -n codimd --create-namespace --set codimd.imageStorePersistentVolume.enabled=false ``` -This will create two PVCs, one for HackMD, and one for the Postgres instance that backs it. +This will create a PVC for the Postgres instance that drives CodiMD. ### Set up the Backup Schedule ```bash @@ -22,25 +21,11 @@ cat < Note that we only need to restore PostgreSQL - we didn't change anything in the core app. - First, we need to scale down our deployment. We can't swap out a PVC in-place, so you'll necessarily incur some downtime. ```bash -kubectl scale all --all --replicas=0 -n notepad +kubectl scale all --all --replicas=0 -n codimd ``` Next, annotate the `SnapshotGroup` with the timestamp of the snapshot you want. For example, here we'll use timestamp `1585945609`. ```bash -$ kubectl get volumesnapshot -n notepad +$ kubectl get volumesnapshot -n codimd NAME AGE -hackmd-1585945609 15s -hackmd-postgresql-1585945609 15s +codimd-1585945609 15s +codimd-postgresql-1585945609 15s ``` ```bash -kubectl annotate snapshotgroup/hackmd-postgresql -n notepad --overwrite \ +kubectl annotate snapshotgroup/codimd-postgresql -n codimd --overwrite \ "gemini.fairwinds.com/restore=1585945609" ``` @@ -123,16 +105,18 @@ This will: Note: If your PVC gets stuck in `Terminating`, this might be related to rate-limiting from the DO API (check [this issue](https://github.com/FairwindsOps/gemini/issues/29) for more info) You can force destroy the PVC by running: ```bash -kubectl -n notepad patch pvc data-hackmd-postgresql-0 -p '{"metadata":{"finalizers": []}}' --type=merge +kubectl -n codimd patch pvc data-codimd-postgresql-0 -p '{"metadata":{"finalizers": []}}' --type=merge ``` +Wait until you see that your PVC is back in `Bound` state. + Finally, we can scale back up: ```bash -kubectl scale all --all --replicas=1 -n notepad +kubectl scale all --all --replicas=1 -n codimd ``` ### Verify the restore ```bash -kubectl port-forward svc/hackmd 3000:3000 -n notepad +kubectl port-forward svc/codimd 3000:80 -n codimd ``` Go back to your document. The second round of edits you made should be gone! diff --git a/examples/hackmd/course.yaml b/examples/hackmd/course.yaml deleted file mode 100644 index f94e2c5..0000000 --- a/examples/hackmd/course.yaml +++ /dev/null @@ -1,7 +0,0 @@ -namespace: notepad -charts: - hackmd: - namespace: notepad - values: - postgresql: - postgresqlPassword: thisisnotasecret diff --git a/examples/hackmd/snapshotgroup.yaml b/examples/hackmd/snapshotgroup.yaml deleted file mode 100644 index 2db1c8a..0000000 --- a/examples/hackmd/snapshotgroup.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: gemini.fairwinds.com/v1beta1 -kind: SnapshotGroup -metadata: - name: hackmd - namespace: notepad -spec: - persistentVolumeClaim: - claimName: hackmd - schedule: - - every: "10 minutes" - keep: 3 - - every: hour - keep: 1 ---- -apiVersion: gemini.fairwinds.com/v1beta1 -kind: SnapshotGroup -metadata: - name: hackmd-postgresql - namespace: notepad -spec: - persistentVolumeClaim: - claimName: data-hackmd-postgresql-0 - schedule: - - every: "10 minutes" - keep: 3 - - every: hour - keep: 1 - diff --git a/go.mod b/go.mod index 7008cf5..ecc75ea 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 github.com/stretchr/testify v1.8.1 golang.org/x/time v0.3.0 + gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.26.1 k8s.io/apiextensions-apiserver v0.26.1 k8s.io/apimachinery v0.26.1 @@ -46,7 +47,6 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/kube-openapi v0.0.0-20230217203603-ff9a8e8fa21d // indirect k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 9b20fc6..1dbcb71 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -28,8 +28,8 @@ import ( "github.com/fairwindsops/gemini/pkg/kube" "github.com/fairwindsops/gemini/pkg/snapshots" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - listers "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + listers "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1" ) const defaultSnapshotReadyTimeoutSeconds = 60 diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index 1ccd536..b81fe97 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -26,7 +26,7 @@ import ( "github.com/fairwindsops/gemini/pkg/kube" "github.com/fairwindsops/gemini/pkg/snapshots" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" ) func newSnapshotGroup(name, namespace string) *snapshotgroup.SnapshotGroup { diff --git a/pkg/kube/client.go b/pkg/kube/client.go index f1ca78e..545ed9c 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -15,6 +15,7 @@ package kube import ( + "os" "context" "errors" "time" @@ -31,11 +32,11 @@ import ( "k8s.io/client-go/restmapper" "sigs.k8s.io/controller-runtime/pkg/client/config" - snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - snapshotGroupClientset "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned" - snapshotgroupInterface "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1" - "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions" - informers "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + snapshotGroupClientset "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned" + snapshotgroupInterface "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1" + "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions" + informers "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1" ) const ( @@ -51,7 +52,7 @@ type Client struct { Informer informers.SnapshotGroupInformer InformerFactory externalversions.SharedInformerFactory SnapshotClient dynamic.NamespaceableResourceInterface - SnapshotGroupClient snapshotgroupInterface.SnapshotgroupV1beta1Interface + SnapshotGroupClient snapshotgroupInterface.SnapshotgroupV1Interface VolumeSnapshotVersion string } @@ -84,7 +85,7 @@ func createClient() *Client { } informerFactory := externalversions.NewSharedInformerFactory(sgClientSet, time.Second*30) - informer := informerFactory.Snapshotgroup().V1beta1().SnapshotGroups() + informer := informerFactory.Snapshotgroup().V1().SnapshotGroups() resources, err := restmapper.GetAPIGroupResources(k8s.Discovery()) if err != nil { @@ -113,15 +114,17 @@ func createClient() *Client { } snapshotClient := dynamicInterface.Resource(vsMapping.Resource) - if _, err = snapshotgroupv1.CreateCustomResourceDefinition("crd-ns", extClientSet); err != nil { - panic(err) + if os.Getenv("GEMINI_CREATE_CRD") != "" { + if _, err = snapshotgroupv1.CreateCustomResourceDefinition("crd-ns", extClientSet); err != nil { + panic(err) + } } return &Client{ K8s: k8s, Informer: informer, InformerFactory: informerFactory, SnapshotClient: snapshotClient, - SnapshotGroupClient: sgClientSet.SnapshotgroupV1beta1(), + SnapshotGroupClient: sgClientSet.SnapshotgroupV1(), VolumeSnapshotVersion: VolumeSnapshotGroupName + "/" + volumeSnapshotVersion, } } diff --git a/pkg/kube/fake_client.go b/pkg/kube/fake_client.go index e4a08bd..d0d55bd 100644 --- a/pkg/kube/fake_client.go +++ b/pkg/kube/fake_client.go @@ -23,8 +23,8 @@ import ( dynamicFake "k8s.io/client-go/dynamic/fake" k8sfake "k8s.io/client-go/kubernetes/fake" - snapshotGroupsFake "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake" - snapshotGroupExternalVersions "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions" + snapshotGroupsFake "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake" + snapshotGroupExternalVersions "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions" ) var noResync = func() time.Duration { return 0 } @@ -42,11 +42,11 @@ func createFakeClient() *Client { snapshotGroupClientSet := snapshotGroupsFake.NewSimpleClientset(objects...) informerFactory := snapshotGroupExternalVersions.NewSharedInformerFactory(snapshotGroupClientSet, noResync()) - informer := informerFactory.Snapshotgroup().V1beta1().SnapshotGroups() + informer := informerFactory.Snapshotgroup().V1().SnapshotGroups() volumeSnapshotVersionResource := schema.GroupVersionResource{ Group: VolumeSnapshotGroupName, - Version: "v1beta1", + Version: "v1", Resource: VolumeSnapshotKind, } dynamic := dynamicFake.NewSimpleDynamicClientWithCustomListKinds(k8sruntime.NewScheme(), map[schema.GroupVersionResource]string{ @@ -59,6 +59,6 @@ func createFakeClient() *Client { Informer: informer, InformerFactory: informerFactory, SnapshotClient: snapshotClient, - SnapshotGroupClient: snapshotGroupClientSet.SnapshotgroupV1beta1(), + SnapshotGroupClient: snapshotGroupClientSet.SnapshotgroupV1(), } } diff --git a/pkg/snapshots/groups.go b/pkg/snapshots/groups.go index 876d1ee..d4fa13c 100644 --- a/pkg/snapshots/groups.go +++ b/pkg/snapshots/groups.go @@ -22,7 +22,7 @@ import ( "k8s.io/klog/v2" "github.com/fairwindsops/gemini/pkg/kube" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" ) func updateSnapshotGroup(sg *snapshotgroup.SnapshotGroup) error { diff --git a/pkg/snapshots/pvc.go b/pkg/snapshots/pvc.go index b472fdc..a6ba1f6 100644 --- a/pkg/snapshots/pvc.go +++ b/pkg/snapshots/pvc.go @@ -24,7 +24,7 @@ import ( "k8s.io/klog/v2" "github.com/fairwindsops/gemini/pkg/kube" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" ) func getPVCName(sg *snapshotgroup.SnapshotGroup) string { diff --git a/pkg/snapshots/scheduler.go b/pkg/snapshots/scheduler.go index 85490ae..0c2d5f1 100644 --- a/pkg/snapshots/scheduler.go +++ b/pkg/snapshots/scheduler.go @@ -20,7 +20,7 @@ import ( "strings" "time" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" "k8s.io/klog/v2" ) diff --git a/pkg/snapshots/scheduler_test.go b/pkg/snapshots/scheduler_test.go index 45fc0dc..2808de0 100644 --- a/pkg/snapshots/scheduler_test.go +++ b/pkg/snapshots/scheduler_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" "github.com/stretchr/testify/assert" ) diff --git a/pkg/snapshots/snapshots.go b/pkg/snapshots/snapshots.go index c329993..f04f143 100644 --- a/pkg/snapshots/snapshots.go +++ b/pkg/snapshots/snapshots.go @@ -24,9 +24,9 @@ import ( "time" "github.com/fairwindsops/gemini/pkg/kube" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" - snapshotsv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1beta1" + snapshotsv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/clientset.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/clientset.go similarity index 78% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/clientset.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/clientset.go index 7f8e4f3..098f1de 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/clientset.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/clientset.go @@ -21,7 +21,7 @@ package versioned import ( "fmt" - snapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -29,19 +29,19 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - SnapshotgroupV1beta1() snapshotgroupv1beta1.SnapshotgroupV1beta1Interface + SnapshotgroupV1() snapshotgroupv1.SnapshotgroupV1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - snapshotgroupV1beta1 *snapshotgroupv1beta1.SnapshotgroupV1beta1Client + snapshotgroupV1 *snapshotgroupv1.SnapshotgroupV1Client } -// SnapshotgroupV1beta1 retrieves the SnapshotgroupV1beta1Client -func (c *Clientset) SnapshotgroupV1beta1() snapshotgroupv1beta1.SnapshotgroupV1beta1Interface { - return c.snapshotgroupV1beta1 +// SnapshotgroupV1 retrieves the SnapshotgroupV1Client +func (c *Clientset) SnapshotgroupV1() snapshotgroupv1.SnapshotgroupV1Interface { + return c.snapshotgroupV1 } // Discovery retrieves the DiscoveryClient @@ -65,7 +65,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.snapshotgroupV1beta1, err = snapshotgroupv1beta1.NewForConfig(&configShallowCopy) + cs.snapshotgroupV1, err = snapshotgroupv1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -81,7 +81,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.snapshotgroupV1beta1 = snapshotgroupv1beta1.NewForConfigOrDie(c) + cs.snapshotgroupV1 = snapshotgroupv1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -90,7 +90,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.snapshotgroupV1beta1 = snapshotgroupv1beta1.New(c) + cs.snapshotgroupV1 = snapshotgroupv1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/doc.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/doc.go similarity index 100% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/doc.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/doc.go diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/clientset_generated.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/clientset_generated.go similarity index 80% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/clientset_generated.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/clientset_generated.go index 1ab1571..33d4101 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/clientset_generated.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/clientset_generated.go @@ -19,9 +19,9 @@ limitations under the License. package fake import ( - clientset "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned" - snapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1" - fakesnapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake" + clientset "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1" + fakesnapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -76,7 +76,7 @@ func (c *Clientset) Tracker() testing.ObjectTracker { var _ clientset.Interface = &Clientset{} -// SnapshotgroupV1beta1 retrieves the SnapshotgroupV1beta1Client -func (c *Clientset) SnapshotgroupV1beta1() snapshotgroupv1beta1.SnapshotgroupV1beta1Interface { - return &fakesnapshotgroupv1beta1.FakeSnapshotgroupV1beta1{Fake: &c.Fake} +// SnapshotgroupV1 retrieves the SnapshotgroupV1Client +func (c *Clientset) SnapshotgroupV1() snapshotgroupv1.SnapshotgroupV1Interface { + return &fakesnapshotgroupv1.FakeSnapshotgroupV1{Fake: &c.Fake} } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/doc.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/doc.go similarity index 100% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/doc.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/doc.go diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/register.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/register.go similarity index 93% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/register.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/register.go index db3e97a..5c7429e 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/fake/register.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - snapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotgroupv1beta1.AddToScheme, + snapshotgroupv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme/doc.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme/doc.go similarity index 100% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme/doc.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme/doc.go diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme/register.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme/register.go similarity index 93% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme/register.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme/register.go index 5bbe926..0790a45 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme/register.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - snapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - snapshotgroupv1beta1.AddToScheme, + snapshotgroupv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/doc.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/doc.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/doc.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/doc.go index 7711019..3af5d05 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/doc.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1beta1 +package v1 diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/doc.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/doc.go similarity index 100% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/doc.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/doc.go diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup.go similarity index 67% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup.go index cc9952f..1cd972c 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup.go @@ -21,8 +21,8 @@ package fake import ( "context" - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" @@ -32,29 +32,29 @@ import ( // FakeSnapshotGroups implements SnapshotGroupInterface type FakeSnapshotGroups struct { - Fake *FakeSnapshotgroupV1beta1 + Fake *FakeSnapshotgroupV1 ns string } -var snapshotgroupsResource = schema.GroupVersionResource{Group: "snapshotgroup", Version: "v1beta1", Resource: "snapshotgroups"} +var snapshotgroupsResource = schema.GroupVersionResource{Group: "snapshotgroup", Version: "v1", Resource: "snapshotgroups"} -var snapshotgroupsKind = schema.GroupVersionKind{Group: "snapshotgroup", Version: "v1beta1", Kind: "SnapshotGroup"} +var snapshotgroupsKind = schema.GroupVersionKind{Group: "snapshotgroup", Version: "v1", Kind: "SnapshotGroup"} // Get takes name of the snapshotGroup, and returns the corresponding snapshotGroup object, and an error if there is any. -func (c *FakeSnapshotGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.SnapshotGroup, err error) { +func (c *FakeSnapshotGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SnapshotGroup, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(snapshotgroupsResource, c.ns, name), &v1beta1.SnapshotGroup{}) + Invokes(testing.NewGetAction(snapshotgroupsResource, c.ns, name), &v1.SnapshotGroup{}) if obj == nil { return nil, err } - return obj.(*v1beta1.SnapshotGroup), err + return obj.(*v1.SnapshotGroup), err } // List takes label and field selectors, and returns the list of SnapshotGroups that match those selectors. -func (c *FakeSnapshotGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.SnapshotGroupList, err error) { +func (c *FakeSnapshotGroups) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SnapshotGroupList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(snapshotgroupsResource, snapshotgroupsKind, c.ns, opts), &v1beta1.SnapshotGroupList{}) + Invokes(testing.NewListAction(snapshotgroupsResource, snapshotgroupsKind, c.ns, opts), &v1.SnapshotGroupList{}) if obj == nil { return nil, err @@ -64,8 +64,8 @@ func (c *FakeSnapshotGroups) List(ctx context.Context, opts v1.ListOptions) (res if label == nil { label = labels.Everything() } - list := &v1beta1.SnapshotGroupList{ListMeta: obj.(*v1beta1.SnapshotGroupList).ListMeta} - for _, item := range obj.(*v1beta1.SnapshotGroupList).Items { + list := &v1.SnapshotGroupList{ListMeta: obj.(*v1.SnapshotGroupList).ListMeta} + for _, item := range obj.(*v1.SnapshotGroupList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,57 +74,57 @@ func (c *FakeSnapshotGroups) List(ctx context.Context, opts v1.ListOptions) (res } // Watch returns a watch.Interface that watches the requested snapshotGroups. -func (c *FakeSnapshotGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeSnapshotGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(snapshotgroupsResource, c.ns, opts)) } // Create takes the representation of a snapshotGroup and creates it. Returns the server's representation of the snapshotGroup, and an error, if there is any. -func (c *FakeSnapshotGroups) Create(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.CreateOptions) (result *v1beta1.SnapshotGroup, err error) { +func (c *FakeSnapshotGroups) Create(ctx context.Context, snapshotGroup *v1.SnapshotGroup, opts metav1.CreateOptions) (result *v1.SnapshotGroup, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(snapshotgroupsResource, c.ns, snapshotGroup), &v1beta1.SnapshotGroup{}) + Invokes(testing.NewCreateAction(snapshotgroupsResource, c.ns, snapshotGroup), &v1.SnapshotGroup{}) if obj == nil { return nil, err } - return obj.(*v1beta1.SnapshotGroup), err + return obj.(*v1.SnapshotGroup), err } // Update takes the representation of a snapshotGroup and updates it. Returns the server's representation of the snapshotGroup, and an error, if there is any. -func (c *FakeSnapshotGroups) Update(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.UpdateOptions) (result *v1beta1.SnapshotGroup, err error) { +func (c *FakeSnapshotGroups) Update(ctx context.Context, snapshotGroup *v1.SnapshotGroup, opts metav1.UpdateOptions) (result *v1.SnapshotGroup, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(snapshotgroupsResource, c.ns, snapshotGroup), &v1beta1.SnapshotGroup{}) + Invokes(testing.NewUpdateAction(snapshotgroupsResource, c.ns, snapshotGroup), &v1.SnapshotGroup{}) if obj == nil { return nil, err } - return obj.(*v1beta1.SnapshotGroup), err + return obj.(*v1.SnapshotGroup), err } // Delete takes name of the snapshotGroup and deletes it. Returns an error if one occurs. -func (c *FakeSnapshotGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeSnapshotGroups) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(snapshotgroupsResource, c.ns, name), &v1beta1.SnapshotGroup{}) + Invokes(testing.NewDeleteAction(snapshotgroupsResource, c.ns, name), &v1.SnapshotGroup{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeSnapshotGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeSnapshotGroups) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(snapshotgroupsResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &v1beta1.SnapshotGroupList{}) + _, err := c.Fake.Invokes(action, &v1.SnapshotGroupList{}) return err } // Patch applies the patch and returns the patched snapshotGroup. -func (c *FakeSnapshotGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SnapshotGroup, err error) { +func (c *FakeSnapshotGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SnapshotGroup, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(snapshotgroupsResource, c.ns, name, pt, data, subresources...), &v1beta1.SnapshotGroup{}) + Invokes(testing.NewPatchSubresourceAction(snapshotgroupsResource, c.ns, name, pt, data, subresources...), &v1.SnapshotGroup{}) if obj == nil { return nil, err } - return obj.(*v1beta1.SnapshotGroup), err + return obj.(*v1.SnapshotGroup), err } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup_client.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup_client.go similarity index 73% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup_client.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup_client.go index 067b23c..edb72f8 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/fake/fake_snapshotgroup_client.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/fake/fake_snapshotgroup_client.go @@ -19,22 +19,22 @@ limitations under the License. package fake import ( - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeSnapshotgroupV1beta1 struct { +type FakeSnapshotgroupV1 struct { *testing.Fake } -func (c *FakeSnapshotgroupV1beta1) SnapshotGroups(namespace string) v1beta1.SnapshotGroupInterface { +func (c *FakeSnapshotgroupV1) SnapshotGroups(namespace string) v1.SnapshotGroupInterface { return &FakeSnapshotGroups{c, namespace} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeSnapshotgroupV1beta1) RESTClient() rest.Interface { +func (c *FakeSnapshotgroupV1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/generated_expansion.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/generated_expansion.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/generated_expansion.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/generated_expansion.go index d430669..3891b43 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/generated_expansion.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/generated_expansion.go @@ -16,6 +16,6 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1 type SnapshotGroupExpansion interface{} diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup.go similarity index 68% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup.go index 4b1b6c7..467f8b9 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup.go @@ -16,15 +16,15 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( "context" "time" - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - scheme "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + scheme "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" @@ -38,14 +38,14 @@ type SnapshotGroupsGetter interface { // SnapshotGroupInterface has methods to work with SnapshotGroup resources. type SnapshotGroupInterface interface { - Create(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.CreateOptions) (*v1beta1.SnapshotGroup, error) - Update(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.UpdateOptions) (*v1beta1.SnapshotGroup, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.SnapshotGroup, error) - List(ctx context.Context, opts v1.ListOptions) (*v1beta1.SnapshotGroupList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SnapshotGroup, err error) + Create(ctx context.Context, snapshotGroup *snapshotgroupv1.SnapshotGroup, opts metav1.CreateOptions) (*snapshotgroupv1.SnapshotGroup, error) + Update(ctx context.Context, snapshotGroup *snapshotgroupv1.SnapshotGroup, opts metav1.UpdateOptions) (*snapshotgroupv1.SnapshotGroup, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*snapshotgroupv1.SnapshotGroup, error) + List(ctx context.Context, opts metav1.ListOptions) (*snapshotgroupv1.SnapshotGroupList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *snapshotgroupv1.SnapshotGroup, err error) SnapshotGroupExpansion } @@ -56,7 +56,7 @@ type snapshotGroups struct { } // newSnapshotGroups returns a SnapshotGroups -func newSnapshotGroups(c *SnapshotgroupV1beta1Client, namespace string) *snapshotGroups { +func newSnapshotGroups(c *SnapshotgroupV1Client, namespace string) *snapshotGroups { return &snapshotGroups{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newSnapshotGroups(c *SnapshotgroupV1beta1Client, namespace string) *snapsho } // Get takes name of the snapshotGroup, and returns the corresponding snapshotGroup object, and an error if there is any. -func (c *snapshotGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.SnapshotGroup, err error) { - result = &v1beta1.SnapshotGroup{} +func (c *snapshotGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *snapshotgroupv1.SnapshotGroup, err error) { + result = &snapshotgroupv1.SnapshotGroup{} err = c.client.Get(). Namespace(c.ns). Resource("snapshotgroups"). @@ -77,12 +77,12 @@ func (c *snapshotGroups) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of SnapshotGroups that match those selectors. -func (c *snapshotGroups) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.SnapshotGroupList, err error) { +func (c *snapshotGroups) List(ctx context.Context, opts metav1.ListOptions) (result *snapshotgroupv1.SnapshotGroupList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1beta1.SnapshotGroupList{} + result = &snapshotgroupv1.SnapshotGroupList{} err = c.client.Get(). Namespace(c.ns). Resource("snapshotgroups"). @@ -94,7 +94,7 @@ func (c *snapshotGroups) List(ctx context.Context, opts v1.ListOptions) (result } // Watch returns a watch.Interface that watches the requested snapshotGroups. -func (c *snapshotGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *snapshotGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -109,8 +109,8 @@ func (c *snapshotGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch. } // Create takes the representation of a snapshotGroup and creates it. Returns the server's representation of the snapshotGroup, and an error, if there is any. -func (c *snapshotGroups) Create(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.CreateOptions) (result *v1beta1.SnapshotGroup, err error) { - result = &v1beta1.SnapshotGroup{} +func (c *snapshotGroups) Create(ctx context.Context, snapshotGroup *snapshotgroupv1.SnapshotGroup, opts metav1.CreateOptions) (result *snapshotgroupv1.SnapshotGroup, err error) { + result = &snapshotgroupv1.SnapshotGroup{} err = c.client.Post(). Namespace(c.ns). Resource("snapshotgroups"). @@ -122,8 +122,8 @@ func (c *snapshotGroups) Create(ctx context.Context, snapshotGroup *v1beta1.Snap } // Update takes the representation of a snapshotGroup and updates it. Returns the server's representation of the snapshotGroup, and an error, if there is any. -func (c *snapshotGroups) Update(ctx context.Context, snapshotGroup *v1beta1.SnapshotGroup, opts v1.UpdateOptions) (result *v1beta1.SnapshotGroup, err error) { - result = &v1beta1.SnapshotGroup{} +func (c *snapshotGroups) Update(ctx context.Context, snapshotGroup *snapshotgroupv1.SnapshotGroup, opts metav1.UpdateOptions) (result *snapshotgroupv1.SnapshotGroup, err error) { + result = &snapshotgroupv1.SnapshotGroup{} err = c.client.Put(). Namespace(c.ns). Resource("snapshotgroups"). @@ -136,7 +136,7 @@ func (c *snapshotGroups) Update(ctx context.Context, snapshotGroup *v1beta1.Snap } // Delete takes name of the snapshotGroup and deletes it. Returns an error if one occurs. -func (c *snapshotGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *snapshotGroups) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("snapshotgroups"). @@ -147,7 +147,7 @@ func (c *snapshotGroups) Delete(ctx context.Context, name string, opts v1.Delete } // DeleteCollection deletes a collection of objects. -func (c *snapshotGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *snapshotGroups) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { var timeout time.Duration if listOpts.TimeoutSeconds != nil { timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second @@ -163,8 +163,8 @@ func (c *snapshotGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOpt } // Patch applies the patch and returns the patched snapshotGroup. -func (c *snapshotGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.SnapshotGroup, err error) { - result = &v1beta1.SnapshotGroup{} +func (c *snapshotGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *snapshotgroupv1.SnapshotGroup, err error) { + result = &snapshotgroupv1.SnapshotGroup{} err = c.client.Patch(pt). Namespace(c.ns). Resource("snapshotgroups"). diff --git a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup_client.go b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup_client.go similarity index 58% rename from pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup_client.go rename to pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup_client.go index 6f05e1d..852360e 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/typed/snapshotgroup/v1beta1/snapshotgroup_client.go +++ b/pkg/types/snapshotgroup/v1/apis/clientset/versioned/typed/snapshotgroup/v1/snapshotgroup_client.go @@ -16,30 +16,30 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned/scheme" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type SnapshotgroupV1beta1Interface interface { +type SnapshotgroupV1Interface interface { RESTClient() rest.Interface SnapshotGroupsGetter } -// SnapshotgroupV1beta1Client is used to interact with features provided by the snapshotgroup group. -type SnapshotgroupV1beta1Client struct { +// SnapshotgroupV1Client is used to interact with features provided by the snapshotgroup group. +type SnapshotgroupV1Client struct { restClient rest.Interface } -func (c *SnapshotgroupV1beta1Client) SnapshotGroups(namespace string) SnapshotGroupInterface { +func (c *SnapshotgroupV1Client) SnapshotGroups(namespace string) SnapshotGroupInterface { return newSnapshotGroups(c, namespace) } -// NewForConfig creates a new SnapshotgroupV1beta1Client for the given config. -func NewForConfig(c *rest.Config) (*SnapshotgroupV1beta1Client, error) { +// NewForConfig creates a new SnapshotgroupV1Client for the given config. +func NewForConfig(c *rest.Config) (*SnapshotgroupV1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -48,12 +48,12 @@ func NewForConfig(c *rest.Config) (*SnapshotgroupV1beta1Client, error) { if err != nil { return nil, err } - return &SnapshotgroupV1beta1Client{client}, nil + return &SnapshotgroupV1Client{client}, nil } -// NewForConfigOrDie creates a new SnapshotgroupV1beta1Client for the given config and +// NewForConfigOrDie creates a new SnapshotgroupV1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SnapshotgroupV1beta1Client { +func NewForConfigOrDie(c *rest.Config) *SnapshotgroupV1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -61,13 +61,13 @@ func NewForConfigOrDie(c *rest.Config) *SnapshotgroupV1beta1Client { return client } -// New creates a new SnapshotgroupV1beta1Client for the given RESTClient. -func New(c rest.Interface) *SnapshotgroupV1beta1Client { - return &SnapshotgroupV1beta1Client{c} +// New creates a new SnapshotgroupV1Client for the given RESTClient. +func New(c rest.Interface) *SnapshotgroupV1Client { + return &SnapshotgroupV1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1beta1.SchemeGroupVersion + gv := v1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() @@ -81,7 +81,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *SnapshotgroupV1beta1Client) RESTClient() rest.Interface { +func (c *SnapshotgroupV1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/factory.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/factory.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/factory.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/factory.go index d39c5da..da6f0b7 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/factory.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/factory.go @@ -23,9 +23,9 @@ import ( sync "sync" time "time" - versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned" - internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces" - snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup" + versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned" + internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces" + snapshotgroup "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/generic.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/generic.go similarity index 87% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/generic.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/generic.go index 07edbc8..ab61b7a 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/generic.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( "fmt" - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,9 +52,9 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=snapshotgroup, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("snapshotgroups"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshotgroup().V1beta1().SnapshotGroups().Informer()}, nil + // Group=snapshotgroup, Version=v1 + case v1.SchemeGroupVersion.WithResource("snapshotgroups"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Snapshotgroup().V1().SnapshotGroups().Informer()}, nil } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go index 9b18b7a..380e2e2 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -21,7 +21,7 @@ package internalinterfaces import ( time "time" - versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned" + versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" cache "k8s.io/client-go/tools/cache" diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/interface.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/interface.go similarity index 72% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/interface.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/interface.go index e576686..dfc13cb 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/interface.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/interface.go @@ -19,14 +19,14 @@ limitations under the License. package snapshotgroup import ( - internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces" - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1" + internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1beta1 provides access to shared informers for resources in V1beta1. - V1beta1() v1beta1.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1beta1 returns a new v1beta1.Interface. -func (g *group) V1beta1() v1beta1.Interface { - return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/interface.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/interface.go similarity index 94% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/interface.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/interface.go index 6e615eb..749c0a4 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/interface.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/interface.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( - internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces" + internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces" ) // Interface provides access to all the informers in this group version. diff --git a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/snapshotgroup.go b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/snapshotgroup.go similarity index 74% rename from pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/snapshotgroup.go rename to pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/snapshotgroup.go index 3d5c987..d06e9c4 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/snapshotgroup/v1beta1/snapshotgroup.go +++ b/pkg/types/snapshotgroup/v1/apis/informers/externalversions/snapshotgroup/v1/snapshotgroup.go @@ -16,17 +16,17 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( "context" time "time" - snapshotgroupv1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" - versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/clientset/versioned" - internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/informers/externalversions/internalinterfaces" - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + snapshotgroupv1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" + versioned "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/clientset/versioned" + internalinterfaces "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/informers/externalversions/internalinterfaces" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -36,7 +36,7 @@ import ( // SnapshotGroups. type SnapshotGroupInformer interface { Informer() cache.SharedIndexInformer - Lister() v1beta1.SnapshotGroupLister + Lister() v1.SnapshotGroupLister } type snapshotGroupInformer struct { @@ -58,20 +58,20 @@ func NewSnapshotGroupInformer(client versioned.Interface, namespace string, resy func NewFilteredSnapshotGroupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotgroupV1beta1().SnapshotGroups(namespace).List(context.TODO(), options) + return client.SnapshotgroupV1().SnapshotGroups(namespace).List(context.TODO(), options) }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SnapshotgroupV1beta1().SnapshotGroups(namespace).Watch(context.TODO(), options) + return client.SnapshotgroupV1().SnapshotGroups(namespace).Watch(context.TODO(), options) }, }, - &snapshotgroupv1beta1.SnapshotGroup{}, + &snapshotgroupv1.SnapshotGroup{}, resyncPeriod, indexers, ) @@ -82,9 +82,9 @@ func (f *snapshotGroupInformer) defaultInformer(client versioned.Interface, resy } func (f *snapshotGroupInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&snapshotgroupv1beta1.SnapshotGroup{}, f.defaultInformer) + return f.factory.InformerFor(&snapshotgroupv1.SnapshotGroup{}, f.defaultInformer) } -func (f *snapshotGroupInformer) Lister() v1beta1.SnapshotGroupLister { - return v1beta1.NewSnapshotGroupLister(f.Informer().GetIndexer()) +func (f *snapshotGroupInformer) Lister() v1.SnapshotGroupLister { + return v1.NewSnapshotGroupLister(f.Informer().GetIndexer()) } diff --git a/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/expansion_generated.go b/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/expansion_generated.go similarity index 98% rename from pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/expansion_generated.go rename to pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/expansion_generated.go index 9cfc8d7..3b4aeb2 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/expansion_generated.go +++ b/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/expansion_generated.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1beta1 +package v1 // SnapshotGroupListerExpansion allows custom methods to be added to // SnapshotGroupLister. diff --git a/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/snapshotgroup.go b/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/snapshotgroup.go similarity index 81% rename from pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/snapshotgroup.go rename to pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/snapshotgroup.go index f7d7838..8a1921b 100644 --- a/pkg/types/snapshotgroup/v1beta1/apis/listers/snapshotgroup/v1beta1/snapshotgroup.go +++ b/pkg/types/snapshotgroup/v1/apis/listers/snapshotgroup/v1/snapshotgroup.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( - v1beta1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1beta1" + v1 "github.com/fairwindsops/gemini/pkg/types/snapshotgroup/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -30,7 +30,7 @@ import ( type SnapshotGroupLister interface { // List lists all SnapshotGroups in the indexer. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.SnapshotGroup, err error) + List(selector labels.Selector) (ret []*v1.SnapshotGroup, err error) // SnapshotGroups returns an object that can list and get SnapshotGroups. SnapshotGroups(namespace string) SnapshotGroupNamespaceLister SnapshotGroupListerExpansion @@ -47,9 +47,9 @@ func NewSnapshotGroupLister(indexer cache.Indexer) SnapshotGroupLister { } // List lists all SnapshotGroups in the indexer. -func (s *snapshotGroupLister) List(selector labels.Selector) (ret []*v1beta1.SnapshotGroup, err error) { +func (s *snapshotGroupLister) List(selector labels.Selector) (ret []*v1.SnapshotGroup, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.SnapshotGroup)) + ret = append(ret, m.(*v1.SnapshotGroup)) }) return ret, err } @@ -64,10 +64,10 @@ func (s *snapshotGroupLister) SnapshotGroups(namespace string) SnapshotGroupName type SnapshotGroupNamespaceLister interface { // List lists all SnapshotGroups in the indexer for a given namespace. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.SnapshotGroup, err error) + List(selector labels.Selector) (ret []*v1.SnapshotGroup, err error) // Get retrieves the SnapshotGroup from the indexer for a given namespace and name. // Objects returned here must be treated as read-only. - Get(name string) (*v1beta1.SnapshotGroup, error) + Get(name string) (*v1.SnapshotGroup, error) SnapshotGroupNamespaceListerExpansion } @@ -79,21 +79,21 @@ type snapshotGroupNamespaceLister struct { } // List lists all SnapshotGroups in the indexer for a given namespace. -func (s snapshotGroupNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.SnapshotGroup, err error) { +func (s snapshotGroupNamespaceLister) List(selector labels.Selector) (ret []*v1.SnapshotGroup, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.SnapshotGroup)) + ret = append(ret, m.(*v1.SnapshotGroup)) }) return ret, err } // Get retrieves the SnapshotGroup from the indexer for a given namespace and name. -func (s snapshotGroupNamespaceLister) Get(name string) (*v1beta1.SnapshotGroup, error) { +func (s snapshotGroupNamespaceLister) Get(name string) (*v1.SnapshotGroup, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("snapshotgroup"), name) + return nil, errors.NewNotFound(v1.Resource("snapshotgroup"), name) } - return obj.(*v1beta1.SnapshotGroup), nil + return obj.(*v1.SnapshotGroup), nil } diff --git a/pkg/types/snapshotgroup/v1/crd-with-beta1.yaml b/pkg/types/snapshotgroup/v1/crd-with-beta1.yaml new file mode 100644 index 0000000..af66394 --- /dev/null +++ b/pkg/types/snapshotgroup/v1/crd-with-beta1.yaml @@ -0,0 +1,129 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: snapshotgroups.gemini.fairwinds.com +spec: + group: gemini.fairwinds.com + names: + plural: snapshotgroups + singular: snapshotgroup + kind: SnapshotGroup + listKind: SnapshotGroupList + scope: Namespaced + conversion: + strategy: None + versions: + - name: v1beta1 + served: true + storage: false + schema: + openAPIV3Schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: + spec: + type: object + properties: + persistentVolumeClaim: + type: object + properties: + claimName: + description: PersistentVolumeClaim name to backup + type: string + spec: + description: PersistentVolumeClaim spec to create and backup + type: object + schedule: + type: array + items: + type: object + properties: + every: + description: Interval for creating new backups + type: string + keep: + description: Number of historical backups to keep + type: integer + template: + type: object + properties: + spec: + description: VolumeSnapshot spec + type: object + properties: + volumeSnapshotClassName: + description: 'VolumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. VolumeSnapshotClassName may be left nil to indicate that the default SnapshotClass should be used. A given cluster may have multiple default Volume SnapshotClasses: one default per CSI Driver. If a VolumeSnapshot does not specify a SnapshotClass, VolumeSnapshotSource will be checked to figure out what the associated CSI Driver is, and the default VolumeSnapshotClass associated with that CSI Driver will be used. If more than one VolumeSnapshotClass exist for a given CSI Driver and more than one have been marked as default, CreateSnapshot will fail and generate an event. Empty string is not allowed for this field.' + type: string + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: + spec: + type: object + properties: + persistentVolumeClaim: + type: object + properties: + claimName: + description: PersistentVolumeClaim name to backup + type: string + spec: + description: PersistentVolumeClaim spec to create and backup + type: object + properties: + storageClassName: + type: string + accessModes: + type: array + items: + type: string + volumeName: + type: string + resources: + type: object + properties: + requests: + type: object + additionalProperties: true + limits: + type: object + properties: + storageClassName: + type: string + additionalProperties: true + selector: + type: object + properties: + matchLabels: + type: object + additionalProperties: true + matchExpressions: + type: array + items: + type: object + additionalProperties: true + schedule: + type: array + items: + type: object + properties: + every: + description: Interval for creating new backups + type: string + keep: + description: Number of historical backups to keep + type: integer + template: + type: object + properties: + spec: + description: VolumeSnapshot spec + type: object + properties: + volumeSnapshotClassName: + description: 'VolumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. VolumeSnapshotClassName may be left nil to indicate that the default SnapshotClass should be used. A given cluster may have multiple default Volume SnapshotClasses: one default per CSI Driver. If a VolumeSnapshot does not specify a SnapshotClass, VolumeSnapshotSource will be checked to figure out what the associated CSI Driver is, and the default VolumeSnapshotClass associated with that CSI Driver will be used. If more than one VolumeSnapshotClass exist for a given CSI Driver and more than one have been marked as default, CreateSnapshot will fail and generate an event. Empty string is not allowed for this field.' + type: string diff --git a/pkg/types/snapshotgroup/v1/crd.go b/pkg/types/snapshotgroup/v1/crd.go new file mode 100644 index 0000000..7c01353 --- /dev/null +++ b/pkg/types/snapshotgroup/v1/crd.go @@ -0,0 +1,91 @@ +package v1 + +import ( + "os" + "context" + "fmt" + "time" + _ "embed" + + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "gopkg.in/yaml.v2" + "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apimachinery/pkg/util/wait" +) + +//go:embed crd.yaml +var crdYAML string + +//go:embed crd-with-beta1.yaml +var crdWithBeta1YAML string + +// CreateCustomResourceDefinition creates the CRD and add it into Kubernetes. If there is error, +// it will do some clean up. +func CreateCustomResourceDefinition(namespace string, clientSet apiextensionsclientset.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { + crd := &apiextensionsv1.CustomResourceDefinition{} + yamlToParse := crdYAML + if os.Getenv("INCLUDE_GEMINI_BETA_CRD") != "" { + yamlToParse = crdWithBeta1YAML + } + fmt.Println("CRD yaml", yamlToParse) + err := yaml.Unmarshal([]byte(yamlToParse), crd) + if err != nil { + return nil, err + } + fmt.Printf("Parsed CRD: %#v", crd) + + _, err = clientSet.ApiextensionsV1().CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{}) + if err == nil { + fmt.Println("CRD SnapshotGroup is created") + } else if apierrors.IsAlreadyExists(err) { + fmt.Println("CRD SnapshotGroup already exists, trying update") + _, err = clientSet.ApiextensionsV1().CustomResourceDefinitions().Update(context.TODO(), crd, metav1.UpdateOptions{}) + } + if err != nil { + fmt.Printf("Failed to create CRD SnapshotGroup: %+v\n", err) + return nil, err + } + + // Wait for CRD creation. + err = wait.Poll(5*time.Second, 60*time.Second, func() (bool, error) { + crd, err = clientSet.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), CRDName, metav1.GetOptions{}) + if err != nil { + fmt.Printf("Fail to wait for CRD SnapshotGroup creation: %+v\n", err) + + return false, err + } + for _, cond := range crd.Status.Conditions { + switch cond.Type { + case apiextensionsv1.Established: + if cond.Status == apiextensionsv1.ConditionTrue { + return true, err + } + case apiextensionsv1.NamesAccepted: + if cond.Status == apiextensionsv1.ConditionFalse { + fmt.Printf("Name conflict while wait for CRD SnapshotGroup creation: %s, %+v\n", cond.Reason, err) + } + } + } + + return false, err + }) + + // If there is an error, delete the object to keep it clean. + if err != nil { + fmt.Println("Try to cleanup") + deleteErr := clientSet.ApiextensionsV1().CustomResourceDefinitions().Delete(context.TODO(), CRDName, metav1.DeleteOptions{}) + if deleteErr != nil { + fmt.Printf("Fail to delete CRD SnapshotGroup: %+v\n", deleteErr) + + return nil, errors.NewAggregate([]error{err, deleteErr}) + } + + return nil, err + } + + return crd, nil +} diff --git a/pkg/types/snapshotgroup/v1/crd.yaml b/pkg/types/snapshotgroup/v1/crd.yaml new file mode 100644 index 0000000..f78ce0b --- /dev/null +++ b/pkg/types/snapshotgroup/v1/crd.yaml @@ -0,0 +1,88 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: snapshotgroups.gemini.fairwinds.com +spec: + group: gemini.fairwinds.com + names: + plural: snapshotgroups + singular: snapshotgroup + kind: SnapshotGroup + listKind: SnapshotGroupList + scope: Namespaced + versions: + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: + spec: + type: object + properties: + persistentVolumeClaim: + type: object + properties: + claimName: + description: PersistentVolumeClaim name to backup + type: string + spec: + description: PersistentVolumeClaim spec to create and backup + type: object + properties: + storageClassName: + type: string + accessModes: + type: array + items: + type: string + volumeName: + type: string + resources: + type: object + properties: + requests: + type: object + additionalProperties: true + limits: + type: object + properties: + storageClassName: + type: string + additionalProperties: true + selector: + type: object + properties: + matchLabels: + type: object + additionalProperties: true + matchExpressions: + type: array + items: + type: object + additionalProperties: true + schedule: + type: array + items: + type: object + properties: + every: + description: Interval for creating new backups + type: string + keep: + description: Number of historical backups to keep + type: integer + template: + type: object + properties: + spec: + description: VolumeSnapshot spec + type: object + properties: + volumeSnapshotClassName: + description: 'VolumeSnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot. VolumeSnapshotClassName may be left nil to indicate that the default SnapshotClass should be used. A given cluster may have multiple default Volume SnapshotClasses: one default per CSI Driver. If a VolumeSnapshot does not specify a SnapshotClass, VolumeSnapshotSource will be checked to figure out what the associated CSI Driver is, and the default VolumeSnapshotClass associated with that CSI Driver will be used. If more than one VolumeSnapshotClass exist for a given CSI Driver and more than one have been marked as default, CreateSnapshot will fail and generate an event. Empty string is not allowed for this field.' + type: string + conversion: + strategy: None diff --git a/pkg/types/snapshotgroup/v1beta1/deepcopy.go b/pkg/types/snapshotgroup/v1/deepcopy.go similarity index 100% rename from pkg/types/snapshotgroup/v1beta1/deepcopy.go rename to pkg/types/snapshotgroup/v1/deepcopy.go diff --git a/pkg/types/snapshotgroup/v1beta1/register.go b/pkg/types/snapshotgroup/v1/register.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/register.go rename to pkg/types/snapshotgroup/v1/register.go index 50e8d1e..7bffcbb 100644 --- a/pkg/types/snapshotgroup/v1beta1/register.go +++ b/pkg/types/snapshotgroup/v1/register.go @@ -10,7 +10,7 @@ import ( const ( GroupName string = "gemini.fairwinds.com" Kind string = "SnapshotGroup" - GroupVersion string = "v1beta1" + GroupVersion string = "v1" Plural string = "snapshotgroups" Singular string = "snapshotgroup" CRDName string = Plural + "." + GroupName diff --git a/pkg/types/snapshotgroup/v1beta1/snapshotgroup.go b/pkg/types/snapshotgroup/v1/snapshotgroup.go similarity index 97% rename from pkg/types/snapshotgroup/v1beta1/snapshotgroup.go rename to pkg/types/snapshotgroup/v1/snapshotgroup.go index e30a9c8..9348dbd 100644 --- a/pkg/types/snapshotgroup/v1beta1/snapshotgroup.go +++ b/pkg/types/snapshotgroup/v1/snapshotgroup.go @@ -1,7 +1,7 @@ package v1 import ( - snapshotsv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1beta1" + snapshotsv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/types/snapshotgroup/v1beta1/crd.go b/pkg/types/snapshotgroup/v1beta1/crd.go deleted file mode 100644 index b186ed0..0000000 --- a/pkg/types/snapshotgroup/v1beta1/crd.go +++ /dev/null @@ -1,149 +0,0 @@ -package v1 - -import ( - "context" - "fmt" - "reflect" - "time" - - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "k8s.io/apimachinery/pkg/util/errors" - "k8s.io/apimachinery/pkg/util/wait" -) - -// CreateCustomResourceDefinition creates the CRD and add it into Kubernetes. If there is error, -// it will do some clean up. -func CreateCustomResourceDefinition(namespace string, clientSet apiextensionsclientset.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { - crdVersion := apiextensionsv1.CustomResourceDefinitionVersion{ - Name: GroupVersion, - Served: true, - Storage: true, - Deprecated: false, - DeprecationWarning: nil, - Schema: &apiextensionsv1.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensionsv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]apiextensionsv1.JSONSchemaProps{ - "spec": { - Type: "object", - Properties: map[string]apiextensionsv1.JSONSchemaProps{ - "persistentVolumeClaim": { - Type: "object", - Properties: map[string]apiextensionsv1.JSONSchemaProps{ - "claimName": { - Description: "PersistentVolumeClaim name to backup", - Type: "string", - }, - "spec": { - Description: "PersistentVolumeClaim spec to create and backup", - Type: "object", - }, - }, - }, - "schedule": { - Type: "array", - Items: &apiextensionsv1.JSONSchemaPropsOrArray{ - Schema: &apiextensionsv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]apiextensionsv1.JSONSchemaProps{ - "every": { - Description: "Interval for creating new backups", - Type: "string", - }, - "keep": { - Description: "Number of historical backups to keep", - Type: "integer", - }, - }, - }, - }, - }, - "template": { - Type: "object", - Properties: map[string]apiextensionsv1.JSONSchemaProps{ - "spec": { - Description: "VolumeSnapshot spec", - Type: "object", - }, - }, - }, - }, - }, - }, - }, - }, - Subresources: nil, - AdditionalPrinterColumns: nil, - } - - crd := &apiextensionsv1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: CRDName, - Namespace: namespace, - }, - Spec: apiextensionsv1.CustomResourceDefinitionSpec{ - Group: GroupName, - Names: apiextensionsv1.CustomResourceDefinitionNames{ - Plural: Plural, - Kind: reflect.TypeOf(SnapshotGroup{}).Name(), - }, - Scope: apiextensionsv1.NamespaceScoped, - Versions: []apiextensionsv1.CustomResourceDefinitionVersion{crdVersion}, - PreserveUnknownFields: false, - }, - } - - _, err := clientSet.ApiextensionsV1().CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{}) - if err == nil { - fmt.Println("CRD SnapshotGroup is created") - } else if apierrors.IsAlreadyExists(err) { - fmt.Println("CRD SnapshotGroup already exists") - } else { - fmt.Printf("Fail to create CRD SnapshotGroup: %+v\n", err) - - return nil, err - } - - // Wait for CRD creation. - err = wait.Poll(5*time.Second, 60*time.Second, func() (bool, error) { - crd, err = clientSet.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), CRDName, metav1.GetOptions{}) - if err != nil { - fmt.Printf("Fail to wait for CRD SnapshotGroup creation: %+v\n", err) - - return false, err - } - for _, cond := range crd.Status.Conditions { - switch cond.Type { - case apiextensionsv1.Established: - if cond.Status == apiextensionsv1.ConditionTrue { - return true, err - } - case apiextensionsv1.NamesAccepted: - if cond.Status == apiextensionsv1.ConditionFalse { - fmt.Printf("Name conflict while wait for CRD SnapshotGroup creation: %s, %+v\n", cond.Reason, err) - } - } - } - - return false, err - }) - - // If there is an error, delete the object to keep it clean. - if err != nil { - fmt.Println("Try to cleanup") - deleteErr := clientSet.ApiextensionsV1().CustomResourceDefinitions().Delete(context.TODO(), CRDName, metav1.DeleteOptions{}) - if deleteErr != nil { - fmt.Printf("Fail to delete CRD SnapshotGroup: %+v\n", deleteErr) - - return nil, errors.NewAggregate([]error{err, deleteErr}) - } - - return nil, err - } - - return crd, nil -}