From 9f89842463a499cc641104d3d753837666c76f35 Mon Sep 17 00:00:00 2001 From: Yang Le Date: Wed, 22 Sep 2021 09:55:22 +0800 Subject: [PATCH] create migration requests for clusterset api Signed-off-by: Yang Le --- .../config/rbac/cluster_role.yaml | 4 + ...cluster-manager.clusterserviceversion.yaml | 12 + go.mod | 1 + go.sum | 1 + ...r-managedclustersetbindings-migration.yaml | 9 + ...-manager-managedclustersets-migration.yaml | 9 + .../migration_controller.go | 247 ++++++++++++++++ .../migration_controller_test.go | 185 ++++++++++++ pkg/operators/manager.go | 13 + vendor/modules.txt | 8 + .../kube-storage-version-migrator/LICENSE | 202 +++++++++++++ .../pkg/apis/migration/v1alpha1/doc.go | 20 ++ .../pkg/apis/migration/v1alpha1/register.go | 54 ++++ .../pkg/apis/migration/v1alpha1/types.go | 187 ++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 275 ++++++++++++++++++ .../pkg/clients/clientset/clientset.go | 97 ++++++ .../pkg/clients/clientset/doc.go | 20 ++ .../clientset/fake/clientset_generated.go | 82 ++++++ .../pkg/clients/clientset/fake/doc.go | 20 ++ .../pkg/clients/clientset/fake/register.go | 56 ++++ .../pkg/clients/clientset/scheme/doc.go | 20 ++ .../pkg/clients/clientset/scheme/register.go | 56 ++++ .../clientset/typed/migration/v1alpha1/doc.go | 20 ++ .../typed/migration/v1alpha1/fake/doc.go | 20 ++ .../v1alpha1/fake/fake_migration_client.go | 44 +++ .../v1alpha1/fake/fake_storagestate.go | 133 +++++++++ .../fake/fake_storageversionmigration.go | 133 +++++++++ .../migration/v1alpha1/generated_expansion.go | 23 ++ .../migration/v1alpha1/migration_client.go | 94 ++++++ .../typed/migration/v1alpha1/storagestate.go | 184 ++++++++++++ .../v1alpha1/storageversionmigration.go | 184 ++++++++++++ 31 files changed, 2413 insertions(+) create mode 100644 manifests/cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml create mode 100644 manifests/cluster-manager/cluster-manager-managedclustersets-migration.yaml create mode 100644 pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller.go create mode 100644 pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller_test.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/LICENSE create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/register.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/types.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/clientset.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/clientset_generated.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/register.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/register.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/doc.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_migration_client.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storagestate.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storageversionmigration.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/generated_expansion.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/migration_client.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storagestate.go create mode 100644 vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storageversionmigration.go diff --git a/deploy/cluster-manager/config/rbac/cluster_role.yaml b/deploy/cluster-manager/config/rbac/cluster_role.yaml index 9824f89c7..9acde2246 100644 --- a/deploy/cluster-manager/config/rbac/cluster_role.yaml +++ b/deploy/cluster-manager/config/rbac/cluster_role.yaml @@ -44,3 +44,7 @@ rules: - apiGroups: ["operator.open-cluster-management.io"] resources: ["clustermanagers/status"] verbs: ["update", "patch"] +# Allow the registration-operator to create storageversionmigration +- apiGroups: ["migration.k8s.io"] + resources: ["storageversionmigrations"] + verbs: ["create", "get", "list", "update", "watch", "patch", "delete"] diff --git a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml index 6788d8534..878241c80 100644 --- a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml +++ b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml @@ -212,6 +212,18 @@ spec: verbs: - update - patch + - apiGroups: + - migration.k8s.io + resources: + - storageversionmigrations + verbs: + - create + - get + - list + - update + - watch + - patch + - delete serviceAccountName: cluster-manager deployments: - name: cluster-manager diff --git a/go.mod b/go.mod index 2464198ee..3c7163922 100644 --- a/go.mod +++ b/go.mod @@ -22,4 +22,5 @@ require ( k8s.io/kube-aggregator v0.21.0-rc.0 open-cluster-management.io/api v0.0.0-20210916013819-2e58cdb938f9 sigs.k8s.io/controller-runtime v0.6.1-0.20200829232221-efc74d056b24 + sigs.k8s.io/kube-storage-version-migrator v0.0.3 ) diff --git a/go.sum b/go.sum index 73ce3cf71..2e549bb00 100644 --- a/go.sum +++ b/go.sum @@ -975,6 +975,7 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyz sigs.k8s.io/controller-runtime v0.6.1-0.20200829232221-efc74d056b24 h1:X8MP3ikt7leHqbSGyhcTV90nOx4aKU8Q/29PU7SIJOY= sigs.k8s.io/controller-runtime v0.6.1-0.20200829232221-efc74d056b24/go.mod h1:KbYIf6EpZz2+osbp4K0KGKhr5SyMJ8ZOBhjcv7MNqxI= sigs.k8s.io/controller-tools v0.2.8/go.mod h1:9VKHPszmf2DHz/QmHkcfZoewO6BL7pPs9uAiBVsaJSE= +sigs.k8s.io/kube-storage-version-migrator v0.0.3 h1:IclhkKtl1zwS7awsqsQuxrvXrP2VamhcWeZDzsEz6/Q= sigs.k8s.io/kube-storage-version-migrator v0.0.3/go.mod h1:mXfSLkx9xbJHQsgNDDUZK/iQTs2tMbx/hsJlWe6Fthw= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU= diff --git a/manifests/cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml b/manifests/cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml new file mode 100644 index 000000000..cd55894ee --- /dev/null +++ b/manifests/cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml @@ -0,0 +1,9 @@ +apiVersion: migration.k8s.io/v1alpha1 +kind: StorageVersionMigration +metadata: + name: managedclustersetbindings.cluster.open-cluster-management.io +spec: + resource: + group: cluster.open-cluster-management.io + resource: managedclustersetbindings + version: v1alpha1 diff --git a/manifests/cluster-manager/cluster-manager-managedclustersets-migration.yaml b/manifests/cluster-manager/cluster-manager-managedclustersets-migration.yaml new file mode 100644 index 000000000..741a68951 --- /dev/null +++ b/manifests/cluster-manager/cluster-manager-managedclustersets-migration.yaml @@ -0,0 +1,9 @@ +apiVersion: migration.k8s.io/v1alpha1 +kind: StorageVersionMigration +metadata: + name: managedclustersets.cluster.open-cluster-management.io +spec: + resource: + group: cluster.open-cluster-management.io + resource: managedclustersets + version: v1alpha1 diff --git a/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller.go b/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller.go new file mode 100644 index 000000000..78d311e8f --- /dev/null +++ b/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller.go @@ -0,0 +1,247 @@ +package migrationcontroller + +import ( + "context" + "fmt" + "time" + + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/runtime/serializer" + "k8s.io/klog/v2" + + "github.com/openshift/library-go/pkg/assets" + "github.com/openshift/library-go/pkg/controller/factory" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/resource/resourceapply" + "github.com/openshift/library-go/pkg/operator/resource/resourcehelper" + "github.com/openshift/library-go/pkg/operator/resource/resourcemerge" + operatorhelpers "github.com/openshift/library-go/pkg/operator/v1helpers" + apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" + migrationv1alpha1client "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1" + + operatorinformer "open-cluster-management.io/api/client/operator/informers/externalversions/operator/v1" + operatorlister "open-cluster-management.io/api/client/operator/listers/operator/v1" + "open-cluster-management.io/registration-operator/manifests" +) + +var ( + genericScheme = runtime.NewScheme() + genericCodecs = serializer.NewCodecFactory(genericScheme) + genericCodec = genericCodecs.UniversalDeserializer() + + _ = migrationv1alpha1.AddToScheme(genericScheme) + + migrationRequestFiles = []string{ + "cluster-manager/cluster-manager-managedclustersets-migration.yaml", + "cluster-manager/cluster-manager-managedclustersetbindings-migration.yaml", + } +) + +const ( + clusterManagerApplied = "Applied" + migrationRequestCRDName = "storageversionmigrations.migration.k8s.io" +) + +type crdMigrationController struct { + clusterManagerLister operatorlister.ClusterManagerLister + apiExtensionClient apiextensionsclient.Interface + migrationClient migrationv1alpha1client.StorageVersionMigrationsGetter +} + +// NewClusterManagerController construct cluster manager hub controller +func NewCRDMigrationController( + apiExtensionClient apiextensionsclient.Interface, + migrationClient migrationv1alpha1client.StorageVersionMigrationsGetter, + clusterManagerInformer operatorinformer.ClusterManagerInformer, + recorder events.Recorder) factory.Controller { + controller := &crdMigrationController{ + apiExtensionClient: apiExtensionClient, + migrationClient: migrationClient, + clusterManagerLister: clusterManagerInformer.Lister(), + } + + return factory.New().WithSync(controller.sync). + WithInformersQueueKeyFunc(func(obj runtime.Object) string { + accessor, _ := meta.Accessor(obj) + return accessor.GetName() + }, clusterManagerInformer.Informer()). + ToController("CRDMigrationController", recorder) +} + +func (c *crdMigrationController) sync(ctx context.Context, controllerContext factory.SyncContext) error { + clusterManagerName := controllerContext.QueueKey() + klog.V(4).Infof("Reconciling ClusterManager %q", clusterManagerName) + + clusterManager, err := c.clusterManagerLister.Get(clusterManagerName) + if errors.IsNotFound(err) { + // ClusterManager not found, could have been deleted, do nothing. + return nil + } + if err != nil { + return err + } + + // apply storage version migrations if it is supported + supported, err := c.supportStorageVersionMigration(ctx) + if err != nil { + return err + } + if !supported { + return nil + } + + // ClusterManager is deleting, we remove its related resources on hub + if !clusterManager.DeletionTimestamp.IsZero() { + return c.removeStorageVersionMigrations(ctx) + } + + // do not apply storage version migrations until other resources are applied + if applied := meta.IsStatusConditionTrue(clusterManager.Status.Conditions, clusterManagerApplied); !applied { + controllerContext.Queue().AddAfter(clusterManagerName, 5*time.Second) + return nil + } + + return c.applyStorageVersionMigrations(ctx, controllerContext.Recorder()) +} + +// supportStorageVersionMigration returns ture if StorageVersionMigration CRD exists; otherwise returns false. +func (c *crdMigrationController) supportStorageVersionMigration(ctx context.Context) (bool, error) { + _, err := c.apiExtensionClient.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, migrationRequestCRDName, metav1.GetOptions{}) + if errors.IsNotFound(err) { + return false, nil + } + if err != nil { + return false, err + } + return true, nil +} + +func (c *crdMigrationController) removeStorageVersionMigrations( + ctx context.Context) error { + // Reomve storage version migrations + for _, file := range migrationRequestFiles { + err := removeStorageVersionMigration( + ctx, + c.migrationClient, + func(name string) ([]byte, error) { + template, err := manifests.ClusterManagerManifestFiles.ReadFile(name) + if err != nil { + return nil, err + } + return assets.MustCreateAssetFromTemplate(name, template, struct{}{}).Data, nil + }, + file, + ) + if err != nil { + return err + } + } + return nil +} + +func (c *crdMigrationController) applyStorageVersionMigrations(ctx context.Context, recorder events.Recorder) error { + errs := []error{} + for _, file := range migrationRequestFiles { + _, _, err := applyStorageVersionMigration( + c.migrationClient, + func(name string) ([]byte, error) { + template, err := manifests.ClusterManagerManifestFiles.ReadFile(name) + if err != nil { + return nil, err + } + return assets.MustCreateAssetFromTemplate(name, template, struct{}{}).Data, nil + }, + recorder, + file) + if err != nil { + errs = append(errs, err) + } + } + + return operatorhelpers.NewMultiLineAggregate(errs) +} + +func removeStorageVersionMigration( + ctx context.Context, + migrationClient migrationv1alpha1client.StorageVersionMigrationsGetter, + manifests resourceapply.AssetFunc, + file string) error { + objectRaw, err := manifests(file) + if err != nil { + return err + } + object, _, err := genericCodec.Decode(objectRaw, nil, nil) + if err != nil { + return err + } + + required, ok := object.(*migrationv1alpha1.StorageVersionMigration) + if !ok { + return fmt.Errorf("invalid StorageVersionMigration in file %q: %v", file, object) + } + + err = migrationClient.StorageVersionMigrations().Delete(ctx, required.Name, metav1.DeleteOptions{}) + if errors.IsNotFound(err) { + return nil + } + return err +} + +func applyStorageVersionMigration( + client migrationv1alpha1client.StorageVersionMigrationsGetter, + manifests resourceapply.AssetFunc, + recorder events.Recorder, + file string) (*migrationv1alpha1.StorageVersionMigration, bool, error) { + objBytes, err := manifests(file) + if err != nil { + return nil, false, fmt.Errorf("missing %q: %v", file, err) + } + requiredObj, _, err := genericCodec.Decode(objBytes, nil, nil) + if err != nil { + return nil, false, fmt.Errorf("cannot decode %q: %v", file, err) + } + + required, ok := requiredObj.(*migrationv1alpha1.StorageVersionMigration) + if !ok { + return nil, false, fmt.Errorf("invalid StorageVersionMigration in file %q: %v", file, requiredObj) + } + + existing, err := client.StorageVersionMigrations().Get(context.TODO(), required.Name, metav1.GetOptions{}) + if errors.IsNotFound(err) { + actual, err := client.StorageVersionMigrations().Create(context.TODO(), required, metav1.CreateOptions{}) + if err != nil { + recorder.Warningf("StorageVersionMigrationCreateFailed", "Failed to create %s: %v", resourcehelper.FormatResourceForCLIWithNamespace(required), err) + return actual, true, err + } + + recorder.Eventf("StorageVersionMigrationCreated", "Created %s because it was missing", resourcehelper.FormatResourceForCLIWithNamespace(actual)) + return actual, true, err + } + if err != nil { + return nil, false, err + } + + modified := resourcemerge.BoolPtr(false) + existingCopy := existing.DeepCopy() + resourcemerge.EnsureObjectMeta(modified, &existingCopy.ObjectMeta, required.ObjectMeta) + if !equality.Semantic.DeepEqual(existingCopy.Spec, required.Spec) { + *modified = true + existing.Spec = required.Spec + } + if !*modified { + return existing, false, nil + } + + actual, err := client.StorageVersionMigrations().Update(context.TODO(), existingCopy, metav1.UpdateOptions{}) + if err != nil { + recorder.Warningf("StorageVersionMigrationUpdateFailed", "Failed to update %s: %v", resourcehelper.FormatResourceForCLIWithNamespace(existingCopy), err) + return actual, true, err + } + recorder.Eventf("StorageVersionMigrationUpdated", "Updated %s because it changed", resourcehelper.FormatResourceForCLIWithNamespace(actual)) + return actual, true, nil +} diff --git a/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller_test.go b/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller_test.go new file mode 100644 index 000000000..a9def67ab --- /dev/null +++ b/pkg/operators/clustermanager/controllers/migrationcontroller/migration_controller_test.go @@ -0,0 +1,185 @@ +package migrationcontroller + +import ( + "context" + "testing" + + "github.com/openshift/library-go/pkg/operator/events/eventstesting" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + fakeapiextensions "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + clienttesting "k8s.io/client-go/testing" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" + fakemigrationclient "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake" +) + +func TestSupportStorageVersionMigration(t *testing.T) { + cases := []struct { + name string + existingObjects []runtime.Object + supported bool + }{ + { + name: "not support", + supported: false, + }, + { + name: "support", + existingObjects: []runtime.Object{ + &apiextensionsv1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{ + Name: migrationRequestCRDName, + }, + }, + }, + supported: true, + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + fakeAPIExtensionClient := fakeapiextensions.NewSimpleClientset(c.existingObjects...) + controller := crdMigrationController{ + apiExtensionClient: fakeAPIExtensionClient, + } + + actual, err := controller.supportStorageVersionMigration(context.TODO()) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if actual != c.supported { + t.Fatalf("expected %v but got %v", c.supported, actual) + } + }) + } +} + +func TestApplyStorageVersionMigrations(t *testing.T) { + cases := []struct { + name string + existingObjects []runtime.Object + validateActions func(t *testing.T, actions []clienttesting.Action) + }{ + { + name: "created", + validateActions: func(t *testing.T, actions []clienttesting.Action) { + assertActions(t, actions, "get", "create", "get", "create") + actual := actions[1].(clienttesting.CreateActionImpl).Object + assertStorageVersionMigration(t, "managedclustersets.cluster.open-cluster-management.io", actual) + actual = actions[3].(clienttesting.CreateActionImpl).Object + assertStorageVersionMigration(t, "managedclustersetbindings.cluster.open-cluster-management.io", actual) + }, + }, + { + name: "created and updated", + existingObjects: []runtime.Object{ + &migrationv1alpha1.StorageVersionMigration{ + ObjectMeta: metav1.ObjectMeta{ + Name: "managedclustersetbindings.cluster.open-cluster-management.io", + }, + }, + }, + validateActions: func(t *testing.T, actions []clienttesting.Action) { + assertActions(t, actions, "get", "create", "get", "update") + actual := actions[1].(clienttesting.CreateActionImpl).Object + assertStorageVersionMigration(t, "managedclustersets.cluster.open-cluster-management.io", actual) + actual = actions[3].(clienttesting.UpdateActionImpl).Object + assertStorageVersionMigration(t, "managedclustersetbindings.cluster.open-cluster-management.io", actual) + }, + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + fakeMigrationClient := fakemigrationclient.NewSimpleClientset(c.existingObjects...) + controller := crdMigrationController{ + migrationClient: fakeMigrationClient.MigrationV1alpha1(), + } + + err := controller.applyStorageVersionMigrations(context.TODO(), eventstesting.NewTestingEventRecorder(t)) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + c.validateActions(t, fakeMigrationClient.Actions()) + }) + } +} + +func TestRemoveStorageVersionMigrations(t *testing.T) { + names := []string{ + "managedclustersets.cluster.open-cluster-management.io", + "managedclustersetbindings.cluster.open-cluster-management.io", + } + cases := []struct { + name string + existingObjects []runtime.Object + validateActions func(t *testing.T, actions []clienttesting.Action) + }{ + { + name: "not exists", + }, + { + name: "removed", + existingObjects: []runtime.Object{ + &migrationv1alpha1.StorageVersionMigration{ + ObjectMeta: metav1.ObjectMeta{ + Name: "managedclustersetbindings.cluster.open-cluster-management.io", + }, + }, + }, + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + fakeMigrationClient := fakemigrationclient.NewSimpleClientset(c.existingObjects...) + controller := crdMigrationController{ + migrationClient: fakeMigrationClient.MigrationV1alpha1(), + } + + err := controller.applyStorageVersionMigrations(context.TODO(), eventstesting.NewTestingEventRecorder(t)) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + for _, name := range names { + _, err := fakeMigrationClient.MigrationV1alpha1().StorageVersionMigrations().Get(context.TODO(), name, metav1.GetOptions{}) + if errors.IsNotFound(err) { + continue + } + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + } + }) + } +} + +func assertActions(t *testing.T, actualActions []clienttesting.Action, expectedVerbs ...string) { + if len(actualActions) != len(expectedVerbs) { + t.Fatalf("expected %d call but got: %#v", len(expectedVerbs), actualActions) + } + for i, expected := range expectedVerbs { + if actualActions[i].GetVerb() != expected { + t.Errorf("expected %s action but got: %#v", expected, actualActions[i]) + } + } +} + +// AssertNoActions asserts no actions are happened +func assertNoActions(t *testing.T, actualActions []clienttesting.Action) { + assertActions(t, actualActions) +} + +func assertStorageVersionMigration(t *testing.T, name string, object runtime.Object) { + migration, ok := object.(*migrationv1alpha1.StorageVersionMigration) + if !ok { + t.Errorf("expected migration request, but got %v", object) + } + + if migration.Name != name { + t.Errorf("expected migration name %q but got %q", name, migration.Name) + } +} diff --git a/pkg/operators/manager.go b/pkg/operators/manager.go index d9af50cb5..0ec27e6a1 100644 --- a/pkg/operators/manager.go +++ b/pkg/operators/manager.go @@ -10,6 +10,7 @@ import ( "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset" + migrationclient "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset" "github.com/openshift/library-go/pkg/controller/controllercmd" @@ -19,6 +20,7 @@ import ( "open-cluster-management.io/registration-operator/pkg/helpers" certrotationcontroller "open-cluster-management.io/registration-operator/pkg/operators/clustermanager/controllers/certrotationcontroller" "open-cluster-management.io/registration-operator/pkg/operators/clustermanager/controllers/clustermanagercontroller" + "open-cluster-management.io/registration-operator/pkg/operators/clustermanager/controllers/migrationcontroller" clustermanagerstatuscontroller "open-cluster-management.io/registration-operator/pkg/operators/clustermanager/controllers/statuscontroller" "open-cluster-management.io/registration-operator/pkg/operators/klusterlet/controllers/bootstrapcontroller" "open-cluster-management.io/registration-operator/pkg/operators/klusterlet/controllers/klusterletcontroller" @@ -43,6 +45,10 @@ func RunClusterManagerOperator(ctx context.Context, controllerContext *controlle if err != nil { return err } + migrationClient, err := migrationclient.NewForConfig(controllerContext.KubeConfig) + if err != nil { + return err + } kubeInformer := informers.NewSharedInformerFactoryWithOptions(kubeClient, 5*time.Minute, informers.WithNamespace(helpers.ClusterManagerNamespace)) @@ -76,11 +82,18 @@ func RunClusterManagerOperator(ctx context.Context, controllerContext *controlle operatorInformer.Operator().V1().ClusterManagers(), controllerContext.EventRecorder) + crdMigrationController := migrationcontroller.NewCRDMigrationController( + apiExtensionClient, + migrationClient.MigrationV1alpha1(), + operatorInformer.Operator().V1().ClusterManagers(), + controllerContext.EventRecorder) + go operatorInformer.Start(ctx.Done()) go kubeInformer.Start(ctx.Done()) go clusterManagerController.Run(ctx, 1) go statusController.Run(ctx, 1) go certRotationController.Run(ctx, 1) + go crdMigrationController.Run(ctx, 1) <-ctx.Done() return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 84e939cfd..272490912 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1025,6 +1025,14 @@ sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal sigs.k8s.io/controller-runtime/pkg/log sigs.k8s.io/controller-runtime/pkg/log/zap +# sigs.k8s.io/kube-storage-version-migrator v0.0.3 +## explicit +sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1 +sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset +sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake +sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme +sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1 +sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake # sigs.k8s.io/structured-merge-diff/v4 v4.1.0 sigs.k8s.io/structured-merge-diff/v4/fieldpath sigs.k8s.io/structured-merge-diff/v4/merge diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/LICENSE b/vendor/sigs.k8s.io/kube-storage-version-migrator/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/doc.go new file mode 100644 index 000000000..da6d19a24 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package + +// +groupName=migration.k8s.io +package v1alpha1 diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/register.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/register.go new file mode 100644 index 000000000..f400f747e --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/register.go @@ -0,0 +1,54 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "migration.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &StorageVersionMigration{}, + &StorageVersionMigrationList{}, + &StorageState{}, + &StorageStateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/types.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/types.go new file mode 100644 index 000000000..dde42a5b3 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/types.go @@ -0,0 +1,187 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient:nonNamespaced + +// StorageVersionMigration represents a migration of stored data to the latest +// storage version. +type StorageVersionMigration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // Specification of the migration. + // +optional + Spec StorageVersionMigrationSpec `json:"spec,omitempty"` + // Status of the migration. + // +optional + Status StorageVersionMigrationStatus `json:"status,omitempty"` +} + +// The names of the group, the version, and the resource. +type GroupVersionResource struct { + // The name of the group. + Group string `json:"group,omitempty"` + // The name of the version. + Version string `json:"version,omitempty"` + // The name of the resource. + Resource string `json:"resource,omitempty"` +} + +// Spec of the storage version migration. +type StorageVersionMigrationSpec struct { + // The resource that is being migrated. The migrator sends requests to + // the endpoint serving the resource. + // Immutable. + Resource GroupVersionResource `json:"resource"` + // The token used in the list options to get the next chunk of objects + // to migrate. When the .status.conditions indicates the migration is + // "Running", users can use this token to check the progress of the + // migration. + // +optional + ContinueToken string `json:"continueToken,omitempty"` + // TODO: consider recording the storage version hash when the migration + // is created. It can avoid races. +} + +type MigrationConditionType string + +const ( + // Indicates that the migration is running. + MigrationRunning MigrationConditionType = "Running" + // Indicates that the migration has completed successfully. + MigrationSucceeded MigrationConditionType = "Succeeded" + // Indicates that the migration has failed. + MigrationFailed MigrationConditionType = "Failed" +) + +// Describes the state of a migration at a certain point. +type MigrationCondition struct { + // Type of the condition. + Type MigrationConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + // The last time this condition was updated. + // +optional + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // The reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + // A human readable message indicating details about the transition. + // +optional + Message string `json:"message,omitempty"` +} + +// Status of the storage version migration. +type StorageVersionMigrationStatus struct { + // The latest available observations of the migration's current state. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + Conditions []MigrationCondition `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// StorageVersionMigrationList is a collection of storage version migrations. +type StorageVersionMigrationList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of StorageVersionMigration + Items []StorageVersionMigration `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient:nonNamespaced + +// The state of the storage of a specific resource. +type StorageState struct { + metav1.TypeMeta `json:",inline"` + // The name must be "<.spec.resource.resouce>.<.spec.resource.group>". + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // Specification of the storage state. + // +optional + Spec StorageStateSpec `json:"spec,omitempty"` + // Status of the storage state. + // +optional + Status StorageStateStatus `json:"status,omitempty"` +} + +// The names of the group and the resource. +type GroupResource struct { + // The name of the group. + Group string `json:"group,omitempty"` + // The name of the resource. + Resource string `json:"resource,omitempty"` +} + +// Specification of the storage state. +type StorageStateSpec struct { + // The resource this storageState is about. + Resource GroupResource `json:"resource,omitempty"` +} + +// Unknown is a valid value in persistedStorageVersionHashes. +const Unknown = "Unknown" + +// Status of the storage state. +type StorageStateStatus struct { + // The hash values of storage versions that persisted instances of + // spec.resource might still be encoded in. + // "Unknown" is a valid value in the list, and is the default value. + // It is not safe to upgrade or downgrade to an apiserver binary that does not + // support all versions listed in this field, or if "Unknown" is listed. + // Once the storage version migration for this resource has completed, the + // value of this field is refined to only contain the + // currentStorageVersionHash. + // Once the apiserver has changed the storage version, the new storage version + // is appended to the list. + // +optional + PersistedStorageVersionHashes []string `json:"persistedStorageVersionHashes,omitempty"` + // The hash value of the current storage version, as shown in the discovery + // document served by the API server. + // Storage Version is the version to which objects are converted to + // before persisted. + // +optional + CurrentStorageVersionHash string `json:"currentStorageVersionHash,omitempty"` + // LastHeartbeatTime is the last time the storage migration triggering + // controller checks the storage version hash of this resource in the + // discovery document and updates this field. + // +optional + LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// StorageStateList is a collection of storage state. +type StorageStateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + // Items is the list of StorageState + Items []StorageState `json:"items"` +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/zz_generated.deepcopy.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..5d6374d60 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,275 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupResource) DeepCopyInto(out *GroupResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupResource. +func (in *GroupResource) DeepCopy() *GroupResource { + if in == nil { + return nil + } + out := new(GroupResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupVersionResource) DeepCopyInto(out *GroupVersionResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupVersionResource. +func (in *GroupVersionResource) DeepCopy() *GroupVersionResource { + if in == nil { + return nil + } + out := new(GroupVersionResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MigrationCondition) DeepCopyInto(out *MigrationCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MigrationCondition. +func (in *MigrationCondition) DeepCopy() *MigrationCondition { + if in == nil { + return nil + } + out := new(MigrationCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageState) DeepCopyInto(out *StorageState) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageState. +func (in *StorageState) DeepCopy() *StorageState { + if in == nil { + return nil + } + out := new(StorageState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageState) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageStateList) DeepCopyInto(out *StorageStateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageState, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageStateList. +func (in *StorageStateList) DeepCopy() *StorageStateList { + if in == nil { + return nil + } + out := new(StorageStateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageStateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageStateSpec) DeepCopyInto(out *StorageStateSpec) { + *out = *in + out.Resource = in.Resource + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageStateSpec. +func (in *StorageStateSpec) DeepCopy() *StorageStateSpec { + if in == nil { + return nil + } + out := new(StorageStateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageStateStatus) DeepCopyInto(out *StorageStateStatus) { + *out = *in + if in.PersistedStorageVersionHashes != nil { + in, out := &in.PersistedStorageVersionHashes, &out.PersistedStorageVersionHashes + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.LastHeartbeatTime.DeepCopyInto(&out.LastHeartbeatTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageStateStatus. +func (in *StorageStateStatus) DeepCopy() *StorageStateStatus { + if in == nil { + return nil + } + out := new(StorageStateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionMigration) DeepCopyInto(out *StorageVersionMigration) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionMigration. +func (in *StorageVersionMigration) DeepCopy() *StorageVersionMigration { + if in == nil { + return nil + } + out := new(StorageVersionMigration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersionMigration) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionMigrationList) DeepCopyInto(out *StorageVersionMigrationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageVersionMigration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionMigrationList. +func (in *StorageVersionMigrationList) DeepCopy() *StorageVersionMigrationList { + if in == nil { + return nil + } + out := new(StorageVersionMigrationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersionMigrationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionMigrationSpec) DeepCopyInto(out *StorageVersionMigrationSpec) { + *out = *in + out.Resource = in.Resource + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionMigrationSpec. +func (in *StorageVersionMigrationSpec) DeepCopy() *StorageVersionMigrationSpec { + if in == nil { + return nil + } + out := new(StorageVersionMigrationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionMigrationStatus) DeepCopyInto(out *StorageVersionMigrationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]MigrationCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionMigrationStatus. +func (in *StorageVersionMigrationStatus) DeepCopy() *StorageVersionMigrationStatus { + if in == nil { + return nil + } + out := new(StorageVersionMigrationStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/clientset.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/clientset.go new file mode 100644 index 000000000..d8f4f36dd --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/clientset.go @@ -0,0 +1,97 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package clientset + +import ( + "fmt" + + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + MigrationV1alpha1() migrationv1alpha1.MigrationV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + migrationV1alpha1 *migrationv1alpha1.MigrationV1alpha1Client +} + +// MigrationV1alpha1 retrieves the MigrationV1alpha1Client +func (c *Clientset) MigrationV1alpha1() migrationv1alpha1.MigrationV1alpha1Interface { + return c.migrationV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.migrationV1alpha1, err = migrationv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.migrationV1alpha1 = migrationv1alpha1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.migrationV1alpha1 = migrationv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/doc.go new file mode 100644 index 000000000..ee865e56d --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package clientset diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/clientset_generated.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/clientset_generated.go new file mode 100644 index 000000000..f76843a2d --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/clientset_generated.go @@ -0,0 +1,82 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1" + fakemigrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var _ clientset.Interface = &Clientset{} + +// MigrationV1alpha1 retrieves the MigrationV1alpha1Client +func (c *Clientset) MigrationV1alpha1() migrationv1alpha1.MigrationV1alpha1Interface { + return &fakemigrationv1alpha1.FakeMigrationV1alpha1{Fake: &c.Fake} +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/doc.go new file mode 100644 index 000000000..9b99e7167 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/register.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/register.go new file mode 100644 index 000000000..a9d41977c --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + migrationv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/doc.go new file mode 100644 index 000000000..7dc375616 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/register.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/register.go new file mode 100644 index 000000000..93f2b6e2e --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + migrationv1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + migrationv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/doc.go new file mode 100644 index 000000000..df51baa4d --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/doc.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/doc.go new file mode 100644 index 000000000..16f443990 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_migration_client.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_migration_client.go new file mode 100644 index 000000000..fec401146 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_migration_client.go @@ -0,0 +1,44 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1" +) + +type FakeMigrationV1alpha1 struct { + *testing.Fake +} + +func (c *FakeMigrationV1alpha1) StorageStates() v1alpha1.StorageStateInterface { + return &FakeStorageStates{c} +} + +func (c *FakeMigrationV1alpha1) StorageVersionMigrations() v1alpha1.StorageVersionMigrationInterface { + return &FakeStorageVersionMigrations{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeMigrationV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storagestate.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storagestate.go new file mode 100644 index 000000000..c2830a31a --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storagestate.go @@ -0,0 +1,133 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "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" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" +) + +// FakeStorageStates implements StorageStateInterface +type FakeStorageStates struct { + Fake *FakeMigrationV1alpha1 +} + +var storagestatesResource = schema.GroupVersionResource{Group: "migration.k8s.io", Version: "v1alpha1", Resource: "storagestates"} + +var storagestatesKind = schema.GroupVersionKind{Group: "migration.k8s.io", Version: "v1alpha1", Kind: "StorageState"} + +// Get takes name of the storageState, and returns the corresponding storageState object, and an error if there is any. +func (c *FakeStorageStates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.StorageState, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(storagestatesResource, name), &v1alpha1.StorageState{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageState), err +} + +// List takes label and field selectors, and returns the list of StorageStates that match those selectors. +func (c *FakeStorageStates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageStateList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(storagestatesResource, storagestatesKind, opts), &v1alpha1.StorageStateList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.StorageStateList{ListMeta: obj.(*v1alpha1.StorageStateList).ListMeta} + for _, item := range obj.(*v1alpha1.StorageStateList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested storageStates. +func (c *FakeStorageStates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(storagestatesResource, opts)) +} + +// Create takes the representation of a storageState and creates it. Returns the server's representation of the storageState, and an error, if there is any. +func (c *FakeStorageStates) Create(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.CreateOptions) (result *v1alpha1.StorageState, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(storagestatesResource, storageState), &v1alpha1.StorageState{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageState), err +} + +// Update takes the representation of a storageState and updates it. Returns the server's representation of the storageState, and an error, if there is any. +func (c *FakeStorageStates) Update(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (result *v1alpha1.StorageState, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(storagestatesResource, storageState), &v1alpha1.StorageState{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageState), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeStorageStates) UpdateStatus(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (*v1alpha1.StorageState, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(storagestatesResource, "status", storageState), &v1alpha1.StorageState{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageState), err +} + +// Delete takes name of the storageState and deletes it. Returns an error if one occurs. +func (c *FakeStorageStates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(storagestatesResource, name), &v1alpha1.StorageState{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeStorageStates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(storagestatesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.StorageStateList{}) + return err +} + +// Patch applies the patch and returns the patched storageState. +func (c *FakeStorageStates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.StorageState, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(storagestatesResource, name, pt, data, subresources...), &v1alpha1.StorageState{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageState), err +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storageversionmigration.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storageversionmigration.go new file mode 100644 index 000000000..41fd7c390 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/fake/fake_storageversionmigration.go @@ -0,0 +1,133 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "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" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" +) + +// FakeStorageVersionMigrations implements StorageVersionMigrationInterface +type FakeStorageVersionMigrations struct { + Fake *FakeMigrationV1alpha1 +} + +var storageversionmigrationsResource = schema.GroupVersionResource{Group: "migration.k8s.io", Version: "v1alpha1", Resource: "storageversionmigrations"} + +var storageversionmigrationsKind = schema.GroupVersionKind{Group: "migration.k8s.io", Version: "v1alpha1", Kind: "StorageVersionMigration"} + +// Get takes name of the storageVersionMigration, and returns the corresponding storageVersionMigration object, and an error if there is any. +func (c *FakeStorageVersionMigrations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.StorageVersionMigration, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(storageversionmigrationsResource, name), &v1alpha1.StorageVersionMigration{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageVersionMigration), err +} + +// List takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors. +func (c *FakeStorageVersionMigrations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionMigrationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(storageversionmigrationsResource, storageversionmigrationsKind, opts), &v1alpha1.StorageVersionMigrationList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.StorageVersionMigrationList{ListMeta: obj.(*v1alpha1.StorageVersionMigrationList).ListMeta} + for _, item := range obj.(*v1alpha1.StorageVersionMigrationList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested storageVersionMigrations. +func (c *FakeStorageVersionMigrations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(storageversionmigrationsResource, opts)) +} + +// Create takes the representation of a storageVersionMigration and creates it. Returns the server's representation of the storageVersionMigration, and an error, if there is any. +func (c *FakeStorageVersionMigrations) Create(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.CreateOptions) (result *v1alpha1.StorageVersionMigration, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(storageversionmigrationsResource, storageVersionMigration), &v1alpha1.StorageVersionMigration{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageVersionMigration), err +} + +// Update takes the representation of a storageVersionMigration and updates it. Returns the server's representation of the storageVersionMigration, and an error, if there is any. +func (c *FakeStorageVersionMigrations) Update(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (result *v1alpha1.StorageVersionMigration, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(storageversionmigrationsResource, storageVersionMigration), &v1alpha1.StorageVersionMigration{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageVersionMigration), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeStorageVersionMigrations) UpdateStatus(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (*v1alpha1.StorageVersionMigration, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(storageversionmigrationsResource, "status", storageVersionMigration), &v1alpha1.StorageVersionMigration{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageVersionMigration), err +} + +// Delete takes name of the storageVersionMigration and deletes it. Returns an error if one occurs. +func (c *FakeStorageVersionMigrations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(storageversionmigrationsResource, name), &v1alpha1.StorageVersionMigration{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeStorageVersionMigrations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(storageversionmigrationsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.StorageVersionMigrationList{}) + return err +} + +// Patch applies the patch and returns the patched storageVersionMigration. +func (c *FakeStorageVersionMigrations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.StorageVersionMigration, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(storageversionmigrationsResource, name, pt, data, subresources...), &v1alpha1.StorageVersionMigration{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.StorageVersionMigration), err +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/generated_expansion.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..3ce4f5753 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type StorageStateExpansion interface{} + +type StorageVersionMigrationExpansion interface{} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/migration_client.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/migration_client.go new file mode 100644 index 000000000..097a331f0 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/migration_client.go @@ -0,0 +1,94 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + rest "k8s.io/client-go/rest" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" + "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme" +) + +type MigrationV1alpha1Interface interface { + RESTClient() rest.Interface + StorageStatesGetter + StorageVersionMigrationsGetter +} + +// MigrationV1alpha1Client is used to interact with features provided by the migration.k8s.io group. +type MigrationV1alpha1Client struct { + restClient rest.Interface +} + +func (c *MigrationV1alpha1Client) StorageStates() StorageStateInterface { + return newStorageStates(c) +} + +func (c *MigrationV1alpha1Client) StorageVersionMigrations() StorageVersionMigrationInterface { + return newStorageVersionMigrations(c) +} + +// NewForConfig creates a new MigrationV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*MigrationV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &MigrationV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new MigrationV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *MigrationV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new MigrationV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *MigrationV1alpha1Client { + return &MigrationV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *MigrationV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storagestate.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storagestate.go new file mode 100644 index 000000000..8345b3619 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storagestate.go @@ -0,0 +1,184 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1 "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" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" + scheme "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme" +) + +// StorageStatesGetter has a method to return a StorageStateInterface. +// A group's client should implement this interface. +type StorageStatesGetter interface { + StorageStates() StorageStateInterface +} + +// StorageStateInterface has methods to work with StorageState resources. +type StorageStateInterface interface { + Create(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.CreateOptions) (*v1alpha1.StorageState, error) + Update(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (*v1alpha1.StorageState, error) + UpdateStatus(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (*v1alpha1.StorageState, 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) (*v1alpha1.StorageState, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.StorageStateList, 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 *v1alpha1.StorageState, err error) + StorageStateExpansion +} + +// storageStates implements StorageStateInterface +type storageStates struct { + client rest.Interface +} + +// newStorageStates returns a StorageStates +func newStorageStates(c *MigrationV1alpha1Client) *storageStates { + return &storageStates{ + client: c.RESTClient(), + } +} + +// Get takes name of the storageState, and returns the corresponding storageState object, and an error if there is any. +func (c *storageStates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.StorageState, err error) { + result = &v1alpha1.StorageState{} + err = c.client.Get(). + Resource("storagestates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of StorageStates that match those selectors. +func (c *storageStates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageStateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.StorageStateList{} + err = c.client.Get(). + Resource("storagestates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested storageStates. +func (c *storageStates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("storagestates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a storageState and creates it. Returns the server's representation of the storageState, and an error, if there is any. +func (c *storageStates) Create(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.CreateOptions) (result *v1alpha1.StorageState, err error) { + result = &v1alpha1.StorageState{} + err = c.client.Post(). + Resource("storagestates"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageState). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a storageState and updates it. Returns the server's representation of the storageState, and an error, if there is any. +func (c *storageStates) Update(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (result *v1alpha1.StorageState, err error) { + result = &v1alpha1.StorageState{} + err = c.client.Put(). + Resource("storagestates"). + Name(storageState.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageState). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *storageStates) UpdateStatus(ctx context.Context, storageState *v1alpha1.StorageState, opts v1.UpdateOptions) (result *v1alpha1.StorageState, err error) { + result = &v1alpha1.StorageState{} + err = c.client.Put(). + Resource("storagestates"). + Name(storageState.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageState). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the storageState and deletes it. Returns an error if one occurs. +func (c *storageStates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("storagestates"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *storageStates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("storagestates"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched storageState. +func (c *storageStates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.StorageState, err error) { + result = &v1alpha1.StorageState{} + err = c.client.Patch(pt). + Resource("storagestates"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storageversionmigration.go b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storageversionmigration.go new file mode 100644 index 000000000..34fa3a987 --- /dev/null +++ b/vendor/sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/typed/migration/v1alpha1/storageversionmigration.go @@ -0,0 +1,184 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1 "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" + v1alpha1 "sigs.k8s.io/kube-storage-version-migrator/pkg/apis/migration/v1alpha1" + scheme "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset/scheme" +) + +// StorageVersionMigrationsGetter has a method to return a StorageVersionMigrationInterface. +// A group's client should implement this interface. +type StorageVersionMigrationsGetter interface { + StorageVersionMigrations() StorageVersionMigrationInterface +} + +// StorageVersionMigrationInterface has methods to work with StorageVersionMigration resources. +type StorageVersionMigrationInterface interface { + Create(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.CreateOptions) (*v1alpha1.StorageVersionMigration, error) + Update(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (*v1alpha1.StorageVersionMigration, error) + UpdateStatus(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (*v1alpha1.StorageVersionMigration, 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) (*v1alpha1.StorageVersionMigration, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.StorageVersionMigrationList, 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 *v1alpha1.StorageVersionMigration, err error) + StorageVersionMigrationExpansion +} + +// storageVersionMigrations implements StorageVersionMigrationInterface +type storageVersionMigrations struct { + client rest.Interface +} + +// newStorageVersionMigrations returns a StorageVersionMigrations +func newStorageVersionMigrations(c *MigrationV1alpha1Client) *storageVersionMigrations { + return &storageVersionMigrations{ + client: c.RESTClient(), + } +} + +// Get takes name of the storageVersionMigration, and returns the corresponding storageVersionMigration object, and an error if there is any. +func (c *storageVersionMigrations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.StorageVersionMigration, err error) { + result = &v1alpha1.StorageVersionMigration{} + err = c.client.Get(). + Resource("storageversionmigrations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors. +func (c *storageVersionMigrations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionMigrationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.StorageVersionMigrationList{} + err = c.client.Get(). + Resource("storageversionmigrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested storageVersionMigrations. +func (c *storageVersionMigrations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("storageversionmigrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a storageVersionMigration and creates it. Returns the server's representation of the storageVersionMigration, and an error, if there is any. +func (c *storageVersionMigrations) Create(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.CreateOptions) (result *v1alpha1.StorageVersionMigration, err error) { + result = &v1alpha1.StorageVersionMigration{} + err = c.client.Post(). + Resource("storageversionmigrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageVersionMigration). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a storageVersionMigration and updates it. Returns the server's representation of the storageVersionMigration, and an error, if there is any. +func (c *storageVersionMigrations) Update(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (result *v1alpha1.StorageVersionMigration, err error) { + result = &v1alpha1.StorageVersionMigration{} + err = c.client.Put(). + Resource("storageversionmigrations"). + Name(storageVersionMigration.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageVersionMigration). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *storageVersionMigrations) UpdateStatus(ctx context.Context, storageVersionMigration *v1alpha1.StorageVersionMigration, opts v1.UpdateOptions) (result *v1alpha1.StorageVersionMigration, err error) { + result = &v1alpha1.StorageVersionMigration{} + err = c.client.Put(). + Resource("storageversionmigrations"). + Name(storageVersionMigration.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(storageVersionMigration). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the storageVersionMigration and deletes it. Returns an error if one occurs. +func (c *storageVersionMigrations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("storageversionmigrations"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *storageVersionMigrations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("storageversionmigrations"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched storageVersionMigration. +func (c *storageVersionMigrations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.StorageVersionMigration, err error) { + result = &v1alpha1.StorageVersionMigration{} + err = c.client.Patch(pt). + Resource("storageversionmigrations"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +}