From 2a74fb4678c4bf49fc7cc42cb9c8719b6507de72 Mon Sep 17 00:00:00 2001 From: Andrew Pryde Date: Fri, 1 Jun 2018 15:16:08 +0100 Subject: [PATCH] Migrate API version from v1 -> v1alpha1 --- cmd/mysql-agent/app/mysql_agent.go | 18 +-- cmd/mysql-operator/app/mysql_operator.go | 22 ++-- .../custom-resource-definitions.yaml | 8 +- docs/tutorial.md | 2 +- docs/user/backup.md | 24 ++-- docs/user/clusters.md | 14 +-- docs/user/restore.md | 2 +- docs/user/router.md | 2 +- examples/backup/backup-schedule.yaml | 2 +- examples/backup/backup.yaml | 2 +- examples/cluster/cluster-with-3-replicas.yaml | 2 +- .../cluster/cluster-with-custom-config.yaml | 2 +- .../cluster/cluster-with-custom-secret.yaml | 2 +- .../cluster-with-custom-ssl-certs.yaml | 2 +- ...er-with-data-volume-and-backup-volume.yaml | 2 +- examples/cluster/cluster-with-volume.yaml | 2 +- examples/cluster/cluster.yaml | 2 +- examples/cluster/multi-master-cluster.yaml | 2 +- .../wordpress-router/wordpress-database.yaml | 2 +- .../demo/wordpress/wordpress-database.yaml | 2 +- examples/restore/restore.yaml | 2 +- hack/update-generated.sh | 10 +- mysql-operator/templates/01-resources.yaml | 8 +- pkg/apis/mysql/v1/doc.go | 5 - pkg/apis/mysql/{v1 => v1alpha1}/backup.go | 2 +- .../mysql/{v1 => v1alpha1}/backup_test.go | 3 +- .../mysql/{v1 => v1alpha1}/backupschedule.go | 2 +- .../{v1 => v1alpha1}/backupschedule_test.go | 2 +- pkg/apis/mysql/{v1 => v1alpha1}/cluster.go | 2 +- .../mysql/{v1 => v1alpha1}/cluster_test.go | 2 +- .../mysql/v1alpha1/doc.go} | 6 +- pkg/apis/mysql/{v1 => v1alpha1}/metadata.go | 2 +- pkg/apis/mysql/{v1 => v1alpha1}/register.go | 4 +- pkg/apis/mysql/{v1 => v1alpha1}/restore.go | 2 +- .../mysql/{v1 => v1alpha1}/restore_test.go | 2 +- .../mysql/{v1 => v1alpha1}/validate_backup.go | 2 +- .../validate_backup_executor.go | 2 +- .../validate_backup_storage.go | 2 +- .../validate_backupschedule.go | 2 +- .../{v1 => v1alpha1}/validate_cluster.go | 2 +- .../{v1 => v1alpha1}/validate_restore.go | 2 +- .../{v1 => v1alpha1}/zz_generated.deepcopy.go | 31 +++-- pkg/backup/backup.go | 4 +- pkg/backup/executor/executor.go | 4 +- pkg/backup/executor/mysqldump/config.go | 4 +- pkg/backup/executor/mysqldump/provider.go | 4 +- pkg/backup/storage/s3/client.go | 2 +- pkg/backup/storage/s3/client_test.go | 4 +- pkg/backup/storage/s3/config.go | 4 +- pkg/backup/storage/s3/config_test.go | 6 +- pkg/backup/storage/s3/provider.go | 4 +- pkg/backup/storage/storage.go | 4 +- pkg/constants/constants.go | 6 +- pkg/controllers/backup/agent_controller.go | 40 +++---- pkg/controllers/backup/metrics.go | 1 + pkg/controllers/backup/operator_controller.go | 34 +++--- pkg/controllers/backup/schedule/controller.go | 38 +++---- .../backup/schedule/controller_test.go | 106 +++++++++--------- pkg/controllers/cluster/cluster_control.go | 24 ++-- pkg/controllers/cluster/controller.go | 28 ++--- pkg/controllers/cluster/controller_test.go | 42 ++++--- pkg/controllers/cluster/manager/metrics.go | 1 + pkg/controllers/cluster/metrics.go | 1 + pkg/controllers/cluster/pod_control.go | 6 +- pkg/controllers/cluster/secret_control.go | 6 +- pkg/controllers/cluster/service_control.go | 12 +- .../cluster/statefulset_control.go | 6 +- .../cluster/statefulset_control_test.go | 4 +- pkg/controllers/cluster/utils.go | 14 +-- pkg/controllers/controllers.go | 22 ---- pkg/controllers/restore/agent_controller.go | 44 ++++---- pkg/controllers/restore/metrics.go | 1 + .../restore/operator_controller.go | 36 +++--- pkg/controllers/util/patch.go | 16 +-- .../clientset/versioned/clientset.go | 24 ++-- .../versioned/fake/clientset_generated.go | 16 +-- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../typed/mysql/{v1 => v1alpha1}/doc.go | 2 +- .../typed/mysql/{v1 => v1alpha1}/fake/doc.go | 0 .../fake/fake_mysql_client.go | 14 +-- .../{v1 => v1alpha1}/fake/fake_mysqlbackup.go | 44 ++++---- .../fake/fake_mysqlbackupschedule.go | 44 ++++---- .../fake/fake_mysqlcluster.go | 44 ++++---- .../fake/fake_mysqlrestore.go | 44 ++++---- .../{v1 => v1alpha1}/generated_expansion.go | 2 +- .../mysql/{v1 => v1alpha1}/mysql_client.go | 38 +++---- .../mysql/{v1 => v1alpha1}/mysqlbackup.go | 50 ++++----- .../{v1 => v1alpha1}/mysqlbackupschedule.go | 50 ++++----- .../mysql/{v1 => v1alpha1}/mysqlcluster.go | 50 ++++----- .../mysql/{v1 => v1alpha1}/mysqlrestore.go | 50 ++++----- .../informers/externalversions/generic.go | 20 ++-- .../externalversions/mysql/interface.go | 12 +- .../mysql/{v1 => v1alpha1}/interface.go | 2 +- .../mysql/{v1 => v1alpha1}/mysqlbackup.go | 26 ++--- .../{v1 => v1alpha1}/mysqlbackupschedule.go | 26 ++--- .../mysql/{v1 => v1alpha1}/mysqlcluster.go | 26 ++--- .../mysql/{v1 => v1alpha1}/mysqlrestore.go | 26 ++--- .../{v1 => v1alpha1}/expansion_generated.go | 2 +- .../mysql/{v1 => v1alpha1}/mysqlbackup.go | 24 ++-- .../{v1 => v1alpha1}/mysqlbackupschedule.go | 24 ++-- .../mysql/{v1 => v1alpha1}/mysqlcluster.go | 24 ++-- .../mysql/{v1 => v1alpha1}/mysqlrestore.go | 24 ++-- pkg/resources/secrets/secret.go | 16 +-- pkg/resources/secrets/secret_test.go | 6 +- pkg/resources/services/service.go | 25 +++-- pkg/resources/statefulsets/statefulset.go | 20 ++-- .../statefulsets/statefulset_test.go | 46 ++++---- pkg/util/test/test_backup.go | 12 +- pkg/util/test/test_backupschedule.go | 2 +- test/e2e/backup_restore.go | 6 +- test/e2e/cluster_creation.go | 4 +- test/e2e/container_crash.go | 6 +- test/e2e/framework/backup.go | 46 ++++---- test/e2e/framework/cluster.go | 6 +- test/e2e/framework/restore.go | 32 +++--- test/e2e/pod_crash.go | 4 +- test/examples/examples_test.go | 12 +- 118 files changed, 845 insertions(+), 855 deletions(-) delete mode 100644 pkg/apis/mysql/v1/doc.go rename pkg/apis/mysql/{v1 => v1alpha1}/backup.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/backup_test.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/backupschedule.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/backupschedule_test.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/cluster.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/cluster_test.go (99%) rename pkg/{resources/services/service_test.go => apis/mysql/v1alpha1/doc.go} (81%) rename pkg/apis/mysql/{v1 => v1alpha1}/metadata.go (98%) rename pkg/apis/mysql/{v1 => v1alpha1}/register.go (98%) rename pkg/apis/mysql/{v1 => v1alpha1}/restore.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/restore_test.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_backup.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_backup_executor.go (98%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_backup_storage.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_backupschedule.go (98%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_cluster.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/validate_restore.go (99%) rename pkg/apis/mysql/{v1 => v1alpha1}/zz_generated.deepcopy.go (96%) delete mode 100644 pkg/controllers/controllers.go rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/doc.go (97%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/doc.go (100%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/fake_mysql_client.go (65%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/fake_mysqlbackup.go (74%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/fake_mysqlbackupschedule.go (73%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/fake_mysqlcluster.go (73%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/fake/fake_mysqlrestore.go (73%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/generated_expansion.go (97%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/mysql_client.go (61%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/mysqlbackup.go (68%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/mysqlbackupschedule.go (67%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/mysqlcluster.go (68%) rename pkg/generated/clientset/versioned/typed/mysql/{v1 => v1alpha1}/mysqlrestore.go (68%) rename pkg/generated/informers/externalversions/mysql/{v1 => v1alpha1}/interface.go (99%) rename pkg/generated/informers/externalversions/mysql/{v1 => v1alpha1}/mysqlbackup.go (79%) rename pkg/generated/informers/externalversions/mysql/{v1 => v1alpha1}/mysqlbackupschedule.go (78%) rename pkg/generated/informers/externalversions/mysql/{v1 => v1alpha1}/mysqlcluster.go (79%) rename pkg/generated/informers/externalversions/mysql/{v1 => v1alpha1}/mysqlrestore.go (79%) rename pkg/generated/listers/mysql/{v1 => v1alpha1}/expansion_generated.go (99%) rename pkg/generated/listers/mysql/{v1 => v1alpha1}/mysqlbackup.go (80%) rename pkg/generated/listers/mysql/{v1 => v1alpha1}/mysqlbackupschedule.go (81%) rename pkg/generated/listers/mysql/{v1 => v1alpha1}/mysqlcluster.go (80%) rename pkg/generated/listers/mysql/{v1 => v1alpha1}/mysqlrestore.go (80%) diff --git a/cmd/mysql-agent/app/mysql_agent.go b/cmd/mysql-agent/app/mysql_agent.go index 9294522fc..dd6c25b31 100644 --- a/cmd/mysql-agent/app/mysql_agent.go +++ b/cmd/mysql-agent/app/mysql_agent.go @@ -37,7 +37,7 @@ import ( backupcontroller "github.com/oracle/mysql-operator/pkg/controllers/backup" clustermgr "github.com/oracle/mysql-operator/pkg/controllers/cluster/manager" restorecontroller "github.com/oracle/mysql-operator/pkg/controllers/restore" - mysqlop "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions" metrics "github.com/oracle/mysql-operator/pkg/util/metrics" signals "github.com/oracle/mysql-operator/pkg/util/signals" @@ -83,7 +83,7 @@ func Run(opts *options.MySQLAgentOpts) error { }() kubeclient := kubernetes.NewForConfigOrDie(kubeconfig) - mysqlopClient := mysqlop.NewForConfigOrDie(kubeconfig) + mysqlopClient := clientset.NewForConfigOrDie(kubeconfig) sharedInformerFactory := informers.NewFilteredSharedInformerFactory(mysqlopClient, 0, opts.Namespace, nil) kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeclient, resyncPeriod(opts)(), opts.Namespace, nil) @@ -116,9 +116,9 @@ func Run(opts *options.MySQLAgentOpts) error { backupController := backupcontroller.NewAgentController( kubeclient, - mysqlopClient.MysqlV1(), - sharedInformerFactory.Mysql().V1().MySQLBackups(), - sharedInformerFactory.Mysql().V1().MySQLClusters(), + mysqlopClient.MysqlV1alpha1(), + sharedInformerFactory.Mysql().V1alpha1().MySQLBackups(), + sharedInformerFactory.Mysql().V1alpha1().MySQLClusters(), kubeInformerFactory.Core().V1().Pods(), opts.Hostname, ) @@ -130,10 +130,10 @@ func Run(opts *options.MySQLAgentOpts) error { restoreController := restorecontroller.NewAgentController( kubeclient, - mysqlopClient.MysqlV1(), - sharedInformerFactory.Mysql().V1().MySQLRestores(), - sharedInformerFactory.Mysql().V1().MySQLClusters(), - sharedInformerFactory.Mysql().V1().MySQLBackups(), + mysqlopClient.MysqlV1alpha1(), + sharedInformerFactory.Mysql().V1alpha1().MySQLRestores(), + sharedInformerFactory.Mysql().V1alpha1().MySQLClusters(), + sharedInformerFactory.Mysql().V1alpha1().MySQLBackups(), kubeInformerFactory.Core().V1().Pods(), opts.Hostname, ) diff --git a/cmd/mysql-operator/app/mysql_operator.go b/cmd/mysql-operator/app/mysql_operator.go index 9d7a0ae90..cd6825284 100644 --- a/cmd/mysql-operator/app/mysql_operator.go +++ b/cmd/mysql-operator/app/mysql_operator.go @@ -33,7 +33,7 @@ import ( backupschedule "github.com/oracle/mysql-operator/pkg/controllers/backup/schedule" cluster "github.com/oracle/mysql-operator/pkg/controllers/cluster" restorecontroller "github.com/oracle/mysql-operator/pkg/controllers/restore" - mysqlop "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions" metrics "github.com/oracle/mysql-operator/pkg/util/metrics" signals "github.com/oracle/mysql-operator/pkg/util/signals" @@ -71,7 +71,7 @@ func Run(s *options.MySQLOperatorServer) error { signals.SetupSignalHandler(cancelFunc) kubeClient := kubernetes.NewForConfigOrDie(kubeconfig) - mysqlopClient := mysqlop.NewForConfigOrDie(kubeconfig) + mysqlopClient := clientset.NewForConfigOrDie(kubeconfig) // Shared informers (non namespace specific). operatorInformerFactory := informers.NewFilteredSharedInformerFactory(mysqlopClient, resyncPeriod(s)(), s.Namespace, nil) @@ -83,7 +83,7 @@ func Run(s *options.MySQLOperatorServer) error { *s, mysqlopClient, kubeClient, - operatorInformerFactory.Mysql().V1().MySQLClusters(), + operatorInformerFactory.Mysql().V1alpha1().MySQLClusters(), kubeInformerFactory.Apps().V1beta1().StatefulSets(), kubeInformerFactory.Core().V1().Pods(), kubeInformerFactory.Core().V1().Services(), @@ -98,9 +98,9 @@ func Run(s *options.MySQLOperatorServer) error { backupController := backupcontroller.NewOperatorController( kubeClient, - mysqlopClient.MysqlV1(), - operatorInformerFactory.Mysql().V1().MySQLBackups(), - operatorInformerFactory.Mysql().V1().MySQLClusters(), + mysqlopClient.MysqlV1alpha1(), + operatorInformerFactory.Mysql().V1alpha1().MySQLBackups(), + operatorInformerFactory.Mysql().V1alpha1().MySQLClusters(), kubeInformerFactory.Core().V1().Pods(), ) wg.Add(1) @@ -111,10 +111,10 @@ func Run(s *options.MySQLOperatorServer) error { restoreController := restorecontroller.NewOperatorController( kubeClient, - mysqlopClient.MysqlV1(), - operatorInformerFactory.Mysql().V1().MySQLRestores(), - operatorInformerFactory.Mysql().V1().MySQLClusters(), - operatorInformerFactory.Mysql().V1().MySQLBackups(), + mysqlopClient.MysqlV1alpha1(), + operatorInformerFactory.Mysql().V1alpha1().MySQLRestores(), + operatorInformerFactory.Mysql().V1alpha1().MySQLClusters(), + operatorInformerFactory.Mysql().V1alpha1().MySQLBackups(), kubeInformerFactory.Core().V1().Pods(), ) wg.Add(1) @@ -126,7 +126,7 @@ func Run(s *options.MySQLOperatorServer) error { backupScheduleController := backupschedule.NewController( mysqlopClient, kubeClient, - operatorInformerFactory.Mysql().V1().MySQLBackupSchedules(), + operatorInformerFactory.Mysql().V1alpha1().MySQLBackupSchedules(), 30*time.Second, s.Namespace, ) diff --git a/contrib/manifests/custom-resource-definitions.yaml b/contrib/manifests/custom-resource-definitions.yaml index bec5c0fe8..8324ae887 100644 --- a/contrib/manifests/custom-resource-definitions.yaml +++ b/contrib/manifests/custom-resource-definitions.yaml @@ -5,7 +5,7 @@ metadata: name: mysqlclusters.mysql.oracle.com spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLCluster @@ -18,7 +18,7 @@ metadata: name: mysqlbackups.mysql.oracle.com spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLBackup @@ -31,7 +31,7 @@ metadata: name: mysqlrestores.mysql.oracle.com spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLRestore @@ -44,7 +44,7 @@ metadata: name: mysqlbackupschedules.mysql.oracle.com spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLBackupSchedule diff --git a/docs/tutorial.md b/docs/tutorial.md index d74396cb0..ca87eb596 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -126,7 +126,7 @@ You should now have a cluster in the default namespace ``` $ kubectl get mysqlclusters NAME KIND -myappdb MySQLCluster.v1.mysql.oracle.com +myappdb MySQLCluster.v1alpha1.mysql.oracle.com ``` To find out how to create larger clusters, and configure storage see [Clusters](user/clusters.md#clusters). diff --git a/docs/user/backup.md b/docs/user/backup.md index d4c2280c8..464d534f8 100644 --- a/docs/user/backup.md +++ b/docs/user/backup.md @@ -40,7 +40,7 @@ operator. The secretRef is the name of a secret that contains your Object Storage credentials. Note: The databases field is mandatory. ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpa1 kind: MySQLBackup metadata: name: mysql-backup @@ -63,30 +63,30 @@ spec: ### On-demand backups - executor configuration -A backup spec requires an 'executor' to support the backup and restore of +A backup spec requires an 'executor' to support the backup and restore of database content. -Currently, the 'mysqldump' utility is provided, although further executors may +Currently, the 'mysqldump' utility is provided, although further executors may be added in the future. -You should additionally configure the list of databases to include in the +You should additionally configure the list of databases to include in the backup. ### On-demand backups - storage configuration -A backup spec requires a 'storage' mechanism to save the backed up +A backup spec requires a 'storage' mechanism to save the backed up content of a database. -Currently, 'S3' based object storage is provided, although further providers +Currently, 'S3' based object storage is provided, although further providers may be added in the future. #### On-demand backups - OCI S3 storage configuration -When configuring an S3 endpoint you should ensure that it is correct for your -backing provider and that you have pre-created the desired bucket. +When configuring an S3 endpoint you should ensure that it is correct for your +backing provider and that you have pre-created the desired bucket. -For example, An Oracle OCI backend for the tenancy 'mytenancy', region -'us-phoenix-1', and bucket 'mybucket', should have the storage element +For example, An Oracle OCI backend for the tenancy 'mytenancy', region +'us-phoenix-1', and bucket 'mybucket', should have the storage element configured as follows: ```yaml @@ -98,7 +98,7 @@ configured as follows: ... ``` -The bucket should also be valid for the secret credentials specified previously. +The bucket should also be valid for the secret credentials specified previously. #### On-demand backups - Amazon S3 storage configuration @@ -146,7 +146,7 @@ databases field is mandatory. For example, the following will create a backup of the employees database every 30 minutes: ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLBackupSchedule metadata: name: mysql-backup-schedule diff --git a/docs/user/clusters.md b/docs/user/clusters.md index 8b4ac5f01..3a126f3fb 100644 --- a/docs/user/clusters.md +++ b/docs/user/clusters.md @@ -7,7 +7,7 @@ MySQL cluster examples. The following example will create a MySQL Cluster with 3 replicas, one primary and 2 secondaries: ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-test-cluster @@ -20,7 +20,7 @@ spec: The following example will create a MySQL Cluster with 3 primary (read/write) replicas: ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-multimaster-cluster @@ -40,7 +40,7 @@ $ kubectl create secret generic mysql-root-user-secret --from-literal=password=f Create your cluster and reference it ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: example-mysql-cluster-custom-secret @@ -72,7 +72,7 @@ spec: persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: example-mysql-cluster-with-volume @@ -129,7 +129,7 @@ spec: persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: example-mysql-cluster-with-volume @@ -179,7 +179,7 @@ kubectl create configmap mycnf --from-file=examples/my.cnf Now we can reference our config map in our cluster spec definition. For example: ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-cluster-with-config @@ -194,7 +194,7 @@ By default, the MySQL Operator starts a cluster with `--server_id` set to `1000` The following example will create a MySQL Cluster with following `server_id`'s: 42,43,44 ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-cluster-with-custom-serverid diff --git a/docs/user/restore.md b/docs/user/restore.md index b7c7b10aa..185ffdcde 100644 --- a/docs/user/restore.md +++ b/docs/user/restore.md @@ -10,7 +10,7 @@ backup that you wish to restore, and the clusterRef is the name of the destination cluster of the restore operation. ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLRestore metadata: name: example-restore diff --git a/docs/user/router.md b/docs/user/router.md index 548c18805..573d8df46 100644 --- a/docs/user/router.md +++ b/docs/user/router.md @@ -17,7 +17,7 @@ Typically the MySQL Router is deployed [alongside your application][2]. We'll use WordPress as an example of how you might setup the MySQL Router for a a real application. The first thing we want to do is create our MySQL Cluster using the operator. ```yaml -apiVersion: "mysql.oracle.com/v1" +apiVersion: "mysql.oracle.com/v1alpa1" kind: MySQLCluster metadata: name: mysql-wordpress diff --git a/examples/backup/backup-schedule.yaml b/examples/backup/backup-schedule.yaml index f56d86a70..884a82e6d 100644 --- a/examples/backup/backup-schedule.yaml +++ b/examples/backup/backup-schedule.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLBackupSchedule metadata: name: mysql-backup-schedule diff --git a/examples/backup/backup.yaml b/examples/backup/backup.yaml index 32911fcb3..6d6e26faa 100644 --- a/examples/backup/backup.yaml +++ b/examples/backup/backup.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLBackup metadata: name: mysql-backup diff --git a/examples/cluster/cluster-with-3-replicas.yaml b/examples/cluster/cluster-with-3-replicas.yaml index ded12fb15..5c6b17437 100644 --- a/examples/cluster/cluster-with-3-replicas.yaml +++ b/examples/cluster/cluster-with-3-replicas.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster-with-custom-config.yaml b/examples/cluster/cluster-with-custom-config.yaml index a5825c338..f71b3ab71 100644 --- a/examples/cluster/cluster-with-custom-config.yaml +++ b/examples/cluster/cluster-with-custom-config.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster-with-custom-secret.yaml b/examples/cluster/cluster-with-custom-secret.yaml index 79ce57c17..3a99370f9 100644 --- a/examples/cluster/cluster-with-custom-secret.yaml +++ b/examples/cluster/cluster-with-custom-secret.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster-with-custom-ssl-certs.yaml b/examples/cluster/cluster-with-custom-ssl-certs.yaml index a9d08c29e..5ebbe34de 100644 --- a/examples/cluster/cluster-with-custom-ssl-certs.yaml +++ b/examples/cluster/cluster-with-custom-ssl-certs.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster-with-data-volume-and-backup-volume.yaml b/examples/cluster/cluster-with-data-volume-and-backup-volume.yaml index 5210a9f38..545a0e3b7 100644 --- a/examples/cluster/cluster-with-data-volume-and-backup-volume.yaml +++ b/examples/cluster/cluster-with-data-volume-and-backup-volume.yaml @@ -31,7 +31,7 @@ spec: persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster-with-volume.yaml b/examples/cluster/cluster-with-volume.yaml index c3d15c11a..e34a30dac 100644 --- a/examples/cluster/cluster-with-volume.yaml +++ b/examples/cluster/cluster-with-volume.yaml @@ -15,7 +15,7 @@ spec: persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/cluster.yaml b/examples/cluster/cluster.yaml index 6bba714b6..bce0d5d99 100644 --- a/examples/cluster/cluster.yaml +++ b/examples/cluster/cluster.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/cluster/multi-master-cluster.yaml b/examples/cluster/multi-master-cluster.yaml index d5ec87818..f794ea2d8 100644 --- a/examples/cluster/multi-master-cluster.yaml +++ b/examples/cluster/multi-master-cluster.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql diff --git a/examples/demo/wordpress-router/wordpress-database.yaml b/examples/demo/wordpress-router/wordpress-database.yaml index 67cd3fc3e..c9b49c222 100644 --- a/examples/demo/wordpress-router/wordpress-database.yaml +++ b/examples/demo/wordpress-router/wordpress-database.yaml @@ -15,7 +15,7 @@ metadata: data: password: bXktc3VwZXItc2VjcmV0LXBhc3M= --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-wordpress diff --git a/examples/demo/wordpress/wordpress-database.yaml b/examples/demo/wordpress/wordpress-database.yaml index cfe68326e..b989887e1 100644 --- a/examples/demo/wordpress/wordpress-database.yaml +++ b/examples/demo/wordpress/wordpress-database.yaml @@ -15,7 +15,7 @@ spec: persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLCluster metadata: name: mysql-wordpress diff --git a/examples/restore/restore.yaml b/examples/restore/restore.yaml index 023f18ba7..924d3d3b8 100644 --- a/examples/restore/restore.yaml +++ b/examples/restore/restore.yaml @@ -1,4 +1,4 @@ -apiVersion: "mysql.oracle.com/v1" +apiVersion: mysql.oracle.com/v1alpha1 kind: MySQLRestore metadata: name: mysql-restore diff --git a/hack/update-generated.sh b/hack/update-generated.sh index d50f6c64b..3314b2ae0 100755 --- a/hack/update-generated.sh +++ b/hack/update-generated.sh @@ -1,12 +1,12 @@ #!/bin/bash -e -HACK_DIR=$(dirname "${BASH_SOURCE}") -REPO_ROOT=${HACK_DIR}/.. +HACK_DIR=$(dirname "${BASH_SOURCE[0]}") +REPO_ROOT="${HACK_DIR}/.." -${REPO_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh \ +"${REPO_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh" \ all \ github.com/oracle/mysql-operator/pkg/generated \ github.com/oracle/mysql-operator/pkg/apis \ - mysql:v1 \ + mysql:v1alpha1 \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - $@ + "$@" diff --git a/mysql-operator/templates/01-resources.yaml b/mysql-operator/templates/01-resources.yaml index 9b2bc1d7b..3d50bb6aa 100644 --- a/mysql-operator/templates/01-resources.yaml +++ b/mysql-operator/templates/01-resources.yaml @@ -9,7 +9,7 @@ metadata: chart: {{ .Chart.Name }}-{{ .Chart.Version }} spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLCluster @@ -25,7 +25,7 @@ metadata: chart: {{ .Chart.Name }}-{{ .Chart.Version }} spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLBackup @@ -41,7 +41,7 @@ metadata: chart: {{ .Chart.Name }}-{{ .Chart.Version }} spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLRestore @@ -57,7 +57,7 @@ metadata: chart: {{ .Chart.Name }}-{{ .Chart.Version }} spec: group: mysql.oracle.com - version: v1 + version: v1alpha1 scope: Namespaced names: kind: MySQLBackupSchedule diff --git a/pkg/apis/mysql/v1/doc.go b/pkg/apis/mysql/v1/doc.go deleted file mode 100644 index 25dccdfff..000000000 --- a/pkg/apis/mysql/v1/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// +k8s:deepcopy-gen=package - -// Package v1 defines the types for the MySQL Operator v1 API. -// +groupName=mysql.oracle.com -package v1 diff --git a/pkg/apis/mysql/v1/backup.go b/pkg/apis/mysql/v1alpha1/backup.go similarity index 99% rename from pkg/apis/mysql/v1/backup.go rename to pkg/apis/mysql/v1alpha1/backup.go index f8f024da8..cc1dd31da 100644 --- a/pkg/apis/mysql/v1/backup.go +++ b/pkg/apis/mysql/v1alpha1/backup.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/mysql/v1/backup_test.go b/pkg/apis/mysql/v1alpha1/backup_test.go similarity index 99% rename from pkg/apis/mysql/v1/backup_test.go rename to pkg/apis/mysql/v1alpha1/backup_test.go index ca3cb33d2..1093f4001 100644 --- a/pkg/apis/mysql/v1/backup_test.go +++ b/pkg/apis/mysql/v1alpha1/backup_test.go @@ -11,7 +11,8 @@ // 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 v1 + +package v1alpha1 import ( "strings" diff --git a/pkg/apis/mysql/v1/backupschedule.go b/pkg/apis/mysql/v1alpha1/backupschedule.go similarity index 99% rename from pkg/apis/mysql/v1/backupschedule.go rename to pkg/apis/mysql/v1alpha1/backupschedule.go index f9d9ac4c4..b0b1df406 100644 --- a/pkg/apis/mysql/v1/backupschedule.go +++ b/pkg/apis/mysql/v1alpha1/backupschedule.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "github.com/oracle/mysql-operator/pkg/constants" diff --git a/pkg/apis/mysql/v1/backupschedule_test.go b/pkg/apis/mysql/v1alpha1/backupschedule_test.go similarity index 99% rename from pkg/apis/mysql/v1/backupschedule_test.go rename to pkg/apis/mysql/v1alpha1/backupschedule_test.go index 2a836a631..152592276 100644 --- a/pkg/apis/mysql/v1/backupschedule_test.go +++ b/pkg/apis/mysql/v1alpha1/backupschedule_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "strings" diff --git a/pkg/apis/mysql/v1/cluster.go b/pkg/apis/mysql/v1alpha1/cluster.go similarity index 99% rename from pkg/apis/mysql/v1/cluster.go rename to pkg/apis/mysql/v1alpha1/cluster.go index a08e356b9..aab1c5033 100644 --- a/pkg/apis/mysql/v1/cluster.go +++ b/pkg/apis/mysql/v1alpha1/cluster.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/mysql/v1/cluster_test.go b/pkg/apis/mysql/v1alpha1/cluster_test.go similarity index 99% rename from pkg/apis/mysql/v1/cluster_test.go rename to pkg/apis/mysql/v1alpha1/cluster_test.go index 5cbb6bfa0..5ce02bfb3 100644 --- a/pkg/apis/mysql/v1/cluster_test.go +++ b/pkg/apis/mysql/v1alpha1/cluster_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "testing" diff --git a/pkg/resources/services/service_test.go b/pkg/apis/mysql/v1alpha1/doc.go similarity index 81% rename from pkg/resources/services/service_test.go rename to pkg/apis/mysql/v1alpha1/doc.go index 0413771b9..d329ffd41 100644 --- a/pkg/resources/services/service_test.go +++ b/pkg/apis/mysql/v1alpha1/doc.go @@ -12,4 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -package services +// +k8s:deepcopy-gen=package + +// Package v1 defines the types for the MySQL Operator v1 API. +// +groupName=mysql.oracle.com +package v1alpha1 diff --git a/pkg/apis/mysql/v1/metadata.go b/pkg/apis/mysql/v1alpha1/metadata.go similarity index 98% rename from pkg/apis/mysql/v1/metadata.go rename to pkg/apis/mysql/v1alpha1/metadata.go index 483473974..b2ce591f8 100644 --- a/pkg/apis/mysql/v1/metadata.go +++ b/pkg/apis/mysql/v1alpha1/metadata.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import "github.com/oracle/mysql-operator/pkg/constants" diff --git a/pkg/apis/mysql/v1/register.go b/pkg/apis/mysql/v1alpha1/register.go similarity index 98% rename from pkg/apis/mysql/v1/register.go rename to pkg/apis/mysql/v1alpha1/register.go index f239b09bf..1bb3c9909 100644 --- a/pkg/apis/mysql/v1/register.go +++ b/pkg/apis/mysql/v1alpha1/register.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 // This package will auto register types with the Kubernetes API @@ -35,7 +35,7 @@ var ( const GroupName = "mysql.oracle.com" // SchemeGroupVersion is the GroupVersion for the MySQL Operator API. -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} const ( // MySQLClusterCRDResourceKind is the Kind of a MySQLCluster. diff --git a/pkg/apis/mysql/v1/restore.go b/pkg/apis/mysql/v1alpha1/restore.go similarity index 99% rename from pkg/apis/mysql/v1/restore.go rename to pkg/apis/mysql/v1alpha1/restore.go index 4f542648b..f0c851499 100644 --- a/pkg/apis/mysql/v1/restore.go +++ b/pkg/apis/mysql/v1alpha1/restore.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "github.com/oracle/mysql-operator/pkg/constants" diff --git a/pkg/apis/mysql/v1/restore_test.go b/pkg/apis/mysql/v1alpha1/restore_test.go similarity index 99% rename from pkg/apis/mysql/v1/restore_test.go rename to pkg/apis/mysql/v1alpha1/restore_test.go index 89d92494f..f0badfd15 100644 --- a/pkg/apis/mysql/v1/restore_test.go +++ b/pkg/apis/mysql/v1alpha1/restore_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "testing" diff --git a/pkg/apis/mysql/v1/validate_backup.go b/pkg/apis/mysql/v1alpha1/validate_backup.go similarity index 99% rename from pkg/apis/mysql/v1/validate_backup.go rename to pkg/apis/mysql/v1alpha1/validate_backup.go index e477fb498..ca1147a2a 100644 --- a/pkg/apis/mysql/v1/validate_backup.go +++ b/pkg/apis/mysql/v1alpha1/validate_backup.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "fmt" diff --git a/pkg/apis/mysql/v1/validate_backup_executor.go b/pkg/apis/mysql/v1alpha1/validate_backup_executor.go similarity index 98% rename from pkg/apis/mysql/v1/validate_backup_executor.go rename to pkg/apis/mysql/v1alpha1/validate_backup_executor.go index 21d43f23b..a80af3a45 100644 --- a/pkg/apis/mysql/v1/validate_backup_executor.go +++ b/pkg/apis/mysql/v1alpha1/validate_backup_executor.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "fmt" diff --git a/pkg/apis/mysql/v1/validate_backup_storage.go b/pkg/apis/mysql/v1alpha1/validate_backup_storage.go similarity index 99% rename from pkg/apis/mysql/v1/validate_backup_storage.go rename to pkg/apis/mysql/v1alpha1/validate_backup_storage.go index 374fe3f47..44438d88b 100644 --- a/pkg/apis/mysql/v1/validate_backup_storage.go +++ b/pkg/apis/mysql/v1alpha1/validate_backup_storage.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "fmt" diff --git a/pkg/apis/mysql/v1/validate_backupschedule.go b/pkg/apis/mysql/v1alpha1/validate_backupschedule.go similarity index 98% rename from pkg/apis/mysql/v1/validate_backupschedule.go rename to pkg/apis/mysql/v1alpha1/validate_backupschedule.go index 85abc6152..594f83f5e 100644 --- a/pkg/apis/mysql/v1/validate_backupschedule.go +++ b/pkg/apis/mysql/v1alpha1/validate_backupschedule.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "k8s.io/apimachinery/pkg/util/validation/field" diff --git a/pkg/apis/mysql/v1/validate_cluster.go b/pkg/apis/mysql/v1alpha1/validate_cluster.go similarity index 99% rename from pkg/apis/mysql/v1/validate_cluster.go rename to pkg/apis/mysql/v1alpha1/validate_cluster.go index e54ea575b..511d6ef00 100644 --- a/pkg/apis/mysql/v1/validate_cluster.go +++ b/pkg/apis/mysql/v1alpha1/validate_cluster.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "fmt" diff --git a/pkg/apis/mysql/v1/validate_restore.go b/pkg/apis/mysql/v1alpha1/validate_restore.go similarity index 99% rename from pkg/apis/mysql/v1/validate_restore.go rename to pkg/apis/mysql/v1alpha1/validate_restore.go index fa169eb76..f72c029ea 100644 --- a/pkg/apis/mysql/v1/validate_restore.go +++ b/pkg/apis/mysql/v1alpha1/validate_restore.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( "fmt" diff --git a/pkg/apis/mysql/v1/zz_generated.deepcopy.go b/pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go similarity index 96% rename from pkg/apis/mysql/v1/zz_generated.deepcopy.go rename to pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go index da0f25eb8..6f3ac7a3f 100644 --- a/pkg/apis/mysql/v1/zz_generated.deepcopy.go +++ b/pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go @@ -16,10 +16,10 @@ // This file was autogenerated by deepcopy-gen. Do not edit it manually! -package v1 +package v1alpha1 import ( - core_v1 "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -82,7 +82,7 @@ func (in *BackupSpec) DeepCopyInto(out *BackupSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) **out = **in } } @@ -343,7 +343,7 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.Affinity) + *out = new(v1.Affinity) (*in).DeepCopyInto(*out) } } @@ -352,7 +352,7 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.PersistentVolumeClaim) + *out = new(v1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } } @@ -361,7 +361,7 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.PersistentVolumeClaim) + *out = new(v1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } } @@ -370,7 +370,7 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) **out = **in } } @@ -379,7 +379,16 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) + **out = **in + } + } + if in.SSLSecretRef != nil { + in, out := &in.SSLSecretRef, &out.SSLSecretRef + if *in == nil { + *out = nil + } else { + *out = new(v1.LocalObjectReference) **out = **in } } @@ -499,7 +508,7 @@ func (in *RestoreSpec) DeepCopyInto(out *RestoreSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) **out = **in } } @@ -508,7 +517,7 @@ func (in *RestoreSpec) DeepCopyInto(out *RestoreSpec) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) **out = **in } } @@ -568,7 +577,7 @@ func (in *Storage) DeepCopyInto(out *Storage) { if *in == nil { *out = nil } else { - *out = new(core_v1.LocalObjectReference) + *out = new(v1.LocalObjectReference) **out = **in } } diff --git a/pkg/backup/backup.go b/pkg/backup/backup.go index 1a37a18fa..63e02f23f 100644 --- a/pkg/backup/backup.go +++ b/pkg/backup/backup.go @@ -17,7 +17,7 @@ package backup import ( "os" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/backup/executor" "github.com/oracle/mysql-operator/pkg/backup/storage" "github.com/oracle/mysql-operator/pkg/resources/statefulsets" @@ -42,7 +42,7 @@ type runner struct { // NewConfiguredRunner creates a runner configured with the Backup/Restore target executor and // storage configurations. -func NewConfiguredRunner(execConfig *v1.Executor, execCreds map[string]string, storeConfig *v1.Storage, storeCreds map[string]string) (Runner, error) { +func NewConfiguredRunner(execConfig *v1alpha1.Executor, execCreds map[string]string, storeConfig *v1alpha1.Storage, storeCreds map[string]string) (Runner, error) { exec, err := executor.New(execConfig, execCreds) if err != nil { return nil, err diff --git a/pkg/backup/executor/executor.go b/pkg/backup/executor/executor.go index ab5c1ea26..3c8d72e93 100644 --- a/pkg/backup/executor/executor.go +++ b/pkg/backup/executor/executor.go @@ -20,7 +20,7 @@ import ( "os" "strings" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/backup/executor/mysqldump" ) @@ -43,7 +43,7 @@ type Interface interface { } // New builds a new backup executor. -func New(executor *v1.Executor, creds map[string]string) (Interface, error) { +func New(executor *v1alpha1.Executor, creds map[string]string) (Interface, error) { switch strings.ToLower(executor.Provider) { case MySQLDumpProvider: return mysqldump.NewExecutor(executor, creds) diff --git a/pkg/backup/executor/mysqldump/config.go b/pkg/backup/executor/mysqldump/config.go index 0411b970e..9229fea3d 100644 --- a/pkg/backup/executor/mysqldump/config.go +++ b/pkg/backup/executor/mysqldump/config.go @@ -17,7 +17,7 @@ package mysqldump import ( "fmt" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) // Config holds the MySQL credentials required to authenticate with the MySQL database being @@ -29,7 +29,7 @@ type Config struct { } // NewConfig creates an mysqldump configuration based on the input parameters. -func NewConfig(executor *v1.Executor, creds map[string]string) *Config { +func NewConfig(executor *v1alpha1.Executor, creds map[string]string) *Config { return &Config{ databases: executor.Databases, username: creds["username"], diff --git a/pkg/backup/executor/mysqldump/provider.go b/pkg/backup/executor/mysqldump/provider.go index 40b2304e0..f96529178 100644 --- a/pkg/backup/executor/mysqldump/provider.go +++ b/pkg/backup/executor/mysqldump/provider.go @@ -28,7 +28,7 @@ import ( utilexec "k8s.io/utils/exec" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) const ( @@ -43,7 +43,7 @@ type Executor struct { // NewExecutor creates a provider capable of creating and restoring backups with the mysqldump // tool. -func NewExecutor(executor *v1.Executor, creds map[string]string) (*Executor, error) { +func NewExecutor(executor *v1alpha1.Executor, creds map[string]string) (*Executor, error) { cfg := NewConfig(executor, creds) err := cfg.Validate() if err != nil { diff --git a/pkg/backup/storage/s3/client.go b/pkg/backup/storage/s3/client.go index 62946f7a0..2b31c3739 100644 --- a/pkg/backup/storage/s3/client.go +++ b/pkg/backup/storage/s3/client.go @@ -20,7 +20,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" - s3 "github.com/aws/aws-sdk-go/service/s3" + "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/pkg/errors" ) diff --git a/pkg/backup/storage/s3/client_test.go b/pkg/backup/storage/s3/client_test.go index 6ea5b5a6b..cbabc0c40 100644 --- a/pkg/backup/storage/s3/client_test.go +++ b/pkg/backup/storage/s3/client_test.go @@ -17,11 +17,11 @@ package s3 import ( "testing" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) func TestClientWithInvalidData(t *testing.T) { - storage := &v1.Storage{ + storage := &v1alpha1.Storage{ Provider: "s3", Config: map[string]string{ "region": "region", diff --git a/pkg/backup/storage/s3/config.go b/pkg/backup/storage/s3/config.go index 37aa671cf..14825e2d5 100644 --- a/pkg/backup/storage/s3/config.go +++ b/pkg/backup/storage/s3/config.go @@ -17,7 +17,7 @@ package s3 import ( "k8s.io/apimachinery/pkg/util/validation/field" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) // Config holds the credentials required to authenticate with an S3 compliant API. @@ -30,7 +30,7 @@ type Config struct { } // NewConfig creates an S3 configuration based on the input parameters. -func NewConfig(storage *v1.Storage, creds map[string]string) *Config { +func NewConfig(storage *v1alpha1.Storage, creds map[string]string) *Config { return &Config{ endpoint: storage.Config["endpoint"], region: storage.Config["region"], diff --git a/pkg/backup/storage/s3/config_test.go b/pkg/backup/storage/s3/config_test.go index d5e489e41..4f9557dd3 100644 --- a/pkg/backup/storage/s3/config_test.go +++ b/pkg/backup/storage/s3/config_test.go @@ -17,11 +17,11 @@ package s3 import ( "testing" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) func TestConfigFromSecretDataWithValidData(t *testing.T) { - storage := &v1.Storage{ + storage := &v1alpha1.Storage{ Provider: "s3", Config: map[string]string{ "endpoint": "endpoint", @@ -44,7 +44,7 @@ func TestConfigFromSecretDataWithValidData(t *testing.T) { } func TestConfigFromSecretDataWithInValidData(t *testing.T) { - storage := &v1.Storage{ + storage := &v1alpha1.Storage{ Provider: "s3", Config: map[string]string{ "endpoint": "endpoint", diff --git a/pkg/backup/storage/s3/provider.go b/pkg/backup/storage/s3/provider.go index d68610d81..16d903917 100644 --- a/pkg/backup/storage/s3/provider.go +++ b/pkg/backup/storage/s3/provider.go @@ -22,7 +22,7 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) // Provider is storage implementation of provider.Interface. @@ -33,7 +33,7 @@ type Provider struct { // NewStorage creates a provider capable of storing and retreiving objects against the specified // 's3' storage configuration and credentials. -func NewStorage(config *v1.Storage, creds map[string]string) (*Provider, error) { +func NewStorage(config *v1alpha1.Storage, creds map[string]string) (*Provider, error) { cfg := NewConfig(config, creds) if err := cfg.Validate(); err != nil { return nil, err diff --git a/pkg/backup/storage/storage.go b/pkg/backup/storage/storage.go index 0b99a0e59..5bbfff9a4 100644 --- a/pkg/backup/storage/storage.go +++ b/pkg/backup/storage/storage.go @@ -19,7 +19,7 @@ import ( "io" "strings" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/backup/storage/s3" ) @@ -39,7 +39,7 @@ type Interface interface { // NewStorageProvider accepts a secret map and uses its contents to determine the // desired object storage provider implementation. -func NewStorageProvider(config *v1.Storage, creds map[string]string) (Interface, error) { +func NewStorageProvider(config *v1alpha1.Storage, creds map[string]string) (Interface, error) { switch strings.ToLower(config.Provider) { case ProviderS3: return s3.NewStorage(config, creds) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 76d5b1cd8..f9c2dfbbe 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -15,14 +15,14 @@ package constants // MySQLClusterLabel is applied to all components of a MySQL cluster -const MySQLClusterLabel = "v1.mysql.oracle.com/cluster" +const MySQLClusterLabel = "v1alpha1.mysql.oracle.com/cluster" // MySQLOperatorVersionLabel denotes the version of the MySQLOperator and // MySQLOperatorAgent running in the cluster. -const MySQLOperatorVersionLabel = "v1.mysql.oracle.com/version" +const MySQLOperatorVersionLabel = "v1alpha1.mysql.oracle.com/version" // LabelMySQLClusterRole specifies the role of a Pod within a MySQLCluster. -const LabelMySQLClusterRole = "v1.mysql.oracle.com/role" +const LabelMySQLClusterRole = "v1alpha1.mysql.oracle.com/role" // MySQLClusterRolePrimary denotes a primary InnoDB cluster member. const MySQLClusterRolePrimary = "primary" diff --git a/pkg/controllers/backup/agent_controller.go b/pkg/controllers/backup/agent_controller.go index 0234381e8..876d8e5b6 100644 --- a/pkg/controllers/backup/agent_controller.go +++ b/pkg/controllers/backup/agent_controller.go @@ -37,13 +37,13 @@ import ( record "k8s.io/client-go/tools/record" workqueue "k8s.io/client-go/util/workqueue" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" backuputil "github.com/oracle/mysql-operator/pkg/backup" executor "github.com/oracle/mysql-operator/pkg/backup/executor" controllerutils "github.com/oracle/mysql-operator/pkg/controllers/util" - mysqlv1client "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" - informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - listers "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" kubeutil "github.com/oracle/mysql-operator/pkg/util/kube" metrics "github.com/oracle/mysql-operator/pkg/util/metrics" ) @@ -57,7 +57,7 @@ type AgentController struct { podName string kubeClient kubernetes.Interface - client mysqlv1client.MySQLBackupsGetter + client clientset.MySQLBackupsGetter syncHandler func(key string) error // podLister is able to list/get Pods from a shared informer's store. @@ -68,14 +68,14 @@ type AgentController struct { // clusterLister is able to list/get MySQLClusters from a shared informer's // store. - clusterLister listers.MySQLClusterLister + clusterLister listersv1alpha1.MySQLClusterLister // clusterListerSynced returns true if the MySQLCluster shared informer has // synced at least once. clusterListerSynced cache.InformerSynced // backupLister is able to list/get MySQLBackups from a shared informer's // store. - backupLister listers.MySQLBackupLister + backupLister listersv1alpha1.MySQLBackupLister // backupListerSynced returns true if the MySQLBackup shared informer has // synced at least once. backupListerSynced cache.InformerSynced @@ -89,9 +89,9 @@ type AgentController struct { // NewAgentController constructs a new AgentController. func NewAgentController( kubeClient kubernetes.Interface, - client mysqlv1client.MySQLBackupsGetter, - backupInformer informers.MySQLBackupInformer, - clusterInformer informers.MySQLClusterInformer, + client clientset.MySQLBackupsGetter, + backupInformer informersv1alpha1.MySQLBackupInformer, + clusterInformer informersv1alpha1.MySQLClusterInformer, podInformer corev1informers.PodInformer, podName string, ) *AgentController { @@ -121,8 +121,8 @@ func NewAgentController( backupInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ UpdateFunc: func(oldObj, newObj interface{}) { - new := newObj.(*api.MySQLBackup) - if new.Status.Phase == api.BackupPhaseScheduled && new.Spec.AgentScheduled == c.podName { + new := newObj.(*v1alpha1.MySQLBackup) + if new.Status.Phase == v1alpha1.BackupPhaseScheduled && new.Spec.AgentScheduled == c.podName { key, err := cache.MetaNamespaceKeyFunc(new) if err != nil { glog.Errorf("Error creating queue key, item not added to queue: %v", err) @@ -276,10 +276,10 @@ func (controller *AgentController) processBackup(key string) error { // and support users fixing validation errors via updates (rather than // recreation). if validationErr != nil { - backup.Status.Phase = api.BackupPhaseFailed + backup.Status.Phase = v1alpha1.BackupPhaseFailed backup, err = controller.client.MySQLBackups(ns).Update(backup) if err != nil { - return errors.Wrapf(err, "failed to update (phase=%q)", api.BackupPhaseFailed) + return errors.Wrapf(err, "failed to update (phase=%q)", v1alpha1.BackupPhaseFailed) } controller.recorder.Eventf(backup, corev1.EventTypeWarning, "FailedValidation", validationErr.Error()) @@ -294,10 +294,10 @@ func (controller *AgentController) processBackup(key string) error { return nil } -func (controller *AgentController) performBackup(backup *api.MySQLBackup, creds *corev1.Secret) error { +func (controller *AgentController) performBackup(backup *v1alpha1.MySQLBackup, creds *corev1.Secret) error { // Update backup phase to started. started := time.Now() - backup.Status.Phase = api.BackupPhaseStarted + backup.Status.Phase = v1alpha1.BackupPhaseStarted backup.Status.TimeStarted = metav1.Time{Time: started} backup, err := controller.client.MySQLBackups(backup.Namespace).Update(backup) if err != nil { @@ -313,7 +313,7 @@ func (controller *AgentController) performBackup(backup *api.MySQLBackup, creds runner, err := backuputil.NewConfiguredRunner(backup.Spec.Executor, executor.DefaultCreds(), backup.Spec.Storage, credsMap) if err != nil { - backup.Status.Phase = api.BackupPhaseFailed + backup.Status.Phase = v1alpha1.BackupPhaseFailed backup, updateErr := controller.client.MySQLBackups(backup.Namespace).Update(backup) if updateErr != nil { return errors.Wrapf(err, "failed to mark MySQLBackup %q as failed", kubeutil.NamespaceAndName(backup)) @@ -325,7 +325,7 @@ func (controller *AgentController) performBackup(backup *api.MySQLBackup, creds key, err := runner.Backup(fmt.Sprintf("%s-%s", backup.Spec.ClusterRef.Name, backup.Name)) if err != nil { - backup.Status.Phase = api.BackupPhaseFailed + backup.Status.Phase = v1alpha1.BackupPhaseFailed backup, updateErr := controller.client.MySQLBackups(backup.Namespace).Update(backup) if updateErr != nil { return errors.Wrapf(err, "failed to mark MySQLBackup %q as failed", kubeutil.NamespaceAndName(backup)) @@ -337,9 +337,9 @@ func (controller *AgentController) performBackup(backup *api.MySQLBackup, creds finished := time.Now() - backup.Status.Phase = api.BackupPhaseComplete + backup.Status.Phase = v1alpha1.BackupPhaseComplete backup.Status.TimeCompleted = metav1.Time{Time: finished} - backup.Status.Outcome = api.BackupOutcome{Location: key} + backup.Status.Outcome = v1alpha1.BackupOutcome{Location: key} backup, err = controller.client.MySQLBackups(backup.Namespace).Update(backup) if err != nil { return errors.Wrapf(err, "failed to mark MySQLBackup %q as complete", kubeutil.NamespaceAndName(backup)) diff --git a/pkg/controllers/backup/metrics.go b/pkg/controllers/backup/metrics.go index 05a545ab1..2e23309a7 100644 --- a/pkg/controllers/backup/metrics.go +++ b/pkg/controllers/backup/metrics.go @@ -22,6 +22,7 @@ var ( clusterBackupCount = metrics.NewAgentEventCounter("cluster_backups", "Total number of times the cluster has been backed up") ) +// RegisterMetrics registers the backup metrics. func RegisterMetrics() { metrics.RegisterAgentMetric(clusterBackupCount) } diff --git a/pkg/controllers/backup/operator_controller.go b/pkg/controllers/backup/operator_controller.go index b6e230c7c..d9b7f6a33 100644 --- a/pkg/controllers/backup/operator_controller.go +++ b/pkg/controllers/backup/operator_controller.go @@ -35,12 +35,12 @@ import ( record "k8s.io/client-go/tools/record" workqueue "k8s.io/client-go/util/workqueue" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" clusterlabeler "github.com/oracle/mysql-operator/pkg/controllers/cluster/labeler" controllerutils "github.com/oracle/mysql-operator/pkg/controllers/util" - mysqlv1client "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" - informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - listers "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" kubeutil "github.com/oracle/mysql-operator/pkg/util/kube" ) @@ -50,12 +50,12 @@ const controllerAgentName = "operator-backup-controller" // MySQLBackups to be executed on a specific (primary) mysql-agent. It is run // in the operator. type OperatorController struct { - client mysqlv1client.MySQLBackupsGetter + client clientset.MySQLBackupsGetter syncHandler func(key string) error // backupLister is able to list/get MySQLBackups from a shared informer's // store. - backupLister listers.MySQLBackupLister + backupLister listersv1alpha1.MySQLBackupLister // backupListerSynced returns true if the MySQLBackup shared informer has // synced at least once. backupListerSynced cache.InformerSynced @@ -68,7 +68,7 @@ type OperatorController struct { // clusterLister is able to list/get MySQLClusters from a shared informer's // store. - clusterLister listers.MySQLClusterLister + clusterLister listersv1alpha1.MySQLClusterLister // clusterListerSynced returns true if the MySQLCluster shared informer has // synced at least once. clusterListerSynced cache.InformerSynced @@ -82,9 +82,9 @@ type OperatorController struct { // NewOperatorController constructs a new OperatorController. func NewOperatorController( kubeClient kubernetes.Interface, - client mysqlv1client.MySQLBackupsGetter, - backupInformer informers.MySQLBackupInformer, - clusterInformer informers.MySQLClusterInformer, + client clientset.MySQLBackupsGetter, + backupInformer informersv1alpha1.MySQLBackupInformer, + clusterInformer informersv1alpha1.MySQLClusterInformer, podInformer corev1informers.PodInformer, ) *OperatorController { // Create event broadcaster. @@ -111,10 +111,10 @@ func NewOperatorController( backupInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - backup := obj.(*api.MySQLBackup) + backup := obj.(*v1alpha1.MySQLBackup) switch backup.Status.Phase { - case api.BackupPhaseUnknown, api.BackupPhaseNew: + case v1alpha1.BackupPhaseUnknown, v1alpha1.BackupPhaseNew: // Only process new backups. default: glog.V(2).Infof("MySQLBackup %q is not new, skipping (phase=%q)", @@ -257,10 +257,10 @@ func (controller *OperatorController) processBackup(key string) error { // and support users fixing validation errors via updates (rather than // recreation). if validationErr != nil { - backup.Status.Phase = api.BackupPhaseFailed + backup.Status.Phase = v1alpha1.BackupPhaseFailed backup, err = controller.client.MySQLBackups(ns).Update(backup) if err != nil { - return errors.Wrapf(err, "failed to update (phase=%q)", api.BackupPhaseFailed) + return errors.Wrapf(err, "failed to update (phase=%q)", v1alpha1.BackupPhaseFailed) } controller.recorder.Event(backup, corev1.EventTypeWarning, "FailedValidation", validationErr.Error()) @@ -286,7 +286,7 @@ func (controller *OperatorController) processBackup(key string) error { } // scheduleBackup schedules a MySQLBackup on a specific member of a MySQLCluster. -func (controller *OperatorController) scheduleBackup(backup *api.MySQLBackup) (*api.MySQLBackup, error) { +func (controller *OperatorController) scheduleBackup(backup *v1alpha1.MySQLBackup) (*v1alpha1.MySQLBackup, error) { var ( name = backup.Spec.ClusterRef.Name ns = backup.Namespace @@ -298,7 +298,7 @@ func (controller *OperatorController) scheduleBackup(backup *api.MySQLBackup) (* return backup, errors.Wrap(err, "error listing Pods to choose secondary") } if len(secondaries) > 0 { - backup.Status.Phase = api.BackupPhaseScheduled + backup.Status.Phase = v1alpha1.BackupPhaseScheduled backup.Spec.AgentScheduled = secondaries[0].Name return backup, nil } @@ -309,7 +309,7 @@ func (controller *OperatorController) scheduleBackup(backup *api.MySQLBackup) (* return backup, errors.Wrap(err, "error listing Pods to choose primary") } if len(primaries) > 0 { - backup.Status.Phase = api.BackupPhaseScheduled + backup.Status.Phase = v1alpha1.BackupPhaseScheduled backup.Spec.AgentScheduled = primaries[0].Name return backup, nil } diff --git a/pkg/controllers/backup/schedule/controller.go b/pkg/controllers/backup/schedule/controller.go index 46b9442d9..728b74e5a 100644 --- a/pkg/controllers/backup/schedule/controller.go +++ b/pkg/controllers/backup/schedule/controller.go @@ -38,10 +38,10 @@ import ( "github.com/pkg/errors" "github.com/robfig/cron" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" mysqlop "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" - opinformers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - oplisters "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + opinformers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + oplisters "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" ) const controllerName = "backupschedule-controller" @@ -96,10 +96,10 @@ func NewController( backupScheduleInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - bs := obj.(*api.MySQLBackupSchedule) + bs := obj.(*v1alpha1.MySQLBackupSchedule) switch bs.Status.Phase { - case "", api.BackupSchedulePhaseNew, api.BackupSchedulePhaseEnabled: + case "", v1alpha1.BackupSchedulePhaseNew, v1alpha1.BackupSchedulePhaseEnabled: // add to work queue default: glog.V(4).Info("Backup schedule is not new, skipping") @@ -168,7 +168,7 @@ func (controller *Controller) enqueueAllEnabledSchedules() { } for _, bs := range backupSchedules { - if bs.Status.Phase != api.BackupSchedulePhaseEnabled { + if bs.Status.Phase != v1alpha1.BackupSchedulePhaseEnabled { continue } @@ -232,7 +232,7 @@ func (controller *Controller) processSchedule(key string) error { } switch bs.Status.Phase { - case "", api.BackupSchedulePhaseNew, api.BackupSchedulePhaseEnabled: + case "", v1alpha1.BackupSchedulePhaseNew, v1alpha1.BackupSchedulePhaseEnabled: // valid phase for processing default: return nil @@ -254,19 +254,19 @@ func (controller *Controller) processSchedule(key string) error { cronSchedule, errs := parseCronSchedule(bs) if len(errs) > 0 { - bs.Status.Phase = api.BackupSchedulePhaseFailedValidation + bs.Status.Phase = v1alpha1.BackupSchedulePhaseFailedValidation for _, err := range errs { controller.recorder.Event(bs, corev1.EventTypeWarning, CronScheduleValidationError, err) } } else { - bs.Status.Phase = api.BackupSchedulePhaseEnabled + bs.Status.Phase = v1alpha1.BackupSchedulePhaseEnabled } // update status if it's changed if currentPhase != bs.Status.Phase { - var updatedBackupSchedule *api.MySQLBackupSchedule + var updatedBackupSchedule *v1alpha1.MySQLBackupSchedule err := retry.RetryOnConflict(retry.DefaultRetry, func() error { - updatedBackupSchedule, err = controller.opClient.MysqlV1().MySQLBackupSchedules(ns).Update(bs) + updatedBackupSchedule, err = controller.opClient.MysqlV1alpha1().MySQLBackupSchedules(ns).Update(bs) if err != nil { return errors.Wrapf(err, "error updating backup schedule phase to %q", bs.Status.Phase) } @@ -278,7 +278,7 @@ func (controller *Controller) processSchedule(key string) error { bs = updatedBackupSchedule } - if bs.Status.Phase != api.BackupSchedulePhaseEnabled { + if bs.Status.Phase != v1alpha1.BackupSchedulePhaseEnabled { return nil } @@ -286,7 +286,7 @@ func (controller *Controller) processSchedule(key string) error { return controller.submitBackupIfDue(bs, cronSchedule) } -func parseCronSchedule(item *api.MySQLBackupSchedule) (cron.Schedule, []string) { +func parseCronSchedule(item *v1alpha1.MySQLBackupSchedule) (cron.Schedule, []string) { var validationErrors []string var schedule cron.Schedule @@ -321,7 +321,7 @@ func parseCronSchedule(item *api.MySQLBackupSchedule) (cron.Schedule, []string) return schedule, nil } -func (controller *Controller) submitBackupIfDue(item *api.MySQLBackupSchedule, cronSchedule cron.Schedule) error { +func (controller *Controller) submitBackupIfDue(item *v1alpha1.MySQLBackupSchedule, cronSchedule cron.Schedule) error { var ( now = controller.clock.Now() isDue, nextRunTime = getNextRunTime(item, cronSchedule, now) @@ -336,7 +336,7 @@ func (controller *Controller) submitBackupIfDue(item *api.MySQLBackupSchedule, c // trigger a Backup if it's time. glog.Infof("Backup schedule %s[%s] is due, submitting Backup", item.Name, item.Spec.Schedule) backup := getBackup(item, now) - if _, err := controller.opClient.MysqlV1().MySQLBackups(backup.Namespace).Create(backup); err != nil { + if _, err := controller.opClient.MysqlV1alpha1().MySQLBackups(backup.Namespace).Create(backup); err != nil { return errors.Wrap(err, "error creating MySQLBackup") } @@ -345,7 +345,7 @@ func (controller *Controller) submitBackupIfDue(item *api.MySQLBackupSchedule, c bs.Status.LastBackup = metav1.NewTime(now) err := retry.RetryOnConflict(retry.DefaultRetry, func() error { - if _, err := controller.opClient.MysqlV1().MySQLBackupSchedules(bs.Namespace).Update(bs); err != nil { + if _, err := controller.opClient.MysqlV1alpha1().MySQLBackupSchedules(bs.Namespace).Update(bs); err != nil { return errors.Wrapf(err, "error updating backup schedule's LastBackup time to %v", bs.Status.LastBackup) } return nil @@ -359,7 +359,7 @@ func (controller *Controller) submitBackupIfDue(item *api.MySQLBackupSchedule, c // getNextRunTime gets the latest run time (if the backup schedule hasn't run // yet, this will be the zero value which will trigger an immediate backup). -func getNextRunTime(bs *api.MySQLBackupSchedule, cronSchedule cron.Schedule, asOf time.Time) (bool, time.Time) { +func getNextRunTime(bs *v1alpha1.MySQLBackupSchedule, cronSchedule cron.Schedule, asOf time.Time) (bool, time.Time) { lastBackupTime := bs.Status.LastBackup.Time nextRunTime := cronSchedule.Next(lastBackupTime) @@ -367,8 +367,8 @@ func getNextRunTime(bs *api.MySQLBackupSchedule, cronSchedule cron.Schedule, asO return asOf.After(nextRunTime), nextRunTime } -func getBackup(item *api.MySQLBackupSchedule, timestamp time.Time) *api.MySQLBackup { - backup := &api.MySQLBackup{ +func getBackup(item *v1alpha1.MySQLBackupSchedule, timestamp time.Time) *v1alpha1.MySQLBackup { + backup := &v1alpha1.MySQLBackup{ Spec: item.Spec.BackupTemplate, ObjectMeta: metav1.ObjectMeta{ Namespace: item.Namespace, diff --git a/pkg/controllers/backup/schedule/controller_test.go b/pkg/controllers/backup/schedule/controller_test.go index 05affb4e7..ed5a6f959 100644 --- a/pkg/controllers/backup/schedule/controller_test.go +++ b/pkg/controllers/backup/schedule/controller_test.go @@ -31,7 +31,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" constants "github.com/oracle/mysql-operator/pkg/constants" "github.com/oracle/mysql-operator/pkg/controllers/util" mysqlfake "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/fake" @@ -48,12 +48,12 @@ func TestProcessSchedule(t *testing.T) { tests := []struct { name string scheduleKey string - schedule *api.MySQLBackupSchedule + schedule *v1alpha1.MySQLBackupSchedule fakeClockTime string expectedErr bool - expectedSchedulePhaseUpdate *api.MySQLBackupSchedule - expectedScheduleLastBackupUpdate *api.MySQLBackupSchedule - expectedBackupCreate *api.MySQLBackup + expectedSchedulePhaseUpdate *v1alpha1.MySQLBackupSchedule + expectedScheduleLastBackupUpdate *v1alpha1.MySQLBackupSchedule + expectedBackupCreate *v1alpha1.MySQLBackup expectedEvents []string }{ { @@ -70,17 +70,17 @@ func TestProcessSchedule(t *testing.T) { }, { name: "schedule with phase FailedValidation does not get processed", - schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(api.BackupSchedulePhaseFailedValidation).MySQLBackupSchedule, + schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(v1alpha1.BackupSchedulePhaseFailedValidation).MySQLBackupSchedule, expectedErr: false, expectedEvents: []string{}, }, { name: "schedule with phase New gets validated and failed if invalid", - schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(api.BackupSchedulePhaseNew).MySQLBackupSchedule, + schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(v1alpha1.BackupSchedulePhaseNew).MySQLBackupSchedule, expectedErr: false, expectedSchedulePhaseUpdate: NewTestMySQLBackupSchedule("ns", "name"). WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseFailedValidation). + WithPhase(v1alpha1.BackupSchedulePhaseFailedValidation). MySQLBackupSchedule, expectedEvents: []string{"Warning CronScheduleValidationError Schedule must be a non-empty valid Cron expression"}, }, @@ -90,52 +90,52 @@ func TestProcessSchedule(t *testing.T) { expectedErr: false, expectedSchedulePhaseUpdate: NewTestMySQLBackupSchedule("ns", "name"). WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseFailedValidation). + WithPhase(v1alpha1.BackupSchedulePhaseFailedValidation). MySQLBackupSchedule, expectedEvents: []string{"Warning CronScheduleValidationError Schedule must be a non-empty valid Cron expression"}, }, { name: "schedule with phase Enabled gets re-validated and failed if invalid", - schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(api.BackupSchedulePhaseEnabled).MySQLBackupSchedule, + schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(v1alpha1.BackupSchedulePhaseEnabled).MySQLBackupSchedule, expectedErr: false, expectedSchedulePhaseUpdate: NewTestMySQLBackupSchedule("ns", "name"). WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseFailedValidation). + WithPhase(v1alpha1.BackupSchedulePhaseFailedValidation). MySQLBackupSchedule, expectedEvents: []string{"Warning CronScheduleValidationError Schedule must be a non-empty valid Cron expression"}, }, { name: "schedule with phase New gets validated and triggers a backup", - schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(api.BackupSchedulePhaseNew).WithCronSchedule("@every 5m").MySQLBackupSchedule, + schedule: NewTestMySQLBackupSchedule("ns", "name").WithPhase(v1alpha1.BackupSchedulePhaseNew).WithCronSchedule("@every 5m").MySQLBackupSchedule, fakeClockTime: "2017-01-01 12:00:00", expectedErr: false, expectedSchedulePhaseUpdate: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").MySQLBackupSchedule, expectedBackupCreate: NewTestMySQLBackup().WithNamespace("ns").WithName("name-20170101120000").WithLabel("backup-schedule", "name").MySQLBackup, expectedScheduleLastBackupUpdate: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, expectedEvents: []string{}, }, { name: "schedule with phase Enabled gets re-validated and triggers a backup if valid", schedule: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").MySQLBackupSchedule, fakeClockTime: "2017-01-01 12:00:00", expectedErr: false, expectedBackupCreate: NewTestMySQLBackup().WithNamespace("ns").WithName("name-20170101120000").WithLabel("backup-schedule", "name").MySQLBackup, expectedScheduleLastBackupUpdate: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, expectedEvents: []string{}, }, { name: "schedule that's already run gets LastBackup updated", schedule: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2000-01-01 00:00:00").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2000-01-01 00:00:00").MySQLBackupSchedule, fakeClockTime: "2017-01-01 12:00:00", expectedErr: false, expectedBackupCreate: NewTestMySQLBackup().WithNamespace("ns").WithName("name-20170101120000").WithLabel("backup-schedule", "name").MySQLBackup, expectedScheduleLastBackupUpdate: NewTestMySQLBackupSchedule("ns", "name").WithLabel(constants.MySQLOperatorVersionLabel, mysqlOperatorVersion). - WithPhase(api.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, + WithPhase(v1alpha1.BackupSchedulePhaseEnabled).WithCronSchedule("@every 5m").WithLastBackupTime("2017-01-01 12:00:00").MySQLBackupSchedule, expectedEvents: []string{}, }, } @@ -151,7 +151,7 @@ func TestProcessSchedule(t *testing.T) { c := NewController( mysqlopclient, kubeclient, - mysqlopInformerFactory.Mysql().V1().MySQLBackupSchedules(), + mysqlopInformerFactory.Mysql().V1alpha1().MySQLBackupSchedules(), time.Duration(0), metav1.NamespaceDefault, ) @@ -170,7 +170,7 @@ func TestProcessSchedule(t *testing.T) { c.clock = clock.NewFakeClock(testTime) if test.schedule != nil { - mysqlopInformerFactory.Mysql().V1().MySQLBackupSchedules().Informer().GetStore().Add(test.schedule) + mysqlopInformerFactory.Mysql().V1alpha1().MySQLBackupSchedules().Informer().GetStore().Add(test.schedule) // this is necessary so the Update() call returns the appropriate object mysqlopclient.PrependReactor("update", "mysqlbackupschedules", func(action core.Action) (bool, runtime.Object, error) { @@ -194,7 +194,7 @@ func TestProcessSchedule(t *testing.T) { if upd := test.expectedSchedulePhaseUpdate; upd != nil { action := core.NewUpdateAction( - api.SchemeGroupVersion.WithResource("mysqlbackupschedules"), + v1alpha1.SchemeGroupVersion.WithResource("mysqlbackupschedules"), upd.Namespace, upd) expectedActions = append(expectedActions, action) @@ -202,7 +202,7 @@ func TestProcessSchedule(t *testing.T) { if created := test.expectedBackupCreate; created != nil { action := core.NewCreateAction( - api.SchemeGroupVersion.WithResource("mysqlbackups"), + v1alpha1.SchemeGroupVersion.WithResource("mysqlbackups"), created.Namespace, created) expectedActions = append(expectedActions, action) @@ -210,7 +210,7 @@ func TestProcessSchedule(t *testing.T) { if upd := test.expectedScheduleLastBackupUpdate; upd != nil { action := core.NewUpdateAction( - api.SchemeGroupVersion.WithResource("mysqlbackupschedules"), + v1alpha1.SchemeGroupVersion.WithResource("mysqlbackupschedules"), upd.Namespace, upd) expectedActions = append(expectedActions, action) @@ -232,41 +232,41 @@ func TestProcessSchedule(t *testing.T) { func TestGetNextRunTime(t *testing.T) { tests := []struct { name string - schedule *api.MySQLBackupSchedule + schedule *v1alpha1.MySQLBackupSchedule lastRanOffset string expectedDue bool expectedNextRunTimeOffset string }{ { name: "first run", - schedule: &api.MySQLBackupSchedule{Spec: api.BackupScheduleSpec{Schedule: "@every 5m"}}, + schedule: &v1alpha1.MySQLBackupSchedule{Spec: v1alpha1.BackupScheduleSpec{Schedule: "@every 5m"}}, expectedDue: true, expectedNextRunTimeOffset: "5m", }, { name: "just ran", - schedule: &api.MySQLBackupSchedule{Spec: api.BackupScheduleSpec{Schedule: "@every 5m"}}, + schedule: &v1alpha1.MySQLBackupSchedule{Spec: v1alpha1.BackupScheduleSpec{Schedule: "@every 5m"}}, lastRanOffset: "0s", expectedDue: false, expectedNextRunTimeOffset: "5m", }, { name: "almost but not quite time to run", - schedule: &api.MySQLBackupSchedule{Spec: api.BackupScheduleSpec{Schedule: "@every 5m"}}, + schedule: &v1alpha1.MySQLBackupSchedule{Spec: v1alpha1.BackupScheduleSpec{Schedule: "@every 5m"}}, lastRanOffset: "4m59s", expectedDue: false, expectedNextRunTimeOffset: "5m", }, { name: "time to run again", - schedule: &api.MySQLBackupSchedule{Spec: api.BackupScheduleSpec{Schedule: "@every 5m"}}, + schedule: &v1alpha1.MySQLBackupSchedule{Spec: v1alpha1.BackupScheduleSpec{Schedule: "@every 5m"}}, lastRanOffset: "5m", expectedDue: true, expectedNextRunTimeOffset: "5m", }, { name: "several runs missed", - schedule: &api.MySQLBackupSchedule{Spec: api.BackupScheduleSpec{Schedule: "@every 5m"}}, + schedule: &v1alpha1.MySQLBackupSchedule{Spec: v1alpha1.BackupScheduleSpec{Schedule: "@every 5m"}}, lastRanOffset: "5h", expectedDue: true, expectedNextRunTimeOffset: "5m", @@ -308,11 +308,11 @@ func TestParseCronSchedule(t *testing.T) { // Start with a Schedule with: // - schedule: once a day at 9am // - last backup: 2017-08-10 12:27:00 (just happened) - s := &api.MySQLBackupSchedule{ - Spec: api.BackupScheduleSpec{ + s := &v1alpha1.MySQLBackupSchedule{ + Spec: v1alpha1.BackupScheduleSpec{ Schedule: "0 9 * * *", }, - Status: api.ScheduleStatus{ + Status: v1alpha1.ScheduleStatus{ LastBackup: metav1.NewTime(now), }, } @@ -350,64 +350,64 @@ func TestParseCronSchedule(t *testing.T) { func TestGetBackup(t *testing.T) { tests := []struct { name string - schedule *api.MySQLBackupSchedule + schedule *v1alpha1.MySQLBackupSchedule testClockTime string - expectedBackup *api.MySQLBackup + expectedBackup *v1alpha1.MySQLBackup }{ { name: "ensure name is formatted correctly (AM time)", - schedule: &api.MySQLBackupSchedule{ + schedule: &v1alpha1.MySQLBackupSchedule{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar", }, - Spec: api.BackupScheduleSpec{ - BackupTemplate: api.BackupSpec{}, + Spec: v1alpha1.BackupScheduleSpec{ + BackupTemplate: v1alpha1.BackupSpec{}, }, }, testClockTime: "2017-07-25 09:15:00", - expectedBackup: &api.MySQLBackup{ + expectedBackup: &v1alpha1.MySQLBackup{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar-20170725091500", }, - Spec: api.BackupSpec{}, + Spec: v1alpha1.BackupSpec{}, }, }, { name: "ensure name is formatted correctly (PM time)", - schedule: &api.MySQLBackupSchedule{ + schedule: &v1alpha1.MySQLBackupSchedule{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar", }, - Spec: api.BackupScheduleSpec{ - BackupTemplate: api.BackupSpec{}, + Spec: v1alpha1.BackupScheduleSpec{ + BackupTemplate: v1alpha1.BackupSpec{}, }, }, testClockTime: "2017-07-25 14:15:00", - expectedBackup: &api.MySQLBackup{ + expectedBackup: &v1alpha1.MySQLBackup{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar-20170725141500", }, - Spec: api.BackupSpec{}, + Spec: v1alpha1.BackupSpec{}, }, }, { name: "ensure schedule backup template is copied", - schedule: &api.MySQLBackupSchedule{ + schedule: &v1alpha1.MySQLBackupSchedule{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar", }, - Spec: api.BackupScheduleSpec{ - BackupTemplate: api.BackupSpec{ - Executor: &api.Executor{ + Spec: v1alpha1.BackupScheduleSpec{ + BackupTemplate: v1alpha1.BackupSpec{ + Executor: &v1alpha1.Executor{ Provider: "mysqldump", Databases: []string{"db1", "db2"}, }, - Storage: &api.Storage{ + Storage: &v1alpha1.Storage{ Provider: "s3", SecretRef: &corev1.LocalObjectReference{ Name: "backup-storage-creds", @@ -426,17 +426,17 @@ func TestGetBackup(t *testing.T) { }, }, testClockTime: "2017-07-25 09:15:00", - expectedBackup: &api.MySQLBackup{ + expectedBackup: &v1alpha1.MySQLBackup{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "bar-20170725091500", }, - Spec: api.BackupSpec{ - Executor: &api.Executor{ + Spec: v1alpha1.BackupSpec{ + Executor: &v1alpha1.Executor{ Provider: "mysqldump", Databases: []string{"db1", "db2"}, }, - Storage: &api.Storage{ + Storage: &v1alpha1.Storage{ Provider: "s3", SecretRef: &corev1.LocalObjectReference{ Name: "backup-storage-creds", diff --git a/pkg/controllers/cluster/cluster_control.go b/pkg/controllers/cluster/cluster_control.go index 6cadd143c..1f218f886 100644 --- a/pkg/controllers/cluster/cluster_control.go +++ b/pkg/controllers/cluster/cluster_control.go @@ -22,29 +22,29 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/util/retry" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" - mysqlop "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" - listers "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" ) type clusterUpdaterInterface interface { - UpdateClusterStatus(cluster *api.MySQLCluster, status *api.MySQLClusterStatus) error - UpdateClusterLabels(cluster *api.MySQLCluster, lbls labels.Set) error + UpdateClusterStatus(cluster *v1alpha1.MySQLCluster, status *v1alpha1.MySQLClusterStatus) error + UpdateClusterLabels(cluster *v1alpha1.MySQLCluster, lbls labels.Set) error } type clusterUpdater struct { - client mysqlop.Interface - lister listers.MySQLClusterLister + client clientset.Interface + lister listersv1alpha1.MySQLClusterLister } -func newClusterUpdater(client mysqlop.Interface, lister listers.MySQLClusterLister) clusterUpdaterInterface { +func newClusterUpdater(client clientset.Interface, lister listersv1alpha1.MySQLClusterLister) clusterUpdaterInterface { return &clusterUpdater{client: client, lister: lister} } -func (csu *clusterUpdater) UpdateClusterStatus(cluster *api.MySQLCluster, status *api.MySQLClusterStatus) error { +func (csu *clusterUpdater) UpdateClusterStatus(cluster *v1alpha1.MySQLCluster, status *v1alpha1.MySQLClusterStatus) error { return retry.RetryOnConflict(retry.DefaultRetry, func() error { cluster.Status = *status - _, updateErr := csu.client.MysqlV1().MySQLClusters(cluster.Namespace).Update(cluster) + _, updateErr := csu.client.MysqlV1alpha1().MySQLClusters(cluster.Namespace).Update(cluster) if updateErr == nil { return nil } @@ -61,10 +61,10 @@ func (csu *clusterUpdater) UpdateClusterStatus(cluster *api.MySQLCluster, status }) } -func (csu *clusterUpdater) UpdateClusterLabels(cluster *api.MySQLCluster, lbls labels.Set) error { +func (csu *clusterUpdater) UpdateClusterLabels(cluster *v1alpha1.MySQLCluster, lbls labels.Set) error { return retry.RetryOnConflict(retry.DefaultRetry, func() error { cluster.Labels = labels.Merge(labels.Set(cluster.Labels), lbls) - _, updateErr := csu.client.MysqlV1().MySQLClusters(cluster.Namespace).Update(cluster) + _, updateErr := csu.client.MysqlV1alpha1().MySQLClusters(cluster.Namespace).Update(cluster) if updateErr == nil { return nil } diff --git a/pkg/controllers/cluster/controller.go b/pkg/controllers/cluster/controller.go index f17560c80..d0c3bb0aa 100644 --- a/pkg/controllers/cluster/controller.go +++ b/pkg/controllers/cluster/controller.go @@ -41,13 +41,13 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" constants "github.com/oracle/mysql-operator/pkg/constants" controllerutils "github.com/oracle/mysql-operator/pkg/controllers/util" - mysqlop "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" opscheme "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" - opinformers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - oplisters "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" options "github.com/oracle/mysql-operator/cmd/mysql-operator/app/options" secrets "github.com/oracle/mysql-operator/pkg/resources/secrets" @@ -82,14 +82,14 @@ type MySQLController struct { opConfig options.MySQLOperatorServer kubeClient kubernetes.Interface - opClient mysqlop.Interface + opClient clientset.Interface shutdown bool queue workqueue.RateLimitingInterface // clusterLister is able to list/get MySQLClusters from a shared informer's // store. - clusterLister oplisters.MySQLClusterLister + clusterLister listersv1alpha1.MySQLClusterLister // clusterListerSynced returns true if the MySQLCluster shared informer has // synced at least once. clusterListerSynced cache.InformerSynced @@ -138,9 +138,9 @@ type MySQLController struct { // NewController creates a new MySQLController. func NewController( opConfig options.MySQLOperatorServer, - opClient mysqlop.Interface, + opClient clientset.Interface, kubeClient kubernetes.Interface, - clusterInformer opinformers.MySQLClusterInformer, + clusterInformer informersv1alpha1.MySQLClusterInformer, statefulSetInformer appsinformers.StatefulSetInformer, podInformer coreinformers.PodInformer, serviceInformer coreinformers.ServiceInformer, @@ -190,7 +190,7 @@ func NewController( m.enqueueCluster(new) }, DeleteFunc: func(obj interface{}) { - cluster, ok := obj.(*api.MySQLCluster) + cluster, ok := obj.(*v1alpha1.MySQLCluster) if ok { m.onClusterDeleted(cluster.Name) } @@ -421,7 +421,7 @@ func (m *MySQLController) syncHandler(key string) error { } // ensureMySQLOperatorVersion updates the MySQLOperator resource types that require it to make it consistent with the specifed operator version. -func (m *MySQLController) ensureMySQLOperatorVersion(c *api.MySQLCluster, ss *apps.StatefulSet, operatorVersion string) error { +func (m *MySQLController) ensureMySQLOperatorVersion(c *v1alpha1.MySQLCluster, ss *apps.StatefulSet, operatorVersion string) error { // Ensure the Pods belonging to the MySQLCluster are updated to the correct 'mysql-agent' image for the current MySQLOperator version. container := statefulsets.MySQLAgentName pods, err := m.podLister.List(SelectorForCluster(c)) @@ -460,16 +460,16 @@ func (m *MySQLController) ensureMySQLOperatorVersion(c *api.MySQLCluster, ss *ap } // updateClusterStatusForSS updates MySQLCluster statuses based on changes to their associated StatefulSets. -func (m *MySQLController) updateClusterStatus(cluster *api.MySQLCluster, ss *apps.StatefulSet) error { +func (m *MySQLController) updateClusterStatus(cluster *v1alpha1.MySQLCluster, ss *apps.StatefulSet) error { glog.V(4).Infof("%s/%s: ss.Spec.Replicas=%d, ss.Status.ReadyReplicas=%d, ss.Status.Replicas=%d", cluster.Namespace, cluster.Name, *ss.Spec.Replicas, ss.Status.ReadyReplicas, ss.Status.Replicas) phase := cluster.Status.Phase if (ss.Status.ReadyReplicas < ss.Status.Replicas) || (*ss.Spec.Replicas != ss.Status.Replicas) { - phase = api.MySQLClusterPending + phase = v1alpha1.MySQLClusterPending } else if ss.Status.ReadyReplicas == ss.Status.Replicas { - phase = api.MySQLClusterRunning + phase = v1alpha1.MySQLClusterRunning } if phase != cluster.Status.Phase { @@ -520,7 +520,7 @@ func (m *MySQLController) handleObject(obj interface{}) { if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { // If this object is not owned by a MySQLCluster, we should not do // anything more with it. - if ownerRef.Kind != api.MySQLClusterCRDResourceKind { + if ownerRef.Kind != v1alpha1.MySQLClusterCRDResourceKind { return } diff --git a/pkg/controllers/cluster/controller_test.go b/pkg/controllers/cluster/controller_test.go index ba1cf518c..5a4ae7e3c 100644 --- a/pkg/controllers/cluster/controller_test.go +++ b/pkg/controllers/cluster/controller_test.go @@ -31,12 +31,12 @@ import ( cache "k8s.io/client-go/tools/cache" options "github.com/oracle/mysql-operator/cmd/mysql-operator/app/options" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/constants" "github.com/oracle/mysql-operator/pkg/controllers/util" mysqlfake "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/fake" - mysqlinformer_factory "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions" - mysqlinformer "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" + informerfactory "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/resources/secrets" statefulsets "github.com/oracle/mysql-operator/pkg/resources/statefulsets" buildversion "github.com/oracle/mysql-operator/pkg/version" @@ -50,7 +50,7 @@ func mockOperatorConfig() options.MySQLOperatorServer { func TestMessageResourceExistsFormatString(t *testing.T) { ss := statefulsets.NewForCluster( - &api.MySQLCluster{ + &v1alpha1.MySQLCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", Namespace: "default", @@ -124,7 +124,7 @@ func TestSyncEnsureClusterLabels(t *testing.T) { } func assertOperatorClusterInvariants(t *testing.T, controller *MySQLController, namespace string, name string, version string) { - cluster, err := controller.opClient.MysqlV1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) + cluster, err := controller.opClient.MysqlV1alpha1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("Get client MySQLCluster err: %+v", err) } @@ -156,7 +156,7 @@ func TestSyncEnsureSecret(t *testing.T) { assertOperatorSecretInvariants(t, fakeController, cluster) } -func assertOperatorSecretInvariants(t *testing.T, controller *MySQLController, cluster *api.MySQLCluster) { +func assertOperatorSecretInvariants(t *testing.T, controller *MySQLController, cluster *v1alpha1.MySQLCluster) { secretName := secrets.GetRootPasswordSecretName(cluster) secret, err := controller.kubeClient.CoreV1().Secrets(cluster.Namespace).Get(secretName, metav1.GetOptions{}) if err != nil { @@ -194,7 +194,7 @@ func TestSyncEnsureService(t *testing.T) { assertOperatorServiceInvariants(t, fakeController, cluster) } -func assertOperatorServiceInvariants(t *testing.T, controller *MySQLController, cluster *api.MySQLCluster) { +func assertOperatorServiceInvariants(t *testing.T, controller *MySQLController, cluster *v1alpha1.MySQLCluster) { kubeClient := controller.kubeClient service, err := kubeClient.CoreV1().Services(cluster.Namespace).Get(cluster.Name, metav1.GetOptions{}) if err != nil { @@ -236,7 +236,7 @@ func TestSyncEnsureStatefulSet(t *testing.T) { assertOperatorStatefulSetInvariants(t, fakeController, cluster) } -func assertOperatorStatefulSetInvariants(t *testing.T, controller *MySQLController, cluster *api.MySQLCluster) { +func assertOperatorStatefulSetInvariants(t *testing.T, controller *MySQLController, cluster *v1alpha1.MySQLCluster) { kubeClient := controller.kubeClient statefulset, err := kubeClient.AppsV1beta1().StatefulSets(cluster.Namespace).Get(cluster.Name, metav1.GetOptions{}) if err != nil { @@ -334,7 +334,7 @@ func assertOperatorVersionInvariants(t *testing.T, controller *MySQLController, expectedImageVersion := mockOperatorConfig().Images.MySQLAgentImage + ":" + version // Check MySQLCluster has the correct operator version - updatedCluster, err := controller.opClient.MysqlV1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) + updatedCluster, err := controller.opClient.MysqlV1alpha1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("Get client MySQLCluster err: %+v", err) } @@ -405,13 +405,13 @@ func TestMySQLControllerSyncClusterFromScratch(t *testing.T) { assertOperatorServiceInvariants(t, fakeController, cluster) assertOperatorStatefulSetInvariants(t, fakeController, cluster) assertOperatorVersionInvariants(t, fakeController, namespace, name, version) - cluster, err := fakeController.opClient.MysqlV1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) + cluster, err := fakeController.opClient.MysqlV1alpha1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("Get client MySQLCluster err: %+v", err) } } -func hasOwnerReference(ownerReferences []metav1.OwnerReference, cluster *api.MySQLCluster) bool { +func hasOwnerReference(ownerReferences []metav1.OwnerReference, cluster *v1alpha1.MySQLCluster) bool { for _, or := range ownerReferences { if or.APIVersion == cluster.APIVersion && or.Kind == cluster.Kind && or.Name == cluster.Name { return true @@ -429,20 +429,18 @@ func hasContainer(containers []v1.Container, name string) bool { return false } -// mock objects ********** - -func mockMySQLCluster(operatorVersion string, name string, namespace string, replicas int32) *api.MySQLCluster { - cluster := &api.MySQLCluster{ +func mockMySQLCluster(operatorVersion string, name string, namespace string, replicas int32) *v1alpha1.MySQLCluster { + cluster := &v1alpha1.MySQLCluster{ TypeMeta: metav1.TypeMeta{ Kind: "MySQLCluster", - APIVersion: "mysql.oracle.com/v1", + APIVersion: "mysql.oracle.com/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Labels: map[string]string{constants.MySQLClusterLabel: name, constants.MySQLOperatorVersionLabel: operatorVersion}, }, - Spec: api.MySQLClusterSpec{ + Spec: v1alpha1.MySQLClusterSpec{ Replicas: replicas, }, } @@ -450,7 +448,7 @@ func mockMySQLCluster(operatorVersion string, name string, namespace string, rep return cluster } -func mockClusterStatefulSet(cluster *api.MySQLCluster) *apps.StatefulSet { +func mockClusterStatefulSet(cluster *v1alpha1.MySQLCluster) *apps.StatefulSet { return statefulsets.NewForCluster(cluster, mockOperatorConfig().Images, cluster.Name) } @@ -495,7 +493,7 @@ func alwaysReady() bool { return true } // fakeMySQLControllerInformers contain references to the set of underlying informers associated // with a newFakeMySQLController. type fakeMySQLControllerInformers struct { - clusterInformer mysqlinformer.MySQLClusterInformer + clusterInformer informersv1alpha1.MySQLClusterInformer statefulSetInformer appsinformers.StatefulSetInformer podInformer coreinformers.PodInformer serviceInformer coreinformers.ServiceInformer @@ -503,15 +501,15 @@ type fakeMySQLControllerInformers struct { // newFakeMySQLController creates a new fake MySQLController with a fake mysqlop and kube clients and informers // for unit testing. -func newFakeMySQLController(cluster *api.MySQLCluster, kuberesources ...runtime.Object) (*MySQLController, *fakeMySQLControllerInformers) { +func newFakeMySQLController(cluster *v1alpha1.MySQLCluster, kuberesources ...runtime.Object) (*MySQLController, *fakeMySQLControllerInformers) { mysqlopClient := mysqlfake.NewSimpleClientset(cluster) kubeClient := fake.NewSimpleClientset(kuberesources...) kubeInformerFactory := informers.NewSharedInformerFactory(kubeClient, util.NoResyncPeriodFunc()) - mysqlopInformerFactory := mysqlinformer_factory.NewSharedInformerFactory(mysqlopClient, util.NoResyncPeriodFunc()) + mysqlopInformerFactory := informerfactory.NewSharedInformerFactory(mysqlopClient, util.NoResyncPeriodFunc()) fakeInformers := &fakeMySQLControllerInformers{ - clusterInformer: mysqlopInformerFactory.Mysql().V1().MySQLClusters(), + clusterInformer: mysqlopInformerFactory.Mysql().V1alpha1().MySQLClusters(), statefulSetInformer: kubeInformerFactory.Apps().V1beta1().StatefulSets(), podInformer: kubeInformerFactory.Core().V1().Pods(), serviceInformer: kubeInformerFactory.Core().V1().Services(), diff --git a/pkg/controllers/cluster/manager/metrics.go b/pkg/controllers/cluster/manager/metrics.go index 506c246c9..482af90f4 100644 --- a/pkg/controllers/cluster/manager/metrics.go +++ b/pkg/controllers/cluster/manager/metrics.go @@ -28,6 +28,7 @@ var ( instanceStatusCount = metrics.NewAgentStatusCounter("instance_status", "Total number of times the operator detects an instance with a specific innodb status") ) +// RegisterMetrics registers the cluster managemnent metrics. func RegisterMetrics() { metrics.RegisterAgentMetric(clusterCreateCount) metrics.RegisterAgentMetric(clusterCreateErrorCount) diff --git a/pkg/controllers/cluster/metrics.go b/pkg/controllers/cluster/metrics.go index c74459532..d90806a86 100644 --- a/pkg/controllers/cluster/metrics.go +++ b/pkg/controllers/cluster/metrics.go @@ -24,6 +24,7 @@ var ( clustersDeletedCount = metrics.NewOperatorEventCounter("clusters_deleted", "Total number of clusters deleted") ) +// RegisterMetrics registers the cluster CRUD metrics. func RegisterMetrics() { metrics.RegisterOperatorMetric(clustersTotalCount) metrics.RegisterOperatorMetric(clustersCreatedCount) diff --git a/pkg/controllers/cluster/pod_control.go b/pkg/controllers/cluster/pod_control.go index ca9764419..9ca0faf88 100644 --- a/pkg/controllers/cluster/pod_control.go +++ b/pkg/controllers/cluster/pod_control.go @@ -19,7 +19,7 @@ import ( "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" - corelisters "k8s.io/client-go/listers/core/v1" + corelistersv1 "k8s.io/client-go/listers/core/v1" "github.com/oracle/mysql-operator/pkg/constants" "github.com/oracle/mysql-operator/pkg/controllers/util" @@ -35,12 +35,12 @@ type PodControlInterface interface { type realPodControl struct { client kubernetes.Interface - podLister corelisters.PodLister + podLister corelistersv1.PodLister } // NewRealPodControl creates a concrete implementation of the // PodControlInterface. -func NewRealPodControl(client kubernetes.Interface, podLister corelisters.PodLister) PodControlInterface { +func NewRealPodControl(client kubernetes.Interface, podLister corelistersv1.PodLister) PodControlInterface { return &realPodControl{client: client, podLister: podLister} } diff --git a/pkg/controllers/cluster/secret_control.go b/pkg/controllers/cluster/secret_control.go index d931f897e..b9fd7cab0 100644 --- a/pkg/controllers/cluster/secret_control.go +++ b/pkg/controllers/cluster/secret_control.go @@ -19,7 +19,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/resources/secrets" ) @@ -27,7 +27,7 @@ import ( // uses to get and create Secrets. It is implemented as an interface to enable // testing. type SecretControlInterface interface { - GetForCluster(cluster *api.MySQLCluster) (*v1.Secret, error) + GetForCluster(cluster *v1alpha1.MySQLCluster) (*v1.Secret, error) CreateSecret(s *v1.Secret) error } @@ -41,7 +41,7 @@ func NewRealSecretControl(client kubernetes.Interface) SecretControlInterface { return &realSecretControl{client: client} } -func (rsc *realSecretControl) GetForCluster(cluster *api.MySQLCluster) (*v1.Secret, error) { +func (rsc *realSecretControl) GetForCluster(cluster *v1alpha1.MySQLCluster) (*v1.Secret, error) { return rsc.client.CoreV1(). Secrets(cluster.Namespace). Get(secrets.GetRootPasswordSecretName(cluster), metav1.GetOptions{}) diff --git a/pkg/controllers/cluster/service_control.go b/pkg/controllers/cluster/service_control.go index f7feab957..6e9f517be 100644 --- a/pkg/controllers/cluster/service_control.go +++ b/pkg/controllers/cluster/service_control.go @@ -15,29 +15,29 @@ package cluster import ( - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" - corelisters "k8s.io/client-go/listers/core/v1" + corelistersv1 "k8s.io/client-go/listers/core/v1" ) // ServiceControlInterface defines the interface that the MySQLClusterController // uses to create Services. It is implemented as an interface to enable testing. type ServiceControlInterface interface { - CreateService(s *v1.Service) error + CreateService(s *corev1.Service) error } type realServiceControl struct { client kubernetes.Interface - serviceLister corelisters.ServiceLister + serviceLister corelistersv1.ServiceLister } // NewRealServiceControl creates a concrete implementation of the // ServiceControlInterface. -func NewRealServiceControl(client kubernetes.Interface, serviceLister corelisters.ServiceLister) ServiceControlInterface { +func NewRealServiceControl(client kubernetes.Interface, serviceLister corelistersv1.ServiceLister) ServiceControlInterface { return &realServiceControl{client: client, serviceLister: serviceLister} } -func (rsc *realServiceControl) CreateService(s *v1.Service) error { +func (rsc *realServiceControl) CreateService(s *corev1.Service) error { _, err := rsc.client.CoreV1().Services(s.Namespace).Create(s) return err } diff --git a/pkg/controllers/cluster/statefulset_control.go b/pkg/controllers/cluster/statefulset_control.go index e3834e57b..ccc5c5a97 100644 --- a/pkg/controllers/cluster/statefulset_control.go +++ b/pkg/controllers/cluster/statefulset_control.go @@ -19,7 +19,7 @@ import ( apps "k8s.io/api/apps/v1beta1" kubernetes "k8s.io/client-go/kubernetes" - appslisters "k8s.io/client-go/listers/apps/v1beta1" + appslistersv1beta1 "k8s.io/client-go/listers/apps/v1beta1" "github.com/oracle/mysql-operator/pkg/constants" "github.com/oracle/mysql-operator/pkg/controllers/util" @@ -36,12 +36,12 @@ type StatefulSetControlInterface interface { type realStatefulSetControl struct { client kubernetes.Interface - statefulSetLister appslisters.StatefulSetLister + statefulSetLister appslistersv1beta1.StatefulSetLister } // NewRealStatefulSetControl creates a concrete implementation of the // StatefulSetControlInterface. -func NewRealStatefulSetControl(client kubernetes.Interface, statefulSetLister appslisters.StatefulSetLister) StatefulSetControlInterface { +func NewRealStatefulSetControl(client kubernetes.Interface, statefulSetLister appslistersv1beta1.StatefulSetLister) StatefulSetControlInterface { return &realStatefulSetControl{client: client, statefulSetLister: statefulSetLister} } diff --git a/pkg/controllers/cluster/statefulset_control_test.go b/pkg/controllers/cluster/statefulset_control_test.go index d4d83d826..9c8f3d971 100644 --- a/pkg/controllers/cluster/statefulset_control_test.go +++ b/pkg/controllers/cluster/statefulset_control_test.go @@ -16,7 +16,7 @@ package cluster import ( "github.com/oracle/mysql-operator/pkg/controllers/util" - apps "k8s.io/api/apps/v1beta1" + appsv1beta1 "k8s.io/api/apps/v1beta1" kubernetes "k8s.io/client-go/kubernetes" ) @@ -30,7 +30,7 @@ func NewFakeStatefulSetControl(statefulSetControl StatefulSetControlInterface, c return &fakeStatefulSetControl{statefulSetControl, client} } -func (rssc *fakeStatefulSetControl) Patch(old *apps.StatefulSet, new *apps.StatefulSet) error { +func (rssc *fakeStatefulSetControl) Patch(old *appsv1beta1.StatefulSet, new *appsv1beta1.StatefulSet) error { _, err := util.UpdateStatefulSet(rssc.client, new) return err } diff --git a/pkg/controllers/cluster/utils.go b/pkg/controllers/cluster/utils.go index d960906f3..3d85d6470 100644 --- a/pkg/controllers/cluster/utils.go +++ b/pkg/controllers/cluster/utils.go @@ -17,17 +17,17 @@ package cluster import ( "strings" - apps "k8s.io/api/apps/v1beta1" - "k8s.io/api/core/v1" + appsv1beta1 "k8s.io/api/apps/v1beta1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/constants" ) // SelectorForCluster creates a labels.Selector to match a given clusters // associated resources. -func SelectorForCluster(c *api.MySQLCluster) labels.Selector { +func SelectorForCluster(c *v1alpha1.MySQLCluster) labels.Selector { return labels.SelectorFromSet(labels.Set{constants.MySQLClusterLabel: c.Name}) } @@ -46,7 +46,7 @@ func combineSelectors(first labels.Selector, rest ...labels.Selector) labels.Sel return res } -func requiresMySQLAgentStatefulSetUpgrade(ss *apps.StatefulSet, targetContainer string, operatorVersion string) bool { +func requiresMySQLAgentStatefulSetUpgrade(ss *appsv1beta1.StatefulSet, targetContainer string, operatorVersion string) bool { if !SelectorForClusterOperatorVersion(operatorVersion).Matches(labels.Set(ss.Labels)) { return true } @@ -60,7 +60,7 @@ func requiresMySQLAgentStatefulSetUpgrade(ss *apps.StatefulSet, targetContainer return false } -func requiresMySQLAgentPodUpgrade(pod *v1.Pod, targetContainer string, operatorVersion string) bool { +func requiresMySQLAgentPodUpgrade(pod *corev1.Pod, targetContainer string, operatorVersion string) bool { if !SelectorForClusterOperatorVersion(operatorVersion).Matches(labels.Set(pod.Labels)) { return true } @@ -76,6 +76,6 @@ func requiresMySQLAgentPodUpgrade(pod *v1.Pod, targetContainer string, operatorV // canUpgradeMySQLAgent checks that pod can actually be updated (e.g. there no backups currently taking place). // TODO: Implement. -func canUpgradeMySQLAgent(pod *v1.Pod) bool { +func canUpgradeMySQLAgent(pod *corev1.Pod) bool { return true } diff --git a/pkg/controllers/controllers.go b/pkg/controllers/controllers.go deleted file mode 100644 index 863e14902..000000000 --- a/pkg/controllers/controllers.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 Oracle and/or its affiliates. All rights reserved. -// -// 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 controllers - -// Controller provides an interface for controller executors. -type Controller interface { - // Run executes the controller blocking until it recieves on the - // stopChan. - Run(stopChan <-chan struct{}) -} diff --git a/pkg/controllers/restore/agent_controller.go b/pkg/controllers/restore/agent_controller.go index 337fa61e5..0c685dd4b 100644 --- a/pkg/controllers/restore/agent_controller.go +++ b/pkg/controllers/restore/agent_controller.go @@ -36,13 +36,13 @@ import ( record "k8s.io/client-go/tools/record" workqueue "k8s.io/client-go/util/workqueue" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" backuputil "github.com/oracle/mysql-operator/pkg/backup" executor "github.com/oracle/mysql-operator/pkg/backup/executor" controllerutils "github.com/oracle/mysql-operator/pkg/controllers/util" - mysqlv1client "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" - informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - listers "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" kubeutil "github.com/oracle/mysql-operator/pkg/util/kube" metrics "github.com/oracle/mysql-operator/pkg/util/metrics" ) @@ -57,12 +57,12 @@ type AgentController struct { podName string kubeClient kubernetes.Interface - client mysqlv1client.MySQLRestoresGetter + client clientset.MySQLRestoresGetter syncHandler func(key string) error // restoreLister is able to list/get MySQLRestores from a shared informer's // store. - restoreLister listers.MySQLRestoreLister + restoreLister listersv1alpha1.MySQLRestoreLister // restoreListerSynced returns true if the MySQLRestore shared informer has // synced at least once. restoreListerSynced cache.InformerSynced @@ -75,14 +75,14 @@ type AgentController struct { // clusterLister is able to list/get MySQLClusters from a shared informer's // store. - clusterLister listers.MySQLClusterLister + clusterLister listersv1alpha1.MySQLClusterLister // clusterListerSynced returns true if the MySQLCluster shared informer has // synced at least once. clusterListerSynced cache.InformerSynced // backupLister is able to list/get MySQLBackups from a shared informer's // store. - backupLister listers.MySQLBackupLister + backupLister listersv1alpha1.MySQLBackupLister // backupListerSynced returns true if the MySQLBackup shared informer has // synced at least once. backupListerSynced cache.InformerSynced @@ -96,10 +96,10 @@ type AgentController struct { // NewAgentController constructs a new AgentController. func NewAgentController( kubeClient kubernetes.Interface, - client mysqlv1client.MySQLRestoresGetter, - restoreInformer informers.MySQLRestoreInformer, - clusterInformer informers.MySQLClusterInformer, - backupInformer informers.MySQLBackupInformer, + client clientset.MySQLRestoresGetter, + restoreInformer informersv1alpha1.MySQLRestoreInformer, + clusterInformer informersv1alpha1.MySQLClusterInformer, + backupInformer informersv1alpha1.MySQLBackupInformer, podInformer corev1informers.PodInformer, podName string, ) *AgentController { @@ -131,8 +131,8 @@ func NewAgentController( restoreInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ UpdateFunc: func(oldObj, newObj interface{}) { - new := newObj.(*api.MySQLRestore) - if new.Status.Phase == api.RestorePhaseScheduled && new.Spec.AgentScheduled == c.podName { + new := newObj.(*v1alpha1.MySQLRestore) + if new.Status.Phase == v1alpha1.RestorePhaseScheduled && new.Spec.AgentScheduled == c.podName { key, err := cache.MetaNamespaceKeyFunc(new) if err != nil { glog.Errorf("Error creating queue key, item not added to queue: %v", err) @@ -249,7 +249,7 @@ func (controller *AgentController) processRestore(key string) error { restore = restore.EnsureDefaults() var ( - backup *api.MySQLBackup + backup *v1alpha1.MySQLBackup creds *corev1.Secret ) @@ -299,10 +299,10 @@ func (controller *AgentController) processRestore(key string) error { // and support users fixing validation errors via updates (rather than // recreation). if validationErr != nil { - restore.Status.Phase = api.RestorePhaseFailed + restore.Status.Phase = v1alpha1.RestorePhaseFailed restore, err = controller.client.MySQLRestores(ns).Update(restore) if err != nil { - return errors.Wrapf(err, "failed to update (phase=%q)", api.RestorePhaseFailed) + return errors.Wrapf(err, "failed to update (phase=%q)", v1alpha1.RestorePhaseFailed) } controller.recorder.Eventf(restore, corev1.EventTypeWarning, "FailedValidation", validationErr.Error()) @@ -317,10 +317,10 @@ func (controller *AgentController) processRestore(key string) error { return nil } -func (controller *AgentController) performRestore(restore *api.MySQLRestore, backup *api.MySQLBackup, creds *corev1.Secret) error { +func (controller *AgentController) performRestore(restore *v1alpha1.MySQLRestore, backup *v1alpha1.MySQLBackup, creds *corev1.Secret) error { // Update restore phase to started. started := time.Now() - restore.Status.Phase = api.RestorePhaseStarted + restore.Status.Phase = v1alpha1.RestorePhaseStarted restore.Status.TimeStarted = metav1.Time{Time: started} restore, err := controller.client.MySQLRestores(restore.Namespace).Update(restore) if err != nil { @@ -336,7 +336,7 @@ func (controller *AgentController) performRestore(restore *api.MySQLRestore, bac runner, err := backuputil.NewConfiguredRunner(backup.Spec.Executor, executor.DefaultCreds(), backup.Spec.Storage, credsMap) if err != nil { - restore.Status.Phase = api.RestorePhaseFailed + restore.Status.Phase = v1alpha1.RestorePhaseFailed restore, updateErr := controller.client.MySQLRestores(restore.Namespace).Update(restore) if updateErr != nil { return errors.Wrapf(err, "failed to mark MySQLRestore %q as failed", kubeutil.NamespaceAndName(restore)) @@ -348,7 +348,7 @@ func (controller *AgentController) performRestore(restore *api.MySQLRestore, bac err = runner.Restore(backup.Status.Outcome.Location) if err != nil { - restore.Status.Phase = api.RestorePhaseFailed + restore.Status.Phase = v1alpha1.RestorePhaseFailed restore, updateErr := controller.client.MySQLRestores(restore.Namespace).Update(restore) if updateErr != nil { return errors.Wrapf(err, "failed to mark MySQLRestore %q as failed", kubeutil.NamespaceAndName(restore)) @@ -360,7 +360,7 @@ func (controller *AgentController) performRestore(restore *api.MySQLRestore, bac finished := time.Now() - restore.Status.Phase = api.RestorePhaseComplete + restore.Status.Phase = v1alpha1.RestorePhaseComplete restore.Status.TimeCompleted = metav1.Time{Time: finished} restore, err = controller.client.MySQLRestores(restore.Namespace).Update(restore) if err != nil { diff --git a/pkg/controllers/restore/metrics.go b/pkg/controllers/restore/metrics.go index 70c4c2931..80f2fd0e1 100644 --- a/pkg/controllers/restore/metrics.go +++ b/pkg/controllers/restore/metrics.go @@ -22,6 +22,7 @@ var ( clusterRestoreCount = metrics.NewAgentEventCounter("cluster_restores", "Total number of times the cluster has been restored") ) +// RegisterMetrics registers the restore metrics. func RegisterMetrics() { metrics.RegisterAgentMetric(clusterRestoreCount) } diff --git a/pkg/controllers/restore/operator_controller.go b/pkg/controllers/restore/operator_controller.go index ad27a5f58..ce3ca71dc 100644 --- a/pkg/controllers/restore/operator_controller.go +++ b/pkg/controllers/restore/operator_controller.go @@ -35,12 +35,12 @@ import ( record "k8s.io/client-go/tools/record" workqueue "k8s.io/client-go/util/workqueue" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" clusterlabeler "github.com/oracle/mysql-operator/pkg/controllers/cluster/labeler" controllerutils "github.com/oracle/mysql-operator/pkg/controllers/util" - mysqlv1client "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" - informers "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" - listers "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" + clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" + informersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" + listersv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" kubeutil "github.com/oracle/mysql-operator/pkg/util/kube" ) @@ -50,12 +50,12 @@ const controllerAgentName = "operator-restore-controller" // MySQLRestores to be executed on a specific (primary) mysql-agent. It is run // in the operator. type OperatorController struct { - client mysqlv1client.MySQLRestoresGetter + client clientset.MySQLRestoresGetter syncHandler func(key string) error // restoreLister is able to list/get MySQLRestores from a shared informer's // store. - restoreLister listers.MySQLRestoreLister + restoreLister listersv1alpha1.MySQLRestoreLister // restoreListerSynced returns true if the MySQLRestore shared informer has // synced at least once. restoreListerSynced cache.InformerSynced @@ -68,14 +68,14 @@ type OperatorController struct { // clusterLister is able to list/get MySQLClusters from a shared informer's // store. - clusterLister listers.MySQLClusterLister + clusterLister listersv1alpha1.MySQLClusterLister // clusterListerSynced returns true if the MySQLCluster shared informer has // synced at least once. clusterListerSynced cache.InformerSynced // backupLister is able to list/get MySQLBackups from a shared informer's // store. - backupLister listers.MySQLBackupLister + backupLister listersv1alpha1.MySQLBackupLister // backupListerSynced returns true if the MySQLBackup shared informer has // synced at least once. backupListerSynced cache.InformerSynced @@ -89,10 +89,10 @@ type OperatorController struct { // NewOperatorController constructs a new OperatorController. func NewOperatorController( kubeClient kubernetes.Interface, - client mysqlv1client.MySQLRestoresGetter, - restoreInformer informers.MySQLRestoreInformer, - clusterInformer informers.MySQLClusterInformer, - backupInformer informers.MySQLBackupInformer, + client clientset.MySQLRestoresGetter, + restoreInformer informersv1alpha1.MySQLRestoreInformer, + clusterInformer informersv1alpha1.MySQLClusterInformer, + backupInformer informersv1alpha1.MySQLBackupInformer, podInformer corev1informers.PodInformer, ) *OperatorController { // Create event broadcaster. @@ -121,10 +121,10 @@ func NewOperatorController( restoreInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - restore := obj.(*api.MySQLRestore) + restore := obj.(*v1alpha1.MySQLRestore) switch restore.Status.Phase { - case api.RestorePhaseUnknown, api.RestorePhaseNew: + case v1alpha1.RestorePhaseUnknown, v1alpha1.RestorePhaseNew: // Only process new restores. default: glog.V(2).Infof("MySQLRestore %q is not new, skipping (phase=%q)", @@ -279,10 +279,10 @@ func (controller *OperatorController) processRestore(key string) error { // and support users fixing validation errors via updates (rather than // recreation). if validationErr != nil { - restore.Status.Phase = api.RestorePhaseFailed + restore.Status.Phase = v1alpha1.RestorePhaseFailed restore, err = controller.client.MySQLRestores(ns).Update(restore) if err != nil { - return errors.Wrapf(err, "failed to update (phase=%q)", api.RestorePhaseFailed) + return errors.Wrapf(err, "failed to update (phase=%q)", v1alpha1.RestorePhaseFailed) } controller.recorder.Eventf(restore, corev1.EventTypeWarning, "FailedValidation", validationErr.Error()) @@ -307,7 +307,7 @@ func (controller *OperatorController) processRestore(key string) error { } // scheduleRestore schedules a MySQLRestore on a specific member of a MySQLCluster. -func (controller *OperatorController) scheduleRestore(restore *api.MySQLRestore) (*api.MySQLRestore, error) { +func (controller *OperatorController) scheduleRestore(restore *v1alpha1.MySQLRestore) (*v1alpha1.MySQLRestore, error) { var ( name = restore.Spec.ClusterRef.Name ns = restore.Namespace @@ -318,7 +318,7 @@ func (controller *OperatorController) scheduleRestore(restore *api.MySQLRestore) return restore, errors.Wrap(err, "error listing Pods") } if len(primaries) > 0 { - restore.Status.Phase = api.RestorePhaseScheduled + restore.Status.Phase = v1alpha1.RestorePhaseScheduled restore.Spec.AgentScheduled = primaries[0].Name return restore, nil } diff --git a/pkg/controllers/util/patch.go b/pkg/controllers/util/patch.go index 248febe18..f4b36eb3b 100644 --- a/pkg/controllers/util/patch.go +++ b/pkg/controllers/util/patch.go @@ -20,15 +20,15 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" - "k8s.io/api/apps/v1beta1" - "k8s.io/api/core/v1" + appsv1beta1 "k8s.io/api/apps/v1beta1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/client-go/kubernetes" ) // UpdateStatefulSet performs a direct update for the specified StatefulSet. -func UpdateStatefulSet(kubeClient kubernetes.Interface, newData *v1beta1.StatefulSet) (*v1beta1.StatefulSet, error) { +func UpdateStatefulSet(kubeClient kubernetes.Interface, newData *appsv1beta1.StatefulSet) (*appsv1beta1.StatefulSet, error) { result, err := kubeClient.AppsV1beta1().StatefulSets(newData.Namespace).Update(newData) if err != nil { glog.Errorf("Failed to update StatefulSet: %v", err) @@ -39,7 +39,7 @@ func UpdateStatefulSet(kubeClient kubernetes.Interface, newData *v1beta1.Statefu } // PatchStatefulSet performs a direct patch update for the specified StatefulSet. -func PatchStatefulSet(kubeClient kubernetes.Interface, oldData *v1beta1.StatefulSet, newData *v1beta1.StatefulSet) (*v1beta1.StatefulSet, error) { +func PatchStatefulSet(kubeClient kubernetes.Interface, oldData *appsv1beta1.StatefulSet, newData *appsv1beta1.StatefulSet) (*appsv1beta1.StatefulSet, error) { originalJSON, err := json.Marshal(oldData) if err != nil { return nil, err @@ -51,7 +51,7 @@ func PatchStatefulSet(kubeClient kubernetes.Interface, oldData *v1beta1.Stateful } patchBytes, err := strategicpatch.CreateTwoWayMergePatch( - originalJSON, updatedJSON, v1beta1.StatefulSet{}) + originalJSON, updatedJSON, appsv1beta1.StatefulSet{}) if err != nil { return nil, err } @@ -67,7 +67,7 @@ func PatchStatefulSet(kubeClient kubernetes.Interface, oldData *v1beta1.Stateful } // UpdatePod performs a direct update for the specified Pod. -func UpdatePod(kubeClient kubernetes.Interface, newData *v1.Pod) (*v1.Pod, error) { +func UpdatePod(kubeClient kubernetes.Interface, newData *corev1.Pod) (*corev1.Pod, error) { result, err := kubeClient.CoreV1().Pods(newData.Namespace).Update(newData) if err != nil { return nil, errors.Wrap(err, "failed to update pod") @@ -77,7 +77,7 @@ func UpdatePod(kubeClient kubernetes.Interface, newData *v1.Pod) (*v1.Pod, error } // PatchPod perform a direct patch update for the specified Pod. -func PatchPod(kubeClient kubernetes.Interface, oldData *v1.Pod, newData *v1.Pod) (*v1.Pod, error) { +func PatchPod(kubeClient kubernetes.Interface, oldData *corev1.Pod, newData *corev1.Pod) (*corev1.Pod, error) { currentPodJSON, err := json.Marshal(oldData) if err != nil { return nil, err @@ -88,7 +88,7 @@ func PatchPod(kubeClient kubernetes.Interface, oldData *v1.Pod, newData *v1.Pod) return nil, err } - patchBytes, err := strategicpatch.CreateTwoWayMergePatch(currentPodJSON, updatedPodJSON, v1.Pod{}) + patchBytes, err := strategicpatch.CreateTwoWayMergePatch(currentPodJSON, updatedPodJSON, corev1.Pod{}) if err != nil { return nil, err } diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 9ea38ff63..c922b5fba 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -16,7 +16,7 @@ package versioned import ( glog "github.com/golang/glog" - mysqlv1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" + mysqlv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -24,27 +24,27 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - MysqlV1() mysqlv1.MysqlV1Interface + MysqlV1alpha1() mysqlv1alpha1.MysqlV1alpha1Interface // Deprecated: please explicitly pick a version if possible. - Mysql() mysqlv1.MysqlV1Interface + Mysql() mysqlv1alpha1.MysqlV1alpha1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - mysqlV1 *mysqlv1.MysqlV1Client + mysqlV1alpha1 *mysqlv1alpha1.MysqlV1alpha1Client } -// MysqlV1 retrieves the MysqlV1Client -func (c *Clientset) MysqlV1() mysqlv1.MysqlV1Interface { - return c.mysqlV1 +// MysqlV1alpha1 retrieves the MysqlV1alpha1Client +func (c *Clientset) MysqlV1alpha1() mysqlv1alpha1.MysqlV1alpha1Interface { + return c.mysqlV1alpha1 } // Deprecated: Mysql retrieves the default version of MysqlClient. // Please explicitly pick a version. -func (c *Clientset) Mysql() mysqlv1.MysqlV1Interface { - return c.mysqlV1 +func (c *Clientset) Mysql() mysqlv1alpha1.MysqlV1alpha1Interface { + return c.mysqlV1alpha1 } // Discovery retrieves the DiscoveryClient @@ -63,7 +63,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.mysqlV1, err = mysqlv1.NewForConfig(&configShallowCopy) + cs.mysqlV1alpha1, err = mysqlv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -80,7 +80,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.mysqlV1 = mysqlv1.NewForConfigOrDie(c) + cs.mysqlV1alpha1 = mysqlv1alpha1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -89,7 +89,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.mysqlV1 = mysqlv1.New(c) + cs.mysqlV1alpha1 = mysqlv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 4f67a385c..4316c17e3 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -16,8 +16,8 @@ package fake import ( clientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" - mysqlv1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" - fakemysqlv1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1/fake" + mysqlv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" + fakemysqlv1alpha1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -58,12 +58,12 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { var _ clientset.Interface = &Clientset{} -// MysqlV1 retrieves the MysqlV1Client -func (c *Clientset) MysqlV1() mysqlv1.MysqlV1Interface { - return &fakemysqlv1.FakeMysqlV1{Fake: &c.Fake} +// MysqlV1alpha1 retrieves the MysqlV1alpha1Client +func (c *Clientset) MysqlV1alpha1() mysqlv1alpha1.MysqlV1alpha1Interface { + return &fakemysqlv1alpha1.FakeMysqlV1alpha1{Fake: &c.Fake} } -// Mysql retrieves the MysqlV1Client -func (c *Clientset) Mysql() mysqlv1.MysqlV1Interface { - return &fakemysqlv1.FakeMysqlV1{Fake: &c.Fake} +// Mysql retrieves the MysqlV1alpha1Client +func (c *Clientset) Mysql() mysqlv1alpha1.MysqlV1alpha1Interface { + return &fakemysqlv1alpha1.FakeMysqlV1alpha1{Fake: &c.Fake} } diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 289afc95f..477d73430 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -15,7 +15,7 @@ package fake import ( - mysqlv1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysqlv1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -46,6 +46,6 @@ func init() { // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. func AddToScheme(scheme *runtime.Scheme) { - mysqlv1.AddToScheme(scheme) + mysqlv1alpha1.AddToScheme(scheme) } diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index e580b41bb..70aafd81a 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -15,7 +15,7 @@ package scheme import ( - mysqlv1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysqlv1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -46,6 +46,6 @@ func init() { // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. func AddToScheme(scheme *runtime.Scheme) { - mysqlv1.AddToScheme(scheme) + mysqlv1alpha1.AddToScheme(scheme) } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/doc.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/doc.go similarity index 97% rename from pkg/generated/clientset/versioned/typed/mysql/v1/doc.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/doc.go index 0f1b5aa94..ae2b234f3 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/doc.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/doc.go @@ -13,4 +13,4 @@ // limitations under the License. // This package has the automatically generated typed clients. -package v1 +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/doc.go diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysql_client.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysql_client.go similarity index 65% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysql_client.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysql_client.go index 1fadb724b..5c9cdbd0d 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysql_client.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysql_client.go @@ -15,34 +15,34 @@ package fake import ( - v1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/typed/mysql/v1alpha1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeMysqlV1 struct { +type FakeMysqlV1alpha1 struct { *testing.Fake } -func (c *FakeMysqlV1) MySQLBackups(namespace string) v1.MySQLBackupInterface { +func (c *FakeMysqlV1alpha1) MySQLBackups(namespace string) v1alpha1.MySQLBackupInterface { return &FakeMySQLBackups{c, namespace} } -func (c *FakeMysqlV1) MySQLBackupSchedules(namespace string) v1.MySQLBackupScheduleInterface { +func (c *FakeMysqlV1alpha1) MySQLBackupSchedules(namespace string) v1alpha1.MySQLBackupScheduleInterface { return &FakeMySQLBackupSchedules{c, namespace} } -func (c *FakeMysqlV1) MySQLClusters(namespace string) v1.MySQLClusterInterface { +func (c *FakeMysqlV1alpha1) MySQLClusters(namespace string) v1alpha1.MySQLClusterInterface { return &FakeMySQLClusters{c, namespace} } -func (c *FakeMysqlV1) MySQLRestores(namespace string) v1.MySQLRestoreInterface { +func (c *FakeMysqlV1alpha1) MySQLRestores(namespace string) v1alpha1.MySQLRestoreInterface { return &FakeMySQLRestores{c, namespace} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeMysqlV1) RESTClient() rest.Interface { +func (c *FakeMysqlV1alpha1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackup.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackup.go similarity index 74% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackup.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackup.go index bfe7c5766..781868bbb 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackup.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackup.go @@ -15,7 +15,7 @@ package fake import ( - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,29 +26,29 @@ import ( // FakeMySQLBackups implements MySQLBackupInterface type FakeMySQLBackups struct { - Fake *FakeMysqlV1 + Fake *FakeMysqlV1alpha1 ns string } -var mysqlbackupsResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1", Resource: "mysqlbackups"} +var mysqlbackupsResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1alpha1", Resource: "mysqlbackups"} -var mysqlbackupsKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1", Kind: "MySQLBackup"} +var mysqlbackupsKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1alpha1", Kind: "MySQLBackup"} // Get takes name of the mySQLBackup, and returns the corresponding mySQLBackup object, and an error if there is any. -func (c *FakeMySQLBackups) Get(name string, options v1.GetOptions) (result *mysql_v1.MySQLBackup, err error) { +func (c *FakeMySQLBackups) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLBackup, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(mysqlbackupsResource, c.ns, name), &mysql_v1.MySQLBackup{}) + Invokes(testing.NewGetAction(mysqlbackupsResource, c.ns, name), &v1alpha1.MySQLBackup{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackup), err + return obj.(*v1alpha1.MySQLBackup), err } // List takes label and field selectors, and returns the list of MySQLBackups that match those selectors. -func (c *FakeMySQLBackups) List(opts v1.ListOptions) (result *mysql_v1.MySQLBackupList, err error) { +func (c *FakeMySQLBackups) List(opts v1.ListOptions) (result *v1alpha1.MySQLBackupList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(mysqlbackupsResource, mysqlbackupsKind, c.ns, opts), &mysql_v1.MySQLBackupList{}) + Invokes(testing.NewListAction(mysqlbackupsResource, mysqlbackupsKind, c.ns, opts), &v1alpha1.MySQLBackupList{}) if obj == nil { return nil, err @@ -58,8 +58,8 @@ func (c *FakeMySQLBackups) List(opts v1.ListOptions) (result *mysql_v1.MySQLBack if label == nil { label = labels.Everything() } - list := &mysql_v1.MySQLBackupList{} - for _, item := range obj.(*mysql_v1.MySQLBackupList).Items { + list := &v1alpha1.MySQLBackupList{} + for _, item := range obj.(*v1alpha1.MySQLBackupList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,31 +75,31 @@ func (c *FakeMySQLBackups) Watch(opts v1.ListOptions) (watch.Interface, error) { } // Create takes the representation of a mySQLBackup and creates it. Returns the server's representation of the mySQLBackup, and an error, if there is any. -func (c *FakeMySQLBackups) Create(mySQLBackup *mysql_v1.MySQLBackup) (result *mysql_v1.MySQLBackup, err error) { +func (c *FakeMySQLBackups) Create(mySQLBackup *v1alpha1.MySQLBackup) (result *v1alpha1.MySQLBackup, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(mysqlbackupsResource, c.ns, mySQLBackup), &mysql_v1.MySQLBackup{}) + Invokes(testing.NewCreateAction(mysqlbackupsResource, c.ns, mySQLBackup), &v1alpha1.MySQLBackup{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackup), err + return obj.(*v1alpha1.MySQLBackup), err } // Update takes the representation of a mySQLBackup and updates it. Returns the server's representation of the mySQLBackup, and an error, if there is any. -func (c *FakeMySQLBackups) Update(mySQLBackup *mysql_v1.MySQLBackup) (result *mysql_v1.MySQLBackup, err error) { +func (c *FakeMySQLBackups) Update(mySQLBackup *v1alpha1.MySQLBackup) (result *v1alpha1.MySQLBackup, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(mysqlbackupsResource, c.ns, mySQLBackup), &mysql_v1.MySQLBackup{}) + Invokes(testing.NewUpdateAction(mysqlbackupsResource, c.ns, mySQLBackup), &v1alpha1.MySQLBackup{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackup), err + return obj.(*v1alpha1.MySQLBackup), err } // Delete takes name of the mySQLBackup and deletes it. Returns an error if one occurs. func (c *FakeMySQLBackups) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(mysqlbackupsResource, c.ns, name), &mysql_v1.MySQLBackup{}) + Invokes(testing.NewDeleteAction(mysqlbackupsResource, c.ns, name), &v1alpha1.MySQLBackup{}) return err } @@ -108,17 +108,17 @@ func (c *FakeMySQLBackups) Delete(name string, options *v1.DeleteOptions) error func (c *FakeMySQLBackups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(mysqlbackupsResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &mysql_v1.MySQLBackupList{}) + _, err := c.Fake.Invokes(action, &v1alpha1.MySQLBackupList{}) return err } // Patch applies the patch and returns the patched mySQLBackup. -func (c *FakeMySQLBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mysql_v1.MySQLBackup, err error) { +func (c *FakeMySQLBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackup, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(mysqlbackupsResource, c.ns, name, data, subresources...), &mysql_v1.MySQLBackup{}) + Invokes(testing.NewPatchSubresourceAction(mysqlbackupsResource, c.ns, name, data, subresources...), &v1alpha1.MySQLBackup{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackup), err + return obj.(*v1alpha1.MySQLBackup), err } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackupschedule.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackupschedule.go similarity index 73% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackupschedule.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackupschedule.go index 139d146c9..30e7a3a1c 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlbackupschedule.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlbackupschedule.go @@ -15,7 +15,7 @@ package fake import ( - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,29 +26,29 @@ import ( // FakeMySQLBackupSchedules implements MySQLBackupScheduleInterface type FakeMySQLBackupSchedules struct { - Fake *FakeMysqlV1 + Fake *FakeMysqlV1alpha1 ns string } -var mysqlbackupschedulesResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1", Resource: "mysqlbackupschedules"} +var mysqlbackupschedulesResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1alpha1", Resource: "mysqlbackupschedules"} -var mysqlbackupschedulesKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1", Kind: "MySQLBackupSchedule"} +var mysqlbackupschedulesKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1alpha1", Kind: "MySQLBackupSchedule"} // Get takes name of the mySQLBackupSchedule, and returns the corresponding mySQLBackupSchedule object, and an error if there is any. -func (c *FakeMySQLBackupSchedules) Get(name string, options v1.GetOptions) (result *mysql_v1.MySQLBackupSchedule, err error) { +func (c *FakeMySQLBackupSchedules) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLBackupSchedule, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(mysqlbackupschedulesResource, c.ns, name), &mysql_v1.MySQLBackupSchedule{}) + Invokes(testing.NewGetAction(mysqlbackupschedulesResource, c.ns, name), &v1alpha1.MySQLBackupSchedule{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackupSchedule), err + return obj.(*v1alpha1.MySQLBackupSchedule), err } // List takes label and field selectors, and returns the list of MySQLBackupSchedules that match those selectors. -func (c *FakeMySQLBackupSchedules) List(opts v1.ListOptions) (result *mysql_v1.MySQLBackupScheduleList, err error) { +func (c *FakeMySQLBackupSchedules) List(opts v1.ListOptions) (result *v1alpha1.MySQLBackupScheduleList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(mysqlbackupschedulesResource, mysqlbackupschedulesKind, c.ns, opts), &mysql_v1.MySQLBackupScheduleList{}) + Invokes(testing.NewListAction(mysqlbackupschedulesResource, mysqlbackupschedulesKind, c.ns, opts), &v1alpha1.MySQLBackupScheduleList{}) if obj == nil { return nil, err @@ -58,8 +58,8 @@ func (c *FakeMySQLBackupSchedules) List(opts v1.ListOptions) (result *mysql_v1.M if label == nil { label = labels.Everything() } - list := &mysql_v1.MySQLBackupScheduleList{} - for _, item := range obj.(*mysql_v1.MySQLBackupScheduleList).Items { + list := &v1alpha1.MySQLBackupScheduleList{} + for _, item := range obj.(*v1alpha1.MySQLBackupScheduleList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,31 +75,31 @@ func (c *FakeMySQLBackupSchedules) Watch(opts v1.ListOptions) (watch.Interface, } // Create takes the representation of a mySQLBackupSchedule and creates it. Returns the server's representation of the mySQLBackupSchedule, and an error, if there is any. -func (c *FakeMySQLBackupSchedules) Create(mySQLBackupSchedule *mysql_v1.MySQLBackupSchedule) (result *mysql_v1.MySQLBackupSchedule, err error) { +func (c *FakeMySQLBackupSchedules) Create(mySQLBackupSchedule *v1alpha1.MySQLBackupSchedule) (result *v1alpha1.MySQLBackupSchedule, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(mysqlbackupschedulesResource, c.ns, mySQLBackupSchedule), &mysql_v1.MySQLBackupSchedule{}) + Invokes(testing.NewCreateAction(mysqlbackupschedulesResource, c.ns, mySQLBackupSchedule), &v1alpha1.MySQLBackupSchedule{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackupSchedule), err + return obj.(*v1alpha1.MySQLBackupSchedule), err } // Update takes the representation of a mySQLBackupSchedule and updates it. Returns the server's representation of the mySQLBackupSchedule, and an error, if there is any. -func (c *FakeMySQLBackupSchedules) Update(mySQLBackupSchedule *mysql_v1.MySQLBackupSchedule) (result *mysql_v1.MySQLBackupSchedule, err error) { +func (c *FakeMySQLBackupSchedules) Update(mySQLBackupSchedule *v1alpha1.MySQLBackupSchedule) (result *v1alpha1.MySQLBackupSchedule, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(mysqlbackupschedulesResource, c.ns, mySQLBackupSchedule), &mysql_v1.MySQLBackupSchedule{}) + Invokes(testing.NewUpdateAction(mysqlbackupschedulesResource, c.ns, mySQLBackupSchedule), &v1alpha1.MySQLBackupSchedule{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackupSchedule), err + return obj.(*v1alpha1.MySQLBackupSchedule), err } // Delete takes name of the mySQLBackupSchedule and deletes it. Returns an error if one occurs. func (c *FakeMySQLBackupSchedules) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(mysqlbackupschedulesResource, c.ns, name), &mysql_v1.MySQLBackupSchedule{}) + Invokes(testing.NewDeleteAction(mysqlbackupschedulesResource, c.ns, name), &v1alpha1.MySQLBackupSchedule{}) return err } @@ -108,17 +108,17 @@ func (c *FakeMySQLBackupSchedules) Delete(name string, options *v1.DeleteOptions func (c *FakeMySQLBackupSchedules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(mysqlbackupschedulesResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &mysql_v1.MySQLBackupScheduleList{}) + _, err := c.Fake.Invokes(action, &v1alpha1.MySQLBackupScheduleList{}) return err } // Patch applies the patch and returns the patched mySQLBackupSchedule. -func (c *FakeMySQLBackupSchedules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mysql_v1.MySQLBackupSchedule, err error) { +func (c *FakeMySQLBackupSchedules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackupSchedule, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(mysqlbackupschedulesResource, c.ns, name, data, subresources...), &mysql_v1.MySQLBackupSchedule{}) + Invokes(testing.NewPatchSubresourceAction(mysqlbackupschedulesResource, c.ns, name, data, subresources...), &v1alpha1.MySQLBackupSchedule{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLBackupSchedule), err + return obj.(*v1alpha1.MySQLBackupSchedule), err } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlcluster.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlcluster.go similarity index 73% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlcluster.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlcluster.go index a08d87bbb..fa89ec319 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlcluster.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlcluster.go @@ -15,7 +15,7 @@ package fake import ( - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,29 +26,29 @@ import ( // FakeMySQLClusters implements MySQLClusterInterface type FakeMySQLClusters struct { - Fake *FakeMysqlV1 + Fake *FakeMysqlV1alpha1 ns string } -var mysqlclustersResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1", Resource: "mysqlclusters"} +var mysqlclustersResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1alpha1", Resource: "mysqlclusters"} -var mysqlclustersKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1", Kind: "MySQLCluster"} +var mysqlclustersKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1alpha1", Kind: "MySQLCluster"} // Get takes name of the mySQLCluster, and returns the corresponding mySQLCluster object, and an error if there is any. -func (c *FakeMySQLClusters) Get(name string, options v1.GetOptions) (result *mysql_v1.MySQLCluster, err error) { +func (c *FakeMySQLClusters) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLCluster, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(mysqlclustersResource, c.ns, name), &mysql_v1.MySQLCluster{}) + Invokes(testing.NewGetAction(mysqlclustersResource, c.ns, name), &v1alpha1.MySQLCluster{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLCluster), err + return obj.(*v1alpha1.MySQLCluster), err } // List takes label and field selectors, and returns the list of MySQLClusters that match those selectors. -func (c *FakeMySQLClusters) List(opts v1.ListOptions) (result *mysql_v1.MySQLClusterList, err error) { +func (c *FakeMySQLClusters) List(opts v1.ListOptions) (result *v1alpha1.MySQLClusterList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(mysqlclustersResource, mysqlclustersKind, c.ns, opts), &mysql_v1.MySQLClusterList{}) + Invokes(testing.NewListAction(mysqlclustersResource, mysqlclustersKind, c.ns, opts), &v1alpha1.MySQLClusterList{}) if obj == nil { return nil, err @@ -58,8 +58,8 @@ func (c *FakeMySQLClusters) List(opts v1.ListOptions) (result *mysql_v1.MySQLClu if label == nil { label = labels.Everything() } - list := &mysql_v1.MySQLClusterList{} - for _, item := range obj.(*mysql_v1.MySQLClusterList).Items { + list := &v1alpha1.MySQLClusterList{} + for _, item := range obj.(*v1alpha1.MySQLClusterList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,31 +75,31 @@ func (c *FakeMySQLClusters) Watch(opts v1.ListOptions) (watch.Interface, error) } // Create takes the representation of a mySQLCluster and creates it. Returns the server's representation of the mySQLCluster, and an error, if there is any. -func (c *FakeMySQLClusters) Create(mySQLCluster *mysql_v1.MySQLCluster) (result *mysql_v1.MySQLCluster, err error) { +func (c *FakeMySQLClusters) Create(mySQLCluster *v1alpha1.MySQLCluster) (result *v1alpha1.MySQLCluster, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(mysqlclustersResource, c.ns, mySQLCluster), &mysql_v1.MySQLCluster{}) + Invokes(testing.NewCreateAction(mysqlclustersResource, c.ns, mySQLCluster), &v1alpha1.MySQLCluster{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLCluster), err + return obj.(*v1alpha1.MySQLCluster), err } // Update takes the representation of a mySQLCluster and updates it. Returns the server's representation of the mySQLCluster, and an error, if there is any. -func (c *FakeMySQLClusters) Update(mySQLCluster *mysql_v1.MySQLCluster) (result *mysql_v1.MySQLCluster, err error) { +func (c *FakeMySQLClusters) Update(mySQLCluster *v1alpha1.MySQLCluster) (result *v1alpha1.MySQLCluster, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(mysqlclustersResource, c.ns, mySQLCluster), &mysql_v1.MySQLCluster{}) + Invokes(testing.NewUpdateAction(mysqlclustersResource, c.ns, mySQLCluster), &v1alpha1.MySQLCluster{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLCluster), err + return obj.(*v1alpha1.MySQLCluster), err } // Delete takes name of the mySQLCluster and deletes it. Returns an error if one occurs. func (c *FakeMySQLClusters) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(mysqlclustersResource, c.ns, name), &mysql_v1.MySQLCluster{}) + Invokes(testing.NewDeleteAction(mysqlclustersResource, c.ns, name), &v1alpha1.MySQLCluster{}) return err } @@ -108,17 +108,17 @@ func (c *FakeMySQLClusters) Delete(name string, options *v1.DeleteOptions) error func (c *FakeMySQLClusters) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(mysqlclustersResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &mysql_v1.MySQLClusterList{}) + _, err := c.Fake.Invokes(action, &v1alpha1.MySQLClusterList{}) return err } // Patch applies the patch and returns the patched mySQLCluster. -func (c *FakeMySQLClusters) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mysql_v1.MySQLCluster, err error) { +func (c *FakeMySQLClusters) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLCluster, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(mysqlclustersResource, c.ns, name, data, subresources...), &mysql_v1.MySQLCluster{}) + Invokes(testing.NewPatchSubresourceAction(mysqlclustersResource, c.ns, name, data, subresources...), &v1alpha1.MySQLCluster{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLCluster), err + return obj.(*v1alpha1.MySQLCluster), err } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlrestore.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlrestore.go similarity index 73% rename from pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlrestore.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlrestore.go index e6fe0f21d..33a438201 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/fake/fake_mysqlrestore.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/fake/fake_mysqlrestore.go @@ -15,7 +15,7 @@ package fake import ( - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,29 +26,29 @@ import ( // FakeMySQLRestores implements MySQLRestoreInterface type FakeMySQLRestores struct { - Fake *FakeMysqlV1 + Fake *FakeMysqlV1alpha1 ns string } -var mysqlrestoresResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1", Resource: "mysqlrestores"} +var mysqlrestoresResource = schema.GroupVersionResource{Group: "mysql.oracle.com", Version: "v1alpha1", Resource: "mysqlrestores"} -var mysqlrestoresKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1", Kind: "MySQLRestore"} +var mysqlrestoresKind = schema.GroupVersionKind{Group: "mysql.oracle.com", Version: "v1alpha1", Kind: "MySQLRestore"} // Get takes name of the mySQLRestore, and returns the corresponding mySQLRestore object, and an error if there is any. -func (c *FakeMySQLRestores) Get(name string, options v1.GetOptions) (result *mysql_v1.MySQLRestore, err error) { +func (c *FakeMySQLRestores) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLRestore, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(mysqlrestoresResource, c.ns, name), &mysql_v1.MySQLRestore{}) + Invokes(testing.NewGetAction(mysqlrestoresResource, c.ns, name), &v1alpha1.MySQLRestore{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLRestore), err + return obj.(*v1alpha1.MySQLRestore), err } // List takes label and field selectors, and returns the list of MySQLRestores that match those selectors. -func (c *FakeMySQLRestores) List(opts v1.ListOptions) (result *mysql_v1.MySQLRestoreList, err error) { +func (c *FakeMySQLRestores) List(opts v1.ListOptions) (result *v1alpha1.MySQLRestoreList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(mysqlrestoresResource, mysqlrestoresKind, c.ns, opts), &mysql_v1.MySQLRestoreList{}) + Invokes(testing.NewListAction(mysqlrestoresResource, mysqlrestoresKind, c.ns, opts), &v1alpha1.MySQLRestoreList{}) if obj == nil { return nil, err @@ -58,8 +58,8 @@ func (c *FakeMySQLRestores) List(opts v1.ListOptions) (result *mysql_v1.MySQLRes if label == nil { label = labels.Everything() } - list := &mysql_v1.MySQLRestoreList{} - for _, item := range obj.(*mysql_v1.MySQLRestoreList).Items { + list := &v1alpha1.MySQLRestoreList{} + for _, item := range obj.(*v1alpha1.MySQLRestoreList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -75,31 +75,31 @@ func (c *FakeMySQLRestores) Watch(opts v1.ListOptions) (watch.Interface, error) } // Create takes the representation of a mySQLRestore and creates it. Returns the server's representation of the mySQLRestore, and an error, if there is any. -func (c *FakeMySQLRestores) Create(mySQLRestore *mysql_v1.MySQLRestore) (result *mysql_v1.MySQLRestore, err error) { +func (c *FakeMySQLRestores) Create(mySQLRestore *v1alpha1.MySQLRestore) (result *v1alpha1.MySQLRestore, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(mysqlrestoresResource, c.ns, mySQLRestore), &mysql_v1.MySQLRestore{}) + Invokes(testing.NewCreateAction(mysqlrestoresResource, c.ns, mySQLRestore), &v1alpha1.MySQLRestore{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLRestore), err + return obj.(*v1alpha1.MySQLRestore), err } // Update takes the representation of a mySQLRestore and updates it. Returns the server's representation of the mySQLRestore, and an error, if there is any. -func (c *FakeMySQLRestores) Update(mySQLRestore *mysql_v1.MySQLRestore) (result *mysql_v1.MySQLRestore, err error) { +func (c *FakeMySQLRestores) Update(mySQLRestore *v1alpha1.MySQLRestore) (result *v1alpha1.MySQLRestore, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(mysqlrestoresResource, c.ns, mySQLRestore), &mysql_v1.MySQLRestore{}) + Invokes(testing.NewUpdateAction(mysqlrestoresResource, c.ns, mySQLRestore), &v1alpha1.MySQLRestore{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLRestore), err + return obj.(*v1alpha1.MySQLRestore), err } // Delete takes name of the mySQLRestore and deletes it. Returns an error if one occurs. func (c *FakeMySQLRestores) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(mysqlrestoresResource, c.ns, name), &mysql_v1.MySQLRestore{}) + Invokes(testing.NewDeleteAction(mysqlrestoresResource, c.ns, name), &v1alpha1.MySQLRestore{}) return err } @@ -108,17 +108,17 @@ func (c *FakeMySQLRestores) Delete(name string, options *v1.DeleteOptions) error func (c *FakeMySQLRestores) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(mysqlrestoresResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &mysql_v1.MySQLRestoreList{}) + _, err := c.Fake.Invokes(action, &v1alpha1.MySQLRestoreList{}) return err } // Patch applies the patch and returns the patched mySQLRestore. -func (c *FakeMySQLRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mysql_v1.MySQLRestore, err error) { +func (c *FakeMySQLRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLRestore, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(mysqlrestoresResource, c.ns, name, data, subresources...), &mysql_v1.MySQLRestore{}) + Invokes(testing.NewPatchSubresourceAction(mysqlrestoresResource, c.ns, name, data, subresources...), &v1alpha1.MySQLRestore{}) if obj == nil { return nil, err } - return obj.(*mysql_v1.MySQLRestore), err + return obj.(*v1alpha1.MySQLRestore), err } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/generated_expansion.go similarity index 97% rename from pkg/generated/clientset/versioned/typed/mysql/v1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/generated_expansion.go index 9d9e2965e..be57ccf23 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/generated_expansion.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 type MySQLBackupExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/mysql_client.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysql_client.go similarity index 61% rename from pkg/generated/clientset/versioned/typed/mysql/v1/mysql_client.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysql_client.go index 95b1300d3..0c61b24a3 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/mysql_client.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysql_client.go @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type MysqlV1Interface interface { +type MysqlV1alpha1Interface interface { RESTClient() rest.Interface MySQLBackupsGetter MySQLBackupSchedulesGetter @@ -29,29 +29,29 @@ type MysqlV1Interface interface { MySQLRestoresGetter } -// MysqlV1Client is used to interact with features provided by the mysql.oracle.com group. -type MysqlV1Client struct { +// MysqlV1alpha1Client is used to interact with features provided by the mysql.oracle.com group. +type MysqlV1alpha1Client struct { restClient rest.Interface } -func (c *MysqlV1Client) MySQLBackups(namespace string) MySQLBackupInterface { +func (c *MysqlV1alpha1Client) MySQLBackups(namespace string) MySQLBackupInterface { return newMySQLBackups(c, namespace) } -func (c *MysqlV1Client) MySQLBackupSchedules(namespace string) MySQLBackupScheduleInterface { +func (c *MysqlV1alpha1Client) MySQLBackupSchedules(namespace string) MySQLBackupScheduleInterface { return newMySQLBackupSchedules(c, namespace) } -func (c *MysqlV1Client) MySQLClusters(namespace string) MySQLClusterInterface { +func (c *MysqlV1alpha1Client) MySQLClusters(namespace string) MySQLClusterInterface { return newMySQLClusters(c, namespace) } -func (c *MysqlV1Client) MySQLRestores(namespace string) MySQLRestoreInterface { +func (c *MysqlV1alpha1Client) MySQLRestores(namespace string) MySQLRestoreInterface { return newMySQLRestores(c, namespace) } -// NewForConfig creates a new MysqlV1Client for the given config. -func NewForConfig(c *rest.Config) (*MysqlV1Client, error) { +// NewForConfig creates a new MysqlV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*MysqlV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -60,12 +60,12 @@ func NewForConfig(c *rest.Config) (*MysqlV1Client, error) { if err != nil { return nil, err } - return &MysqlV1Client{client}, nil + return &MysqlV1alpha1Client{client}, nil } -// NewForConfigOrDie creates a new MysqlV1Client for the given config and +// NewForConfigOrDie creates a new MysqlV1alpha1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *MysqlV1Client { +func NewForConfigOrDie(c *rest.Config) *MysqlV1alpha1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -73,13 +73,13 @@ func NewForConfigOrDie(c *rest.Config) *MysqlV1Client { return client } -// New creates a new MysqlV1Client for the given RESTClient. -func New(c rest.Interface) *MysqlV1Client { - return &MysqlV1Client{c} +// New creates a new MysqlV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *MysqlV1alpha1Client { + return &MysqlV1alpha1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion + gv := v1alpha1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} @@ -93,7 +93,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *MysqlV1Client) RESTClient() rest.Interface { +func (c *MysqlV1alpha1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackup.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackup.go similarity index 68% rename from pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackup.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackup.go index 2f74d52cc..1b1171e71 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackup.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackup.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" scheme "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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" @@ -31,14 +31,14 @@ type MySQLBackupsGetter interface { // MySQLBackupInterface has methods to work with MySQLBackup resources. type MySQLBackupInterface interface { - Create(*v1.MySQLBackup) (*v1.MySQLBackup, error) - Update(*v1.MySQLBackup) (*v1.MySQLBackup, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.MySQLBackup, error) - List(opts meta_v1.ListOptions) (*v1.MySQLBackupList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLBackup, err error) + Create(*v1alpha1.MySQLBackup) (*v1alpha1.MySQLBackup, error) + Update(*v1alpha1.MySQLBackup) (*v1alpha1.MySQLBackup, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MySQLBackup, error) + List(opts v1.ListOptions) (*v1alpha1.MySQLBackupList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackup, err error) MySQLBackupExpansion } @@ -49,7 +49,7 @@ type mySQLBackups struct { } // newMySQLBackups returns a MySQLBackups -func newMySQLBackups(c *MysqlV1Client, namespace string) *mySQLBackups { +func newMySQLBackups(c *MysqlV1alpha1Client, namespace string) *mySQLBackups { return &mySQLBackups{ client: c.RESTClient(), ns: namespace, @@ -57,8 +57,8 @@ func newMySQLBackups(c *MysqlV1Client, namespace string) *mySQLBackups { } // Get takes name of the mySQLBackup, and returns the corresponding mySQLBackup object, and an error if there is any. -func (c *mySQLBackups) Get(name string, options meta_v1.GetOptions) (result *v1.MySQLBackup, err error) { - result = &v1.MySQLBackup{} +func (c *mySQLBackups) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLBackup, err error) { + result = &v1alpha1.MySQLBackup{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlbackups"). @@ -70,8 +70,8 @@ func (c *mySQLBackups) Get(name string, options meta_v1.GetOptions) (result *v1. } // List takes label and field selectors, and returns the list of MySQLBackups that match those selectors. -func (c *mySQLBackups) List(opts meta_v1.ListOptions) (result *v1.MySQLBackupList, err error) { - result = &v1.MySQLBackupList{} +func (c *mySQLBackups) List(opts v1.ListOptions) (result *v1alpha1.MySQLBackupList, err error) { + result = &v1alpha1.MySQLBackupList{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlbackups"). @@ -82,7 +82,7 @@ func (c *mySQLBackups) List(opts meta_v1.ListOptions) (result *v1.MySQLBackupLis } // Watch returns a watch.Interface that watches the requested mySQLBackups. -func (c *mySQLBackups) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { +func (c *mySQLBackups) Watch(opts v1.ListOptions) (watch.Interface, error) { opts.Watch = true return c.client.Get(). Namespace(c.ns). @@ -92,8 +92,8 @@ func (c *mySQLBackups) Watch(opts meta_v1.ListOptions) (watch.Interface, error) } // Create takes the representation of a mySQLBackup and creates it. Returns the server's representation of the mySQLBackup, and an error, if there is any. -func (c *mySQLBackups) Create(mySQLBackup *v1.MySQLBackup) (result *v1.MySQLBackup, err error) { - result = &v1.MySQLBackup{} +func (c *mySQLBackups) Create(mySQLBackup *v1alpha1.MySQLBackup) (result *v1alpha1.MySQLBackup, err error) { + result = &v1alpha1.MySQLBackup{} err = c.client.Post(). Namespace(c.ns). Resource("mysqlbackups"). @@ -104,8 +104,8 @@ func (c *mySQLBackups) Create(mySQLBackup *v1.MySQLBackup) (result *v1.MySQLBack } // Update takes the representation of a mySQLBackup and updates it. Returns the server's representation of the mySQLBackup, and an error, if there is any. -func (c *mySQLBackups) Update(mySQLBackup *v1.MySQLBackup) (result *v1.MySQLBackup, err error) { - result = &v1.MySQLBackup{} +func (c *mySQLBackups) Update(mySQLBackup *v1alpha1.MySQLBackup) (result *v1alpha1.MySQLBackup, err error) { + result = &v1alpha1.MySQLBackup{} err = c.client.Put(). Namespace(c.ns). Resource("mysqlbackups"). @@ -117,7 +117,7 @@ func (c *mySQLBackups) Update(mySQLBackup *v1.MySQLBackup) (result *v1.MySQLBack } // Delete takes name of the mySQLBackup and deletes it. Returns an error if one occurs. -func (c *mySQLBackups) Delete(name string, options *meta_v1.DeleteOptions) error { +func (c *mySQLBackups) Delete(name string, options *v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlbackups"). @@ -128,7 +128,7 @@ func (c *mySQLBackups) Delete(name string, options *meta_v1.DeleteOptions) error } // DeleteCollection deletes a collection of objects. -func (c *mySQLBackups) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { +func (c *mySQLBackups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlbackups"). @@ -139,8 +139,8 @@ func (c *mySQLBackups) DeleteCollection(options *meta_v1.DeleteOptions, listOpti } // Patch applies the patch and returns the patched mySQLBackup. -func (c *mySQLBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLBackup, err error) { - result = &v1.MySQLBackup{} +func (c *mySQLBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackup, err error) { + result = &v1alpha1.MySQLBackup{} err = c.client.Patch(pt). Namespace(c.ns). Resource("mysqlbackups"). diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackupschedule.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackupschedule.go similarity index 67% rename from pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackupschedule.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackupschedule.go index 7a6629ebb..0427586de 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlbackupschedule.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlbackupschedule.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" scheme "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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" @@ -31,14 +31,14 @@ type MySQLBackupSchedulesGetter interface { // MySQLBackupScheduleInterface has methods to work with MySQLBackupSchedule resources. type MySQLBackupScheduleInterface interface { - Create(*v1.MySQLBackupSchedule) (*v1.MySQLBackupSchedule, error) - Update(*v1.MySQLBackupSchedule) (*v1.MySQLBackupSchedule, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.MySQLBackupSchedule, error) - List(opts meta_v1.ListOptions) (*v1.MySQLBackupScheduleList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLBackupSchedule, err error) + Create(*v1alpha1.MySQLBackupSchedule) (*v1alpha1.MySQLBackupSchedule, error) + Update(*v1alpha1.MySQLBackupSchedule) (*v1alpha1.MySQLBackupSchedule, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MySQLBackupSchedule, error) + List(opts v1.ListOptions) (*v1alpha1.MySQLBackupScheduleList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackupSchedule, err error) MySQLBackupScheduleExpansion } @@ -49,7 +49,7 @@ type mySQLBackupSchedules struct { } // newMySQLBackupSchedules returns a MySQLBackupSchedules -func newMySQLBackupSchedules(c *MysqlV1Client, namespace string) *mySQLBackupSchedules { +func newMySQLBackupSchedules(c *MysqlV1alpha1Client, namespace string) *mySQLBackupSchedules { return &mySQLBackupSchedules{ client: c.RESTClient(), ns: namespace, @@ -57,8 +57,8 @@ func newMySQLBackupSchedules(c *MysqlV1Client, namespace string) *mySQLBackupSch } // Get takes name of the mySQLBackupSchedule, and returns the corresponding mySQLBackupSchedule object, and an error if there is any. -func (c *mySQLBackupSchedules) Get(name string, options meta_v1.GetOptions) (result *v1.MySQLBackupSchedule, err error) { - result = &v1.MySQLBackupSchedule{} +func (c *mySQLBackupSchedules) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLBackupSchedule, err error) { + result = &v1alpha1.MySQLBackupSchedule{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -70,8 +70,8 @@ func (c *mySQLBackupSchedules) Get(name string, options meta_v1.GetOptions) (res } // List takes label and field selectors, and returns the list of MySQLBackupSchedules that match those selectors. -func (c *mySQLBackupSchedules) List(opts meta_v1.ListOptions) (result *v1.MySQLBackupScheduleList, err error) { - result = &v1.MySQLBackupScheduleList{} +func (c *mySQLBackupSchedules) List(opts v1.ListOptions) (result *v1alpha1.MySQLBackupScheduleList, err error) { + result = &v1alpha1.MySQLBackupScheduleList{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -82,7 +82,7 @@ func (c *mySQLBackupSchedules) List(opts meta_v1.ListOptions) (result *v1.MySQLB } // Watch returns a watch.Interface that watches the requested mySQLBackupSchedules. -func (c *mySQLBackupSchedules) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { +func (c *mySQLBackupSchedules) Watch(opts v1.ListOptions) (watch.Interface, error) { opts.Watch = true return c.client.Get(). Namespace(c.ns). @@ -92,8 +92,8 @@ func (c *mySQLBackupSchedules) Watch(opts meta_v1.ListOptions) (watch.Interface, } // Create takes the representation of a mySQLBackupSchedule and creates it. Returns the server's representation of the mySQLBackupSchedule, and an error, if there is any. -func (c *mySQLBackupSchedules) Create(mySQLBackupSchedule *v1.MySQLBackupSchedule) (result *v1.MySQLBackupSchedule, err error) { - result = &v1.MySQLBackupSchedule{} +func (c *mySQLBackupSchedules) Create(mySQLBackupSchedule *v1alpha1.MySQLBackupSchedule) (result *v1alpha1.MySQLBackupSchedule, err error) { + result = &v1alpha1.MySQLBackupSchedule{} err = c.client.Post(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -104,8 +104,8 @@ func (c *mySQLBackupSchedules) Create(mySQLBackupSchedule *v1.MySQLBackupSchedul } // Update takes the representation of a mySQLBackupSchedule and updates it. Returns the server's representation of the mySQLBackupSchedule, and an error, if there is any. -func (c *mySQLBackupSchedules) Update(mySQLBackupSchedule *v1.MySQLBackupSchedule) (result *v1.MySQLBackupSchedule, err error) { - result = &v1.MySQLBackupSchedule{} +func (c *mySQLBackupSchedules) Update(mySQLBackupSchedule *v1alpha1.MySQLBackupSchedule) (result *v1alpha1.MySQLBackupSchedule, err error) { + result = &v1alpha1.MySQLBackupSchedule{} err = c.client.Put(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -117,7 +117,7 @@ func (c *mySQLBackupSchedules) Update(mySQLBackupSchedule *v1.MySQLBackupSchedul } // Delete takes name of the mySQLBackupSchedule and deletes it. Returns an error if one occurs. -func (c *mySQLBackupSchedules) Delete(name string, options *meta_v1.DeleteOptions) error { +func (c *mySQLBackupSchedules) Delete(name string, options *v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -128,7 +128,7 @@ func (c *mySQLBackupSchedules) Delete(name string, options *meta_v1.DeleteOption } // DeleteCollection deletes a collection of objects. -func (c *mySQLBackupSchedules) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { +func (c *mySQLBackupSchedules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlbackupschedules"). @@ -139,8 +139,8 @@ func (c *mySQLBackupSchedules) DeleteCollection(options *meta_v1.DeleteOptions, } // Patch applies the patch and returns the patched mySQLBackupSchedule. -func (c *mySQLBackupSchedules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLBackupSchedule, err error) { - result = &v1.MySQLBackupSchedule{} +func (c *mySQLBackupSchedules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLBackupSchedule, err error) { + result = &v1alpha1.MySQLBackupSchedule{} err = c.client.Patch(pt). Namespace(c.ns). Resource("mysqlbackupschedules"). diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlcluster.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlcluster.go similarity index 68% rename from pkg/generated/clientset/versioned/typed/mysql/v1/mysqlcluster.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlcluster.go index 14f3b9c9c..443540c43 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlcluster.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlcluster.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" scheme "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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" @@ -31,14 +31,14 @@ type MySQLClustersGetter interface { // MySQLClusterInterface has methods to work with MySQLCluster resources. type MySQLClusterInterface interface { - Create(*v1.MySQLCluster) (*v1.MySQLCluster, error) - Update(*v1.MySQLCluster) (*v1.MySQLCluster, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.MySQLCluster, error) - List(opts meta_v1.ListOptions) (*v1.MySQLClusterList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLCluster, err error) + Create(*v1alpha1.MySQLCluster) (*v1alpha1.MySQLCluster, error) + Update(*v1alpha1.MySQLCluster) (*v1alpha1.MySQLCluster, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MySQLCluster, error) + List(opts v1.ListOptions) (*v1alpha1.MySQLClusterList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLCluster, err error) MySQLClusterExpansion } @@ -49,7 +49,7 @@ type mySQLClusters struct { } // newMySQLClusters returns a MySQLClusters -func newMySQLClusters(c *MysqlV1Client, namespace string) *mySQLClusters { +func newMySQLClusters(c *MysqlV1alpha1Client, namespace string) *mySQLClusters { return &mySQLClusters{ client: c.RESTClient(), ns: namespace, @@ -57,8 +57,8 @@ func newMySQLClusters(c *MysqlV1Client, namespace string) *mySQLClusters { } // Get takes name of the mySQLCluster, and returns the corresponding mySQLCluster object, and an error if there is any. -func (c *mySQLClusters) Get(name string, options meta_v1.GetOptions) (result *v1.MySQLCluster, err error) { - result = &v1.MySQLCluster{} +func (c *mySQLClusters) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLCluster, err error) { + result = &v1alpha1.MySQLCluster{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlclusters"). @@ -70,8 +70,8 @@ func (c *mySQLClusters) Get(name string, options meta_v1.GetOptions) (result *v1 } // List takes label and field selectors, and returns the list of MySQLClusters that match those selectors. -func (c *mySQLClusters) List(opts meta_v1.ListOptions) (result *v1.MySQLClusterList, err error) { - result = &v1.MySQLClusterList{} +func (c *mySQLClusters) List(opts v1.ListOptions) (result *v1alpha1.MySQLClusterList, err error) { + result = &v1alpha1.MySQLClusterList{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlclusters"). @@ -82,7 +82,7 @@ func (c *mySQLClusters) List(opts meta_v1.ListOptions) (result *v1.MySQLClusterL } // Watch returns a watch.Interface that watches the requested mySQLClusters. -func (c *mySQLClusters) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { +func (c *mySQLClusters) Watch(opts v1.ListOptions) (watch.Interface, error) { opts.Watch = true return c.client.Get(). Namespace(c.ns). @@ -92,8 +92,8 @@ func (c *mySQLClusters) Watch(opts meta_v1.ListOptions) (watch.Interface, error) } // Create takes the representation of a mySQLCluster and creates it. Returns the server's representation of the mySQLCluster, and an error, if there is any. -func (c *mySQLClusters) Create(mySQLCluster *v1.MySQLCluster) (result *v1.MySQLCluster, err error) { - result = &v1.MySQLCluster{} +func (c *mySQLClusters) Create(mySQLCluster *v1alpha1.MySQLCluster) (result *v1alpha1.MySQLCluster, err error) { + result = &v1alpha1.MySQLCluster{} err = c.client.Post(). Namespace(c.ns). Resource("mysqlclusters"). @@ -104,8 +104,8 @@ func (c *mySQLClusters) Create(mySQLCluster *v1.MySQLCluster) (result *v1.MySQLC } // Update takes the representation of a mySQLCluster and updates it. Returns the server's representation of the mySQLCluster, and an error, if there is any. -func (c *mySQLClusters) Update(mySQLCluster *v1.MySQLCluster) (result *v1.MySQLCluster, err error) { - result = &v1.MySQLCluster{} +func (c *mySQLClusters) Update(mySQLCluster *v1alpha1.MySQLCluster) (result *v1alpha1.MySQLCluster, err error) { + result = &v1alpha1.MySQLCluster{} err = c.client.Put(). Namespace(c.ns). Resource("mysqlclusters"). @@ -117,7 +117,7 @@ func (c *mySQLClusters) Update(mySQLCluster *v1.MySQLCluster) (result *v1.MySQLC } // Delete takes name of the mySQLCluster and deletes it. Returns an error if one occurs. -func (c *mySQLClusters) Delete(name string, options *meta_v1.DeleteOptions) error { +func (c *mySQLClusters) Delete(name string, options *v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlclusters"). @@ -128,7 +128,7 @@ func (c *mySQLClusters) Delete(name string, options *meta_v1.DeleteOptions) erro } // DeleteCollection deletes a collection of objects. -func (c *mySQLClusters) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { +func (c *mySQLClusters) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlclusters"). @@ -139,8 +139,8 @@ func (c *mySQLClusters) DeleteCollection(options *meta_v1.DeleteOptions, listOpt } // Patch applies the patch and returns the patched mySQLCluster. -func (c *mySQLClusters) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLCluster, err error) { - result = &v1.MySQLCluster{} +func (c *mySQLClusters) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLCluster, err error) { + result = &v1alpha1.MySQLCluster{} err = c.client.Patch(pt). Namespace(c.ns). Resource("mysqlclusters"). diff --git a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlrestore.go b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlrestore.go similarity index 68% rename from pkg/generated/clientset/versioned/typed/mysql/v1/mysqlrestore.go rename to pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlrestore.go index 2417f5726..8b71eaaba 100644 --- a/pkg/generated/clientset/versioned/typed/mysql/v1/mysqlrestore.go +++ b/pkg/generated/clientset/versioned/typed/mysql/v1alpha1/mysqlrestore.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" scheme "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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" @@ -31,14 +31,14 @@ type MySQLRestoresGetter interface { // MySQLRestoreInterface has methods to work with MySQLRestore resources. type MySQLRestoreInterface interface { - Create(*v1.MySQLRestore) (*v1.MySQLRestore, error) - Update(*v1.MySQLRestore) (*v1.MySQLRestore, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.MySQLRestore, error) - List(opts meta_v1.ListOptions) (*v1.MySQLRestoreList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLRestore, err error) + Create(*v1alpha1.MySQLRestore) (*v1alpha1.MySQLRestore, error) + Update(*v1alpha1.MySQLRestore) (*v1alpha1.MySQLRestore, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MySQLRestore, error) + List(opts v1.ListOptions) (*v1alpha1.MySQLRestoreList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLRestore, err error) MySQLRestoreExpansion } @@ -49,7 +49,7 @@ type mySQLRestores struct { } // newMySQLRestores returns a MySQLRestores -func newMySQLRestores(c *MysqlV1Client, namespace string) *mySQLRestores { +func newMySQLRestores(c *MysqlV1alpha1Client, namespace string) *mySQLRestores { return &mySQLRestores{ client: c.RESTClient(), ns: namespace, @@ -57,8 +57,8 @@ func newMySQLRestores(c *MysqlV1Client, namespace string) *mySQLRestores { } // Get takes name of the mySQLRestore, and returns the corresponding mySQLRestore object, and an error if there is any. -func (c *mySQLRestores) Get(name string, options meta_v1.GetOptions) (result *v1.MySQLRestore, err error) { - result = &v1.MySQLRestore{} +func (c *mySQLRestores) Get(name string, options v1.GetOptions) (result *v1alpha1.MySQLRestore, err error) { + result = &v1alpha1.MySQLRestore{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlrestores"). @@ -70,8 +70,8 @@ func (c *mySQLRestores) Get(name string, options meta_v1.GetOptions) (result *v1 } // List takes label and field selectors, and returns the list of MySQLRestores that match those selectors. -func (c *mySQLRestores) List(opts meta_v1.ListOptions) (result *v1.MySQLRestoreList, err error) { - result = &v1.MySQLRestoreList{} +func (c *mySQLRestores) List(opts v1.ListOptions) (result *v1alpha1.MySQLRestoreList, err error) { + result = &v1alpha1.MySQLRestoreList{} err = c.client.Get(). Namespace(c.ns). Resource("mysqlrestores"). @@ -82,7 +82,7 @@ func (c *mySQLRestores) List(opts meta_v1.ListOptions) (result *v1.MySQLRestoreL } // Watch returns a watch.Interface that watches the requested mySQLRestores. -func (c *mySQLRestores) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { +func (c *mySQLRestores) Watch(opts v1.ListOptions) (watch.Interface, error) { opts.Watch = true return c.client.Get(). Namespace(c.ns). @@ -92,8 +92,8 @@ func (c *mySQLRestores) Watch(opts meta_v1.ListOptions) (watch.Interface, error) } // Create takes the representation of a mySQLRestore and creates it. Returns the server's representation of the mySQLRestore, and an error, if there is any. -func (c *mySQLRestores) Create(mySQLRestore *v1.MySQLRestore) (result *v1.MySQLRestore, err error) { - result = &v1.MySQLRestore{} +func (c *mySQLRestores) Create(mySQLRestore *v1alpha1.MySQLRestore) (result *v1alpha1.MySQLRestore, err error) { + result = &v1alpha1.MySQLRestore{} err = c.client.Post(). Namespace(c.ns). Resource("mysqlrestores"). @@ -104,8 +104,8 @@ func (c *mySQLRestores) Create(mySQLRestore *v1.MySQLRestore) (result *v1.MySQLR } // Update takes the representation of a mySQLRestore and updates it. Returns the server's representation of the mySQLRestore, and an error, if there is any. -func (c *mySQLRestores) Update(mySQLRestore *v1.MySQLRestore) (result *v1.MySQLRestore, err error) { - result = &v1.MySQLRestore{} +func (c *mySQLRestores) Update(mySQLRestore *v1alpha1.MySQLRestore) (result *v1alpha1.MySQLRestore, err error) { + result = &v1alpha1.MySQLRestore{} err = c.client.Put(). Namespace(c.ns). Resource("mysqlrestores"). @@ -117,7 +117,7 @@ func (c *mySQLRestores) Update(mySQLRestore *v1.MySQLRestore) (result *v1.MySQLR } // Delete takes name of the mySQLRestore and deletes it. Returns an error if one occurs. -func (c *mySQLRestores) Delete(name string, options *meta_v1.DeleteOptions) error { +func (c *mySQLRestores) Delete(name string, options *v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlrestores"). @@ -128,7 +128,7 @@ func (c *mySQLRestores) Delete(name string, options *meta_v1.DeleteOptions) erro } // DeleteCollection deletes a collection of objects. -func (c *mySQLRestores) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { +func (c *mySQLRestores) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("mysqlrestores"). @@ -139,8 +139,8 @@ func (c *mySQLRestores) DeleteCollection(options *meta_v1.DeleteOptions, listOpt } // Patch applies the patch and returns the patched mySQLRestore. -func (c *mySQLRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.MySQLRestore, err error) { - result = &v1.MySQLRestore{} +func (c *mySQLRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MySQLRestore, err error) { + result = &v1alpha1.MySQLRestore{} err = c.client.Patch(pt). Namespace(c.ns). Resource("mysqlrestores"). diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index f22327f8c..0b856984a 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -19,7 +19,7 @@ package externalversions import ( "fmt" - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -50,15 +50,15 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=mysql.oracle.com, Version=v1 - case v1.SchemeGroupVersion.WithResource("mysqlbackups"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1().MySQLBackups().Informer()}, nil - case v1.SchemeGroupVersion.WithResource("mysqlbackupschedules"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1().MySQLBackupSchedules().Informer()}, nil - case v1.SchemeGroupVersion.WithResource("mysqlclusters"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1().MySQLClusters().Informer()}, nil - case v1.SchemeGroupVersion.WithResource("mysqlrestores"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1().MySQLRestores().Informer()}, nil + // Group=mysql.oracle.com, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("mysqlbackups"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1alpha1().MySQLBackups().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("mysqlbackupschedules"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1alpha1().MySQLBackupSchedules().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("mysqlclusters"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1alpha1().MySQLClusters().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("mysqlrestores"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Mysql().V1alpha1().MySQLRestores().Informer()}, nil } diff --git a/pkg/generated/informers/externalversions/mysql/interface.go b/pkg/generated/informers/externalversions/mysql/interface.go index 45af186cc..f60a95429 100644 --- a/pkg/generated/informers/externalversions/mysql/interface.go +++ b/pkg/generated/informers/externalversions/mysql/interface.go @@ -18,13 +18,13 @@ package mysql import ( internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/mysql/v1alpha1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface } type group struct { @@ -38,7 +38,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.factory, g.namespace, g.tweakListOptions) +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/mysql/v1/interface.go b/pkg/generated/informers/externalversions/mysql/v1alpha1/interface.go similarity index 99% rename from pkg/generated/informers/externalversions/mysql/v1/interface.go rename to pkg/generated/informers/externalversions/mysql/v1alpha1/interface.go index 6ee8fe863..840533264 100644 --- a/pkg/generated/informers/externalversions/mysql/v1/interface.go +++ b/pkg/generated/informers/externalversions/mysql/v1alpha1/interface.go @@ -14,7 +14,7 @@ // This file was automatically generated by informer-gen -package v1 +package v1alpha1 import ( internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" diff --git a/pkg/generated/informers/externalversions/mysql/v1/mysqlbackup.go b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackup.go similarity index 79% rename from pkg/generated/informers/externalversions/mysql/v1/mysqlbackup.go rename to pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackup.go index 257961dc0..130f757b9 100644 --- a/pkg/generated/informers/externalversions/mysql/v1/mysqlbackup.go +++ b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackup.go @@ -14,16 +14,16 @@ // This file was automatically generated by informer-gen -package v1 +package v1alpha1 import ( time "time" - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysql_v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" versioned "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -33,7 +33,7 @@ import ( // MySQLBackups. type MySQLBackupInformer interface { Informer() cache.SharedIndexInformer - Lister() v1.MySQLBackupLister + Lister() v1alpha1.MySQLBackupLister } type mySQLBackupInformer struct { @@ -55,20 +55,20 @@ func NewMySQLBackupInformer(client versioned.Interface, namespace string, resync func NewFilteredMySQLBackupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLBackups(namespace).List(options) + return client.MysqlV1alpha1().MySQLBackups(namespace).List(options) }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLBackups(namespace).Watch(options) + return client.MysqlV1alpha1().MySQLBackups(namespace).Watch(options) }, }, - &mysql_v1.MySQLBackup{}, + &mysql_v1alpha1.MySQLBackup{}, resyncPeriod, indexers, ) @@ -79,9 +79,9 @@ func (f *mySQLBackupInformer) defaultInformer(client versioned.Interface, resync } func (f *mySQLBackupInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&mysql_v1.MySQLBackup{}, f.defaultInformer) + return f.factory.InformerFor(&mysql_v1alpha1.MySQLBackup{}, f.defaultInformer) } -func (f *mySQLBackupInformer) Lister() v1.MySQLBackupLister { - return v1.NewMySQLBackupLister(f.Informer().GetIndexer()) +func (f *mySQLBackupInformer) Lister() v1alpha1.MySQLBackupLister { + return v1alpha1.NewMySQLBackupLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/informers/externalversions/mysql/v1/mysqlbackupschedule.go b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackupschedule.go similarity index 78% rename from pkg/generated/informers/externalversions/mysql/v1/mysqlbackupschedule.go rename to pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackupschedule.go index 15f96609e..811e3280f 100644 --- a/pkg/generated/informers/externalversions/mysql/v1/mysqlbackupschedule.go +++ b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlbackupschedule.go @@ -14,16 +14,16 @@ // This file was automatically generated by informer-gen -package v1 +package v1alpha1 import ( time "time" - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysql_v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" versioned "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -33,7 +33,7 @@ import ( // MySQLBackupSchedules. type MySQLBackupScheduleInformer interface { Informer() cache.SharedIndexInformer - Lister() v1.MySQLBackupScheduleLister + Lister() v1alpha1.MySQLBackupScheduleLister } type mySQLBackupScheduleInformer struct { @@ -55,20 +55,20 @@ func NewMySQLBackupScheduleInformer(client versioned.Interface, namespace string func NewFilteredMySQLBackupScheduleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLBackupSchedules(namespace).List(options) + return client.MysqlV1alpha1().MySQLBackupSchedules(namespace).List(options) }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLBackupSchedules(namespace).Watch(options) + return client.MysqlV1alpha1().MySQLBackupSchedules(namespace).Watch(options) }, }, - &mysql_v1.MySQLBackupSchedule{}, + &mysql_v1alpha1.MySQLBackupSchedule{}, resyncPeriod, indexers, ) @@ -79,9 +79,9 @@ func (f *mySQLBackupScheduleInformer) defaultInformer(client versioned.Interface } func (f *mySQLBackupScheduleInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&mysql_v1.MySQLBackupSchedule{}, f.defaultInformer) + return f.factory.InformerFor(&mysql_v1alpha1.MySQLBackupSchedule{}, f.defaultInformer) } -func (f *mySQLBackupScheduleInformer) Lister() v1.MySQLBackupScheduleLister { - return v1.NewMySQLBackupScheduleLister(f.Informer().GetIndexer()) +func (f *mySQLBackupScheduleInformer) Lister() v1alpha1.MySQLBackupScheduleLister { + return v1alpha1.NewMySQLBackupScheduleLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/informers/externalversions/mysql/v1/mysqlcluster.go b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlcluster.go similarity index 79% rename from pkg/generated/informers/externalversions/mysql/v1/mysqlcluster.go rename to pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlcluster.go index 06647d7fd..eb0856f98 100644 --- a/pkg/generated/informers/externalversions/mysql/v1/mysqlcluster.go +++ b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlcluster.go @@ -14,16 +14,16 @@ // This file was automatically generated by informer-gen -package v1 +package v1alpha1 import ( time "time" - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysql_v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" versioned "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -33,7 +33,7 @@ import ( // MySQLClusters. type MySQLClusterInformer interface { Informer() cache.SharedIndexInformer - Lister() v1.MySQLClusterLister + Lister() v1alpha1.MySQLClusterLister } type mySQLClusterInformer struct { @@ -55,20 +55,20 @@ func NewMySQLClusterInformer(client versioned.Interface, namespace string, resyn func NewFilteredMySQLClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLClusters(namespace).List(options) + return client.MysqlV1alpha1().MySQLClusters(namespace).List(options) }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLClusters(namespace).Watch(options) + return client.MysqlV1alpha1().MySQLClusters(namespace).Watch(options) }, }, - &mysql_v1.MySQLCluster{}, + &mysql_v1alpha1.MySQLCluster{}, resyncPeriod, indexers, ) @@ -79,9 +79,9 @@ func (f *mySQLClusterInformer) defaultInformer(client versioned.Interface, resyn } func (f *mySQLClusterInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&mysql_v1.MySQLCluster{}, f.defaultInformer) + return f.factory.InformerFor(&mysql_v1alpha1.MySQLCluster{}, f.defaultInformer) } -func (f *mySQLClusterInformer) Lister() v1.MySQLClusterLister { - return v1.NewMySQLClusterLister(f.Informer().GetIndexer()) +func (f *mySQLClusterInformer) Lister() v1alpha1.MySQLClusterLister { + return v1alpha1.NewMySQLClusterLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/informers/externalversions/mysql/v1/mysqlrestore.go b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlrestore.go similarity index 79% rename from pkg/generated/informers/externalversions/mysql/v1/mysqlrestore.go rename to pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlrestore.go index c7342c556..feffef388 100644 --- a/pkg/generated/informers/externalversions/mysql/v1/mysqlrestore.go +++ b/pkg/generated/informers/externalversions/mysql/v1alpha1/mysqlrestore.go @@ -14,16 +14,16 @@ // This file was automatically generated by informer-gen -package v1 +package v1alpha1 import ( time "time" - mysql_v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + mysql_v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" versioned "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" internalinterfaces "github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/generated/listers/mysql/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -33,7 +33,7 @@ import ( // MySQLRestores. type MySQLRestoreInformer interface { Informer() cache.SharedIndexInformer - Lister() v1.MySQLRestoreLister + Lister() v1alpha1.MySQLRestoreLister } type mySQLRestoreInformer struct { @@ -55,20 +55,20 @@ func NewMySQLRestoreInformer(client versioned.Interface, namespace string, resyn func NewFilteredMySQLRestoreInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLRestores(namespace).List(options) + return client.MysqlV1alpha1().MySQLRestores(namespace).List(options) }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MysqlV1().MySQLRestores(namespace).Watch(options) + return client.MysqlV1alpha1().MySQLRestores(namespace).Watch(options) }, }, - &mysql_v1.MySQLRestore{}, + &mysql_v1alpha1.MySQLRestore{}, resyncPeriod, indexers, ) @@ -79,9 +79,9 @@ func (f *mySQLRestoreInformer) defaultInformer(client versioned.Interface, resyn } func (f *mySQLRestoreInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&mysql_v1.MySQLRestore{}, f.defaultInformer) + return f.factory.InformerFor(&mysql_v1alpha1.MySQLRestore{}, f.defaultInformer) } -func (f *mySQLRestoreInformer) Lister() v1.MySQLRestoreLister { - return v1.NewMySQLRestoreLister(f.Informer().GetIndexer()) +func (f *mySQLRestoreInformer) Lister() v1alpha1.MySQLRestoreLister { + return v1alpha1.NewMySQLRestoreLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/listers/mysql/v1/expansion_generated.go b/pkg/generated/listers/mysql/v1alpha1/expansion_generated.go similarity index 99% rename from pkg/generated/listers/mysql/v1/expansion_generated.go rename to pkg/generated/listers/mysql/v1alpha1/expansion_generated.go index 19c2a175d..05a5bff7b 100644 --- a/pkg/generated/listers/mysql/v1/expansion_generated.go +++ b/pkg/generated/listers/mysql/v1alpha1/expansion_generated.go @@ -14,7 +14,7 @@ // This file was automatically generated by lister-gen -package v1 +package v1alpha1 // MySQLBackupListerExpansion allows custom methods to be added to // MySQLBackupLister. diff --git a/pkg/generated/listers/mysql/v1/mysqlbackup.go b/pkg/generated/listers/mysql/v1alpha1/mysqlbackup.go similarity index 80% rename from pkg/generated/listers/mysql/v1/mysqlbackup.go rename to pkg/generated/listers/mysql/v1alpha1/mysqlbackup.go index 0c8219734..60010cc35 100644 --- a/pkg/generated/listers/mysql/v1/mysqlbackup.go +++ b/pkg/generated/listers/mysql/v1alpha1/mysqlbackup.go @@ -14,10 +14,10 @@ // This file was automatically generated by lister-gen -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -26,7 +26,7 @@ import ( // MySQLBackupLister helps list MySQLBackups. type MySQLBackupLister interface { // List lists all MySQLBackups in the indexer. - List(selector labels.Selector) (ret []*v1.MySQLBackup, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLBackup, err error) // MySQLBackups returns an object that can list and get MySQLBackups. MySQLBackups(namespace string) MySQLBackupNamespaceLister MySQLBackupListerExpansion @@ -43,9 +43,9 @@ func NewMySQLBackupLister(indexer cache.Indexer) MySQLBackupLister { } // List lists all MySQLBackups in the indexer. -func (s *mySQLBackupLister) List(selector labels.Selector) (ret []*v1.MySQLBackup, err error) { +func (s *mySQLBackupLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLBackup, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLBackup)) + ret = append(ret, m.(*v1alpha1.MySQLBackup)) }) return ret, err } @@ -58,9 +58,9 @@ func (s *mySQLBackupLister) MySQLBackups(namespace string) MySQLBackupNamespaceL // MySQLBackupNamespaceLister helps list and get MySQLBackups. type MySQLBackupNamespaceLister interface { // List lists all MySQLBackups in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.MySQLBackup, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLBackup, err error) // Get retrieves the MySQLBackup from the indexer for a given namespace and name. - Get(name string) (*v1.MySQLBackup, error) + Get(name string) (*v1alpha1.MySQLBackup, error) MySQLBackupNamespaceListerExpansion } @@ -72,21 +72,21 @@ type mySQLBackupNamespaceLister struct { } // List lists all MySQLBackups in the indexer for a given namespace. -func (s mySQLBackupNamespaceLister) List(selector labels.Selector) (ret []*v1.MySQLBackup, err error) { +func (s mySQLBackupNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLBackup, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLBackup)) + ret = append(ret, m.(*v1alpha1.MySQLBackup)) }) return ret, err } // Get retrieves the MySQLBackup from the indexer for a given namespace and name. -func (s mySQLBackupNamespaceLister) Get(name string) (*v1.MySQLBackup, error) { +func (s mySQLBackupNamespaceLister) Get(name string) (*v1alpha1.MySQLBackup, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1.Resource("mysqlbackup"), name) + return nil, errors.NewNotFound(v1alpha1.Resource("mysqlbackup"), name) } - return obj.(*v1.MySQLBackup), nil + return obj.(*v1alpha1.MySQLBackup), nil } diff --git a/pkg/generated/listers/mysql/v1/mysqlbackupschedule.go b/pkg/generated/listers/mysql/v1alpha1/mysqlbackupschedule.go similarity index 81% rename from pkg/generated/listers/mysql/v1/mysqlbackupschedule.go rename to pkg/generated/listers/mysql/v1alpha1/mysqlbackupschedule.go index 6f9113ae7..bb900da62 100644 --- a/pkg/generated/listers/mysql/v1/mysqlbackupschedule.go +++ b/pkg/generated/listers/mysql/v1alpha1/mysqlbackupschedule.go @@ -14,10 +14,10 @@ // This file was automatically generated by lister-gen -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -26,7 +26,7 @@ import ( // MySQLBackupScheduleLister helps list MySQLBackupSchedules. type MySQLBackupScheduleLister interface { // List lists all MySQLBackupSchedules in the indexer. - List(selector labels.Selector) (ret []*v1.MySQLBackupSchedule, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLBackupSchedule, err error) // MySQLBackupSchedules returns an object that can list and get MySQLBackupSchedules. MySQLBackupSchedules(namespace string) MySQLBackupScheduleNamespaceLister MySQLBackupScheduleListerExpansion @@ -43,9 +43,9 @@ func NewMySQLBackupScheduleLister(indexer cache.Indexer) MySQLBackupScheduleList } // List lists all MySQLBackupSchedules in the indexer. -func (s *mySQLBackupScheduleLister) List(selector labels.Selector) (ret []*v1.MySQLBackupSchedule, err error) { +func (s *mySQLBackupScheduleLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLBackupSchedule, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLBackupSchedule)) + ret = append(ret, m.(*v1alpha1.MySQLBackupSchedule)) }) return ret, err } @@ -58,9 +58,9 @@ func (s *mySQLBackupScheduleLister) MySQLBackupSchedules(namespace string) MySQL // MySQLBackupScheduleNamespaceLister helps list and get MySQLBackupSchedules. type MySQLBackupScheduleNamespaceLister interface { // List lists all MySQLBackupSchedules in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.MySQLBackupSchedule, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLBackupSchedule, err error) // Get retrieves the MySQLBackupSchedule from the indexer for a given namespace and name. - Get(name string) (*v1.MySQLBackupSchedule, error) + Get(name string) (*v1alpha1.MySQLBackupSchedule, error) MySQLBackupScheduleNamespaceListerExpansion } @@ -72,21 +72,21 @@ type mySQLBackupScheduleNamespaceLister struct { } // List lists all MySQLBackupSchedules in the indexer for a given namespace. -func (s mySQLBackupScheduleNamespaceLister) List(selector labels.Selector) (ret []*v1.MySQLBackupSchedule, err error) { +func (s mySQLBackupScheduleNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLBackupSchedule, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLBackupSchedule)) + ret = append(ret, m.(*v1alpha1.MySQLBackupSchedule)) }) return ret, err } // Get retrieves the MySQLBackupSchedule from the indexer for a given namespace and name. -func (s mySQLBackupScheduleNamespaceLister) Get(name string) (*v1.MySQLBackupSchedule, error) { +func (s mySQLBackupScheduleNamespaceLister) Get(name string) (*v1alpha1.MySQLBackupSchedule, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1.Resource("mysqlbackupschedule"), name) + return nil, errors.NewNotFound(v1alpha1.Resource("mysqlbackupschedule"), name) } - return obj.(*v1.MySQLBackupSchedule), nil + return obj.(*v1alpha1.MySQLBackupSchedule), nil } diff --git a/pkg/generated/listers/mysql/v1/mysqlcluster.go b/pkg/generated/listers/mysql/v1alpha1/mysqlcluster.go similarity index 80% rename from pkg/generated/listers/mysql/v1/mysqlcluster.go rename to pkg/generated/listers/mysql/v1alpha1/mysqlcluster.go index 4a6b90d09..9e3ba72a0 100644 --- a/pkg/generated/listers/mysql/v1/mysqlcluster.go +++ b/pkg/generated/listers/mysql/v1alpha1/mysqlcluster.go @@ -14,10 +14,10 @@ // This file was automatically generated by lister-gen -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -26,7 +26,7 @@ import ( // MySQLClusterLister helps list MySQLClusters. type MySQLClusterLister interface { // List lists all MySQLClusters in the indexer. - List(selector labels.Selector) (ret []*v1.MySQLCluster, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLCluster, err error) // MySQLClusters returns an object that can list and get MySQLClusters. MySQLClusters(namespace string) MySQLClusterNamespaceLister MySQLClusterListerExpansion @@ -43,9 +43,9 @@ func NewMySQLClusterLister(indexer cache.Indexer) MySQLClusterLister { } // List lists all MySQLClusters in the indexer. -func (s *mySQLClusterLister) List(selector labels.Selector) (ret []*v1.MySQLCluster, err error) { +func (s *mySQLClusterLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLCluster, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLCluster)) + ret = append(ret, m.(*v1alpha1.MySQLCluster)) }) return ret, err } @@ -58,9 +58,9 @@ func (s *mySQLClusterLister) MySQLClusters(namespace string) MySQLClusterNamespa // MySQLClusterNamespaceLister helps list and get MySQLClusters. type MySQLClusterNamespaceLister interface { // List lists all MySQLClusters in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.MySQLCluster, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLCluster, err error) // Get retrieves the MySQLCluster from the indexer for a given namespace and name. - Get(name string) (*v1.MySQLCluster, error) + Get(name string) (*v1alpha1.MySQLCluster, error) MySQLClusterNamespaceListerExpansion } @@ -72,21 +72,21 @@ type mySQLClusterNamespaceLister struct { } // List lists all MySQLClusters in the indexer for a given namespace. -func (s mySQLClusterNamespaceLister) List(selector labels.Selector) (ret []*v1.MySQLCluster, err error) { +func (s mySQLClusterNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLCluster, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLCluster)) + ret = append(ret, m.(*v1alpha1.MySQLCluster)) }) return ret, err } // Get retrieves the MySQLCluster from the indexer for a given namespace and name. -func (s mySQLClusterNamespaceLister) Get(name string) (*v1.MySQLCluster, error) { +func (s mySQLClusterNamespaceLister) Get(name string) (*v1alpha1.MySQLCluster, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1.Resource("mysqlcluster"), name) + return nil, errors.NewNotFound(v1alpha1.Resource("mysqlcluster"), name) } - return obj.(*v1.MySQLCluster), nil + return obj.(*v1alpha1.MySQLCluster), nil } diff --git a/pkg/generated/listers/mysql/v1/mysqlrestore.go b/pkg/generated/listers/mysql/v1alpha1/mysqlrestore.go similarity index 80% rename from pkg/generated/listers/mysql/v1/mysqlrestore.go rename to pkg/generated/listers/mysql/v1alpha1/mysqlrestore.go index 1b907c704..44bf5400a 100644 --- a/pkg/generated/listers/mysql/v1/mysqlrestore.go +++ b/pkg/generated/listers/mysql/v1alpha1/mysqlrestore.go @@ -14,10 +14,10 @@ // This file was automatically generated by lister-gen -package v1 +package v1alpha1 import ( - v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1alpha1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" @@ -26,7 +26,7 @@ import ( // MySQLRestoreLister helps list MySQLRestores. type MySQLRestoreLister interface { // List lists all MySQLRestores in the indexer. - List(selector labels.Selector) (ret []*v1.MySQLRestore, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLRestore, err error) // MySQLRestores returns an object that can list and get MySQLRestores. MySQLRestores(namespace string) MySQLRestoreNamespaceLister MySQLRestoreListerExpansion @@ -43,9 +43,9 @@ func NewMySQLRestoreLister(indexer cache.Indexer) MySQLRestoreLister { } // List lists all MySQLRestores in the indexer. -func (s *mySQLRestoreLister) List(selector labels.Selector) (ret []*v1.MySQLRestore, err error) { +func (s *mySQLRestoreLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLRestore, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLRestore)) + ret = append(ret, m.(*v1alpha1.MySQLRestore)) }) return ret, err } @@ -58,9 +58,9 @@ func (s *mySQLRestoreLister) MySQLRestores(namespace string) MySQLRestoreNamespa // MySQLRestoreNamespaceLister helps list and get MySQLRestores. type MySQLRestoreNamespaceLister interface { // List lists all MySQLRestores in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.MySQLRestore, err error) + List(selector labels.Selector) (ret []*v1alpha1.MySQLRestore, err error) // Get retrieves the MySQLRestore from the indexer for a given namespace and name. - Get(name string) (*v1.MySQLRestore, error) + Get(name string) (*v1alpha1.MySQLRestore, error) MySQLRestoreNamespaceListerExpansion } @@ -72,21 +72,21 @@ type mySQLRestoreNamespaceLister struct { } // List lists all MySQLRestores in the indexer for a given namespace. -func (s mySQLRestoreNamespaceLister) List(selector labels.Selector) (ret []*v1.MySQLRestore, err error) { +func (s mySQLRestoreNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MySQLRestore, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.MySQLRestore)) + ret = append(ret, m.(*v1alpha1.MySQLRestore)) }) return ret, err } // Get retrieves the MySQLRestore from the indexer for a given namespace and name. -func (s mySQLRestoreNamespaceLister) Get(name string) (*v1.MySQLRestore, error) { +func (s mySQLRestoreNamespaceLister) Get(name string) (*v1alpha1.MySQLRestore, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, errors.NewNotFound(v1.Resource("mysqlrestore"), name) + return nil, errors.NewNotFound(v1alpha1.Resource("mysqlrestore"), name) } - return obj.(*v1.MySQLRestore), nil + return obj.(*v1alpha1.MySQLRestore), nil } diff --git a/pkg/resources/secrets/secret.go b/pkg/resources/secrets/secret.go index 0d4dd9ce9..ed0e1ae50 100644 --- a/pkg/resources/secrets/secret.go +++ b/pkg/resources/secrets/secret.go @@ -17,27 +17,27 @@ package secrets import ( "fmt" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/constants" ) // NewMysqlRootPassword returns a Kubernetes secret containing a // generated MySQL root password. -func NewMysqlRootPassword(cluster *api.MySQLCluster) *v1.Secret { +func NewMysqlRootPassword(cluster *v1alpha1.MySQLCluster) *corev1.Secret { CreateSecret := RandomAlphanumericString(16) - secret := &v1.Secret{ + secret := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{constants.MySQLClusterLabel: cluster.Name}, Name: GetRootPasswordSecretName(cluster), OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(cluster, schema.GroupVersionKind{ - Group: api.SchemeGroupVersion.Group, - Version: api.SchemeGroupVersion.Version, - Kind: api.MySQLClusterCRDResourceKind, + Group: v1alpha1.SchemeGroupVersion.Group, + Version: v1alpha1.SchemeGroupVersion.Version, + Kind: v1alpha1.MySQLClusterCRDResourceKind, }), }, Namespace: cluster.Namespace, @@ -49,6 +49,6 @@ func NewMysqlRootPassword(cluster *api.MySQLCluster) *v1.Secret { // GetRootPasswordSecretName returns the root password secret name for the // given mysql cluster. -func GetRootPasswordSecretName(cluster *api.MySQLCluster) string { +func GetRootPasswordSecretName(cluster *v1alpha1.MySQLCluster) string { return fmt.Sprintf("%s-root-password", cluster.Name) } diff --git a/pkg/resources/secrets/secret_test.go b/pkg/resources/secrets/secret_test.go index 4cf59de67..9999f22b0 100644 --- a/pkg/resources/secrets/secret_test.go +++ b/pkg/resources/secrets/secret_test.go @@ -19,13 +19,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) func TestGetRootPasswordSecretName(t *testing.T) { - cluster := &api.MySQLCluster{ + cluster := &v1alpha1.MySQLCluster{ ObjectMeta: metav1.ObjectMeta{Name: "example-cluster"}, - Spec: api.MySQLClusterSpec{}, + Spec: v1alpha1.MySQLClusterSpec{}, } actual := GetRootPasswordSecretName(cluster) diff --git a/pkg/resources/services/service.go b/pkg/resources/services/service.go index cd0b16971..193ff120b 100644 --- a/pkg/resources/services/service.go +++ b/pkg/resources/services/service.go @@ -15,38 +15,39 @@ package services import ( - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" - "github.com/oracle/mysql-operator/pkg/constants" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" + "github.com/oracle/mysql-operator/pkg/constants" ) // NewForCluster will return a new headless Kubernetes service for a MySQL cluster -func NewForCluster(cluster *api.MySQLCluster) *v1.Service { - mysqlPort := v1.ServicePort{Port: 3306} - svc := &v1.Service{ +func NewForCluster(cluster *v1alpha1.MySQLCluster) *corev1.Service { + mysqlPort := corev1.ServicePort{Port: 3306} + svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{constants.MySQLClusterLabel: cluster.Name}, Name: cluster.Name, Namespace: cluster.Namespace, OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(cluster, schema.GroupVersionKind{ - Group: api.SchemeGroupVersion.Group, - Version: api.SchemeGroupVersion.Version, - Kind: api.MySQLClusterCRDResourceKind, + Group: v1alpha1.SchemeGroupVersion.Group, + Version: v1alpha1.SchemeGroupVersion.Version, + Kind: v1alpha1.MySQLClusterCRDResourceKind, }), }, Annotations: map[string]string{ "service.alpha.kubernetes.io/tolerate-unready-endpoints": "true", }, }, - Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{mysqlPort}, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{mysqlPort}, Selector: map[string]string{ constants.MySQLClusterLabel: cluster.Name, }, - ClusterIP: v1.ClusterIPNone, + ClusterIP: corev1.ClusterIPNone, }, } diff --git a/pkg/resources/statefulsets/statefulset.go b/pkg/resources/statefulsets/statefulset.go index 12df7a428..495028ded 100644 --- a/pkg/resources/statefulsets/statefulset.go +++ b/pkg/resources/statefulsets/statefulset.go @@ -28,7 +28,7 @@ import ( agentopts "github.com/oracle/mysql-operator/cmd/mysql-agent/app/options" operatoropts "github.com/oracle/mysql-operator/cmd/mysql-operator/app/options" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/constants" "github.com/oracle/mysql-operator/pkg/resources/secrets" "github.com/oracle/mysql-operator/pkg/version" @@ -49,7 +49,7 @@ const ( replicationGroupPort = 13306 ) -func volumeMounts(cluster *api.MySQLCluster) []v1.VolumeMount { +func volumeMounts(cluster *v1alpha1.MySQLCluster) []v1.VolumeMount { var mounts []v1.VolumeMount name := mySQLVolumeName @@ -93,7 +93,7 @@ func volumeMounts(cluster *api.MySQLCluster) []v1.VolumeMount { return mounts } -func clusterNameEnvVar(cluster *api.MySQLCluster) v1.EnvVar { +func clusterNameEnvVar(cluster *v1alpha1.MySQLCluster) v1.EnvVar { return v1.EnvVar{Name: "MYSQL_CLUSTER_NAME", Value: cluster.Name} } @@ -125,7 +125,7 @@ func multiMasterEnvVar(enabled bool) v1.EnvVar { // Returns the MySQL_ROOT_PASSWORD environment variable // If a user specifies a secret in the spec we use that // else we create a secret with a random password -func mysqlRootPassword(cluster *api.MySQLCluster) v1.EnvVar { +func mysqlRootPassword(cluster *v1alpha1.MySQLCluster) v1.EnvVar { var secretName string if cluster.RequiresSecret() { secretName = secrets.GetRootPasswordSecretName(cluster) @@ -164,7 +164,7 @@ func getReplicationGroupSeeds(name string, replicas int) string { // Builds the MySQL operator container for a cluster. // The 'mysqlImage' parameter is the image name of the mysql server to use with // no version information.. e.g. 'mysql/mysql-server' -func mysqlServerContainer(cluster *api.MySQLCluster, mysqlServerImage string, rootPassword v1.EnvVar, serviceName string, replicas int, baseServerID uint32) v1.Container { +func mysqlServerContainer(cluster *v1alpha1.MySQLCluster, mysqlServerImage string, rootPassword v1.EnvVar, serviceName string, replicas int, baseServerID uint32) v1.Container { replicationGroupSeeds := getReplicationGroupSeeds(cluster.Namespace, replicas) args := []string{ @@ -232,7 +232,7 @@ func mysqlServerContainer(cluster *api.MySQLCluster, mysqlServerImage string, ro } } -func mysqlAgentContainer(cluster *api.MySQLCluster, mysqlAgentImage string, rootPassword v1.EnvVar, serviceName string, replicas int) v1.Container { +func mysqlAgentContainer(cluster *v1alpha1.MySQLCluster, mysqlAgentImage string, rootPassword v1.EnvVar, serviceName string, replicas int) v1.Container { agentVersion := version.GetBuildVersion() if version := os.Getenv("MYSQL_AGENT_VERSION"); version != "" { agentVersion = version @@ -281,7 +281,7 @@ func mysqlAgentContainer(cluster *api.MySQLCluster, mysqlAgentImage string, root } // NewForCluster creates a new StatefulSet for the given MySQLCluster. -func NewForCluster(cluster *api.MySQLCluster, images operatoropts.Images, serviceName string) *apps.StatefulSet { +func NewForCluster(cluster *v1alpha1.MySQLCluster, images operatoropts.Images, serviceName string) *apps.StatefulSet { rootPassword := mysqlRootPassword(cluster) replicas := int(cluster.Spec.Replicas) baseServerID := cluster.Spec.BaseServerID @@ -362,9 +362,9 @@ func NewForCluster(cluster *api.MySQLCluster, images operatoropts.Images, servic Name: cluster.Name, OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(cluster, schema.GroupVersionKind{ - Group: api.SchemeGroupVersion.Group, - Version: api.SchemeGroupVersion.Version, - Kind: api.MySQLClusterCRDResourceKind, + Group: v1alpha1.SchemeGroupVersion.Group, + Version: v1alpha1.SchemeGroupVersion.Version, + Kind: v1alpha1.MySQLClusterCRDResourceKind, }), }, Labels: map[string]string{ diff --git a/pkg/resources/statefulsets/statefulset_test.go b/pkg/resources/statefulsets/statefulset_test.go index 1a859c9d6..629df9040 100644 --- a/pkg/resources/statefulsets/statefulset_test.go +++ b/pkg/resources/statefulsets/statefulset_test.go @@ -19,11 +19,11 @@ import ( "testing" "github.com/stretchr/testify/assert" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" options "github.com/oracle/mysql-operator/cmd/mysql-operator/app/options" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) func mockOperatorConfig() options.MySQLOperatorServer { @@ -33,9 +33,9 @@ func mockOperatorConfig() options.MySQLOperatorServer { } func TestMySQLRootPasswordNoSecretRef(t *testing.T) { - cluster := &api.MySQLCluster{ + cluster := &v1alpha1.MySQLCluster{ ObjectMeta: metav1.ObjectMeta{Name: "cluster"}, - Spec: api.MySQLClusterSpec{}, + Spec: v1alpha1.MySQLClusterSpec{}, } actual := mysqlRootPassword(cluster).ValueFrom.SecretKeyRef.Name @@ -46,9 +46,9 @@ func TestMySQLRootPasswordNoSecretRef(t *testing.T) { } func TestMySQLRootPasswordWithSecretRef(t *testing.T) { - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ - SecretRef: &v1.LocalObjectReference{Name: "secret"}, + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ + SecretRef: &corev1.LocalObjectReference{Name: "secret"}, }, } @@ -60,9 +60,9 @@ func TestMySQLRootPasswordWithSecretRef(t *testing.T) { } func TestClusterWithoutPVCHasBackupContainerAndVolumes(t *testing.T) { - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ - SecretRef: &v1.LocalObjectReference{Name: "secret"}, + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ + SecretRef: &corev1.LocalObjectReference{Name: "secret"}, }, } @@ -79,11 +79,11 @@ func TestClusterWithoutPVCHasBackupContainerAndVolumes(t *testing.T) { } func TestClusterWithPVCHasBackupContainerAndVolumes(t *testing.T) { - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ - SecretRef: &v1.LocalObjectReference{Name: "secret"}, - VolumeClaimTemplate: &v1.PersistentVolumeClaim{}, - BackupVolumeClaimTemplate: &v1.PersistentVolumeClaim{}, + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ + SecretRef: &corev1.LocalObjectReference{Name: "secret"}, + VolumeClaimTemplate: &corev1.PersistentVolumeClaim{}, + BackupVolumeClaimTemplate: &corev1.PersistentVolumeClaim{}, }, } @@ -101,8 +101,8 @@ func TestClusterWithPVCHasBackupContainerAndVolumes(t *testing.T) { func TestClusterHasNodeSelector(t *testing.T) { nvmeSelector := map[string]string{"disk": "nvme"} - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ NodeSelector: nvmeSelector, }, } @@ -115,9 +115,9 @@ func TestClusterHasNodeSelector(t *testing.T) { } func TestClusterCustomConfig(t *testing.T) { - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ - ConfigRef: &v1.LocalObjectReference{ + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ + ConfigRef: &corev1.LocalObjectReference{ Name: "mycnf", }, }, @@ -142,9 +142,9 @@ func TestClusterCustomConfig(t *testing.T) { } func TestClusterCustomSSLSetup(t *testing.T) { - cluster := &api.MySQLCluster{ - Spec: api.MySQLClusterSpec{ - SSLSecretRef: &v1.LocalObjectReference{ + cluster := &v1alpha1.MySQLCluster{ + Spec: v1alpha1.MySQLClusterSpec{ + SSLSecretRef: &corev1.LocalObjectReference{ Name: "my-ssl", }, }, diff --git a/pkg/util/test/test_backup.go b/pkg/util/test/test_backup.go index 83aff5c40..7ce616d62 100644 --- a/pkg/util/test/test_backup.go +++ b/pkg/util/test/test_backup.go @@ -18,25 +18,25 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) type TestMySQLBackup struct { - *api.MySQLBackup + *v1alpha1.MySQLBackup } func NewTestMySQLBackup() *TestMySQLBackup { return &TestMySQLBackup{ - MySQLBackup: &api.MySQLBackup{ + MySQLBackup: &v1alpha1.MySQLBackup{ ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, }, - Spec: api.BackupSpec{ - Executor: &api.Executor{ + Spec: v1alpha1.BackupSpec{ + Executor: &v1alpha1.Executor{ Provider: "mysqldump", Databases: []string{"test"}, }, - Storage: &api.Storage{ + Storage: &v1alpha1.Storage{ Provider: "s3", SecretRef: &corev1.LocalObjectReference{ Name: "name", diff --git a/pkg/util/test/test_backupschedule.go b/pkg/util/test/test_backupschedule.go index bd2ff9b8f..5cba6774a 100644 --- a/pkg/util/test/test_backupschedule.go +++ b/pkg/util/test/test_backupschedule.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) type TestMySQLBackupSchedule struct { diff --git a/test/e2e/backup_restore.go b/test/e2e/backup_restore.go index 8a7b6e4bf..de911a7f5 100644 --- a/test/e2e/backup_restore.go +++ b/test/e2e/backup_restore.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/test/e2e/framework" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" @@ -72,8 +72,8 @@ var _ = Describe("Backup/Restore", func() { By("Backing up testdb") dbs := []string{framework.TestDBName} - backup := backupJig.CreateAndAwaitMySQLDumpBackupOrFail(ns, clusterName, dbs, func(b *v1.MySQLBackup) { - b.Spec.Storage = &v1.Storage{ + backup := backupJig.CreateAndAwaitMySQLDumpBackupOrFail(ns, clusterName, dbs, func(b *v1alpha1.MySQLBackup) { + b.Spec.Storage = &v1alpha1.Storage{ Provider: "s3", SecretRef: &corev1.LocalObjectReference{ Name: secret.Name, diff --git a/test/e2e/cluster_creation.go b/test/e2e/cluster_creation.go index 15eb78423..0e1b1d0ab 100644 --- a/test/e2e/cluster_creation.go +++ b/test/e2e/cluster_creation.go @@ -20,7 +20,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/test/e2e/framework" ) @@ -49,7 +49,7 @@ var _ = Describe("MySQLCluster creation", func() { jig := framework.NewMySQLClusterTestJig(f.MySQLClientSet, f.ClientSet, clusterName) - cluster := jig.CreateAndAwaitMySQLClusterOrFail(f.Namespace.Name, replicas, func(cluster *v1.MySQLCluster) { + cluster := jig.CreateAndAwaitMySQLClusterOrFail(f.Namespace.Name, replicas, func(cluster *v1alpha1.MySQLCluster) { cluster.Spec.MultiMaster = true }, framework.DefaultTimeout) diff --git a/test/e2e/container_crash.go b/test/e2e/container_crash.go index fbfeba27a..bd7b66b99 100644 --- a/test/e2e/container_crash.go +++ b/test/e2e/container_crash.go @@ -22,7 +22,7 @@ import ( clientset "k8s.io/client-go/kubernetes" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" "github.com/oracle/mysql-operator/test/e2e/framework" ) @@ -88,7 +88,7 @@ var _ = Describe("Container crash", func() { jig := framework.NewMySQLClusterTestJig(mcs, cs, clusterName) - cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1.MySQLCluster) { + cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1alpha1.MySQLCluster) { cluster.Spec.MultiMaster = true }, framework.DefaultTimeout) @@ -168,7 +168,7 @@ var _ = Describe("Container crash", func() { jig := framework.NewMySQLClusterTestJig(mcs, cs, clusterName) - cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1.MySQLCluster) { + cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1alpha1.MySQLCluster) { cluster.Spec.MultiMaster = true }, framework.DefaultTimeout) diff --git a/test/e2e/framework/backup.go b/test/e2e/framework/backup.go index 8d85ddcc4..f82fcf3a8 100644 --- a/test/e2e/framework/backup.go +++ b/test/e2e/framework/backup.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/ginkgo" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" ) @@ -57,21 +57,21 @@ func NewMySQLBackupTestJig(mysqlClient mysqlclientset.Interface, kubeClient clie } } -// newMySQLBackupTemplate returns the default v1.MySQLBackup template for this jig, but -// does not actually create the MySQLBackup. The default MySQLBackup has the same name -// as the jig. -func (j *MySQLBackupTestJig) newMySQLBackupTemplate(namespace, clusterName string) *v1.MySQLBackup { - return &v1.MySQLBackup{ +// newMySQLBackupTemplate returns the default v1alpha1.MySQLBackup template for +// this jig, but does not actually create the MySQLBackup. The default +// MySQLBackup has the same name as the jig. +func (j *MySQLBackupTestJig) newMySQLBackupTemplate(namespace, clusterName string) *v1alpha1.MySQLBackup { + return &v1alpha1.MySQLBackup{ TypeMeta: metav1.TypeMeta{ - Kind: v1.MySQLBackupCRDResourceKind, - APIVersion: v1.SchemeGroupVersion.String(), + Kind: v1alpha1.MySQLBackupCRDResourceKind, + APIVersion: v1alpha1.SchemeGroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ GenerateName: j.Name, Namespace: namespace, Labels: j.Labels, }, - Spec: v1.BackupSpec{ + Spec: v1alpha1.BackupSpec{ ClusterRef: &corev1.LocalObjectReference{ Name: clusterName, }, @@ -82,7 +82,7 @@ func (j *MySQLBackupTestJig) newMySQLBackupTemplate(namespace, clusterName strin // CreateMySQLBackupOrFail creates a new MySQLBackup based on the jig's // defaults. Callers can provide a function to tweak the MySQLBackup object // before it is created. -func (j *MySQLBackupTestJig) CreateMySQLBackupOrFail(namespace, clusterName string, tweak func(backup *v1.MySQLBackup)) *v1.MySQLBackup { +func (j *MySQLBackupTestJig) CreateMySQLBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.MySQLBackup)) *v1alpha1.MySQLBackup { backup := j.newMySQLBackupTemplate(namespace, clusterName) if tweak != nil { tweak(backup) @@ -91,7 +91,7 @@ func (j *MySQLBackupTestJig) CreateMySQLBackupOrFail(namespace, clusterName stri name := types.NamespacedName{Namespace: namespace, Name: j.Name} By(fmt.Sprintf("Creating a MySQLBackup %q", name)) - result, err := j.MySQLClient.MysqlV1().MySQLBackups(namespace).Create(backup) + result, err := j.MySQLClient.MysqlV1alpha1().MySQLBackups(namespace).Create(backup) if err != nil { Failf("Failed to create MySQLBackup %q: %v", name, err) } @@ -101,7 +101,7 @@ func (j *MySQLBackupTestJig) CreateMySQLBackupOrFail(namespace, clusterName stri // CreateAndAwaitMySQLBackupOrFail creates a new MySQLBackup based on the // jig's defaults, waits for it to become ready. Callers can provide a function // to tweak the MySQLBackup object before it is created. -func (j *MySQLBackupTestJig) CreateAndAwaitMySQLBackupOrFail(namespace, clusterName string, tweak func(backup *v1.MySQLBackup), timeout time.Duration) *v1.MySQLBackup { +func (j *MySQLBackupTestJig) CreateAndAwaitMySQLBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.MySQLBackup), timeout time.Duration) *v1alpha1.MySQLBackup { backup := j.CreateMySQLBackupOrFail(namespace, clusterName, tweak) return j.WaitForbackupReadyOrFail(namespace, backup.Name, timeout) } @@ -109,9 +109,9 @@ func (j *MySQLBackupTestJig) CreateAndAwaitMySQLBackupOrFail(namespace, clusterN // CreateAndAwaitMySQLDumpBackupOrFail creates a new MySQLBackup based on the // jig's defaults, waits for it to become ready. Callers can provide a function // to tweak the MySQLBackup object before it is created. -func (j *MySQLBackupTestJig) CreateAndAwaitMySQLDumpBackupOrFail(namespace, clusterName string, databases []string, tweak func(backup *v1.MySQLBackup), timeout time.Duration) *v1.MySQLBackup { - backup := j.CreateMySQLBackupOrFail(namespace, clusterName, func(backup *v1.MySQLBackup) { - backup.Spec.Executor = &v1.Executor{ +func (j *MySQLBackupTestJig) CreateAndAwaitMySQLDumpBackupOrFail(namespace, clusterName string, databases []string, tweak func(backup *v1alpha1.MySQLBackup), timeout time.Duration) *v1alpha1.MySQLBackup { + backup := j.CreateMySQLBackupOrFail(namespace, clusterName, func(backup *v1alpha1.MySQLBackup) { + backup.Spec.Executor = &v1alpha1.Executor{ Provider: "mysqldump", Databases: databases, } @@ -136,10 +136,10 @@ func (j *MySQLBackupTestJig) CreateS3AuthSecret(namespace, name string) (*corev1 }) } -func (j *MySQLBackupTestJig) waitForConditionOrFail(namespace, name string, timeout time.Duration, message string, conditionFn func(*v1.MySQLBackup) bool) *v1.MySQLBackup { - var backup *v1.MySQLBackup +func (j *MySQLBackupTestJig) waitForConditionOrFail(namespace, name string, timeout time.Duration, message string, conditionFn func(*v1alpha1.MySQLBackup) bool) *v1alpha1.MySQLBackup { + var backup *v1alpha1.MySQLBackup pollFunc := func() (bool, error) { - b, err := j.MySQLClient.MysqlV1().MySQLBackups(namespace).Get(name, metav1.GetOptions{}) + b, err := j.MySQLClient.MysqlV1alpha1().MySQLBackups(namespace).Get(name, metav1.GetOptions{}) if err != nil { return false, err } @@ -157,15 +157,15 @@ func (j *MySQLBackupTestJig) waitForConditionOrFail(namespace, name string, time // WaitForbackupReadyOrFail waits up to a given timeout for a backup to be in // the running phase. -func (j *MySQLBackupTestJig) WaitForbackupReadyOrFail(namespace, name string, timeout time.Duration) *v1.MySQLBackup { +func (j *MySQLBackupTestJig) WaitForbackupReadyOrFail(namespace, name string, timeout time.Duration) *v1alpha1.MySQLBackup { Logf("Waiting up to %v for MySQLBackup \"%s/%s\" to be complete executing", timeout, namespace, name) - backup := j.waitForConditionOrFail(namespace, name, timeout, "to complete executing", func(backup *v1.MySQLBackup) bool { + backup := j.waitForConditionOrFail(namespace, name, timeout, "to complete executing", func(backup *v1alpha1.MySQLBackup) bool { phase := backup.Status.Phase - if phase == v1.BackupPhaseComplete { + if phase == v1alpha1.BackupPhaseComplete { return true } - if phase == v1.BackupPhaseFailed { + if phase == v1alpha1.BackupPhaseFailed { ns := backup.Namespace events, err := j.KubeClient.CoreV1().Events(ns).List(metav1.ListOptions{}) if err != nil { @@ -177,7 +177,7 @@ func (j *MySQLBackupTestJig) WaitForbackupReadyOrFail(namespace, name string, ti } Logf(e.String()) } - Failf("MySQLBackup entered state %q", v1.BackupPhaseFailed) + Failf("MySQLBackup entered state %q", v1alpha1.BackupPhaseFailed) } return false }) diff --git a/test/e2e/framework/cluster.go b/test/e2e/framework/cluster.go index 59965db62..ffab2e876 100644 --- a/test/e2e/framework/cluster.go +++ b/test/e2e/framework/cluster.go @@ -30,7 +30,7 @@ import ( . "github.com/onsi/ginkgo" "github.com/pkg/errors" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + v1 "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" "github.com/oracle/mysql-operator/pkg/controllers/cluster/labeler" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" "github.com/oracle/mysql-operator/pkg/resources/secrets" @@ -93,7 +93,7 @@ func (j *MySQLClusterTestJig) CreateMySQLClusterOrFail(namespace string, replica name := types.NamespacedName{Namespace: namespace, Name: j.Name} By(fmt.Sprintf("Creating a MySQLCluster %q with .spec.replicas=%d", name, replicas)) - result, err := j.MySQLClient.MysqlV1().MySQLClusters(namespace).Create(cluster) + result, err := j.MySQLClient.MysqlV1alpha1().MySQLClusters(namespace).Create(cluster) if err != nil { Failf("Failed to create MySQLCluster %q: %v", name, err) } @@ -114,7 +114,7 @@ func (j *MySQLClusterTestJig) CreateAndAwaitMySQLClusterOrFail(namespace string, func (j *MySQLClusterTestJig) waitForConditionOrFail(namespace, name string, timeout time.Duration, message string, conditionFn func(*v1.MySQLCluster) bool) *v1.MySQLCluster { var cluster *v1.MySQLCluster pollFunc := func() (bool, error) { - c, err := j.MySQLClient.MysqlV1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) + c, err := j.MySQLClient.MysqlV1alpha1().MySQLClusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { return false, err } diff --git a/test/e2e/framework/restore.go b/test/e2e/framework/restore.go index 867806c20..b272d7ac2 100644 --- a/test/e2e/framework/restore.go +++ b/test/e2e/framework/restore.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/ginkgo" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" ) @@ -57,17 +57,17 @@ func NewMySQLRestoreTestJig(mysqlClient mysqlclientset.Interface, kubeClient cli } } -// newMySQLRestoreTemplate returns the default v1.MySQLRestore template for this jig, but +// newMySQLRestoreTemplate returns the default v1alpha1.MySQLRestore template for this jig, but // does not actually create the MySQLRestore. The default MySQLRestore has the // same name as the jig. -func (j *MySQLRestoreTestJig) newMySQLRestoreTemplate(namespace, clusterName, backupName string) *v1.MySQLRestore { - return &v1.MySQLRestore{ +func (j *MySQLRestoreTestJig) newMySQLRestoreTemplate(namespace, clusterName, backupName string) *v1alpha1.MySQLRestore { + return &v1alpha1.MySQLRestore{ ObjectMeta: metav1.ObjectMeta{ GenerateName: j.Name, Namespace: namespace, Labels: j.Labels, }, - Spec: v1.RestoreSpec{ + Spec: v1alpha1.RestoreSpec{ ClusterRef: &corev1.LocalObjectReference{ Name: clusterName, }, @@ -81,7 +81,7 @@ func (j *MySQLRestoreTestJig) newMySQLRestoreTemplate(namespace, clusterName, ba // CreateMySQLRestoreOrFail creates a new MySQLRestore based on the jig's // defaults. Callers can provide a function to tweak the MySQLRestore object // before it is created. -func (j *MySQLRestoreTestJig) CreateMySQLRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1.MySQLRestore)) *v1.MySQLRestore { +func (j *MySQLRestoreTestJig) CreateMySQLRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1alpha1.MySQLRestore)) *v1alpha1.MySQLRestore { restore := j.newMySQLRestoreTemplate(namespace, clusterName, backupName) if tweak != nil { tweak(restore) @@ -90,7 +90,7 @@ func (j *MySQLRestoreTestJig) CreateMySQLRestoreOrFail(namespace, clusterName, b name := types.NamespacedName{Namespace: namespace, Name: j.Name} By(fmt.Sprintf("Creating a MySQLRestore %q", name)) - result, err := j.MySQLClient.MysqlV1().MySQLRestores(namespace).Create(restore) + result, err := j.MySQLClient.MysqlV1alpha1().MySQLRestores(namespace).Create(restore) if err != nil { Failf("Failed to create MySQLRestore %q: %v", name, err) } @@ -100,7 +100,7 @@ func (j *MySQLRestoreTestJig) CreateMySQLRestoreOrFail(namespace, clusterName, b // CreateAndAwaitMySQLRestoreOrFail creates a new MySQLRestore based on the // jig's defaults, waits for it to become ready. Callers can provide a function // to tweak the MySQLRestore object before it is created. -func (j *MySQLRestoreTestJig) CreateAndAwaitMySQLRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1.MySQLRestore), timeout time.Duration) *v1.MySQLRestore { +func (j *MySQLRestoreTestJig) CreateAndAwaitMySQLRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1alpha1.MySQLRestore), timeout time.Duration) *v1alpha1.MySQLRestore { restore := j.CreateMySQLRestoreOrFail(namespace, clusterName, backupName, tweak) restore = j.WaitForRestoreCompleteOrFail(namespace, restore.Name, timeout) return restore @@ -121,10 +121,10 @@ func (j *MySQLRestoreTestJig) CreateS3AuthSecret(namespace, name string) (*corev }) } -func (j *MySQLRestoreTestJig) waitForConditionOrFail(namespace, name string, timeout time.Duration, message string, conditionFn func(*v1.MySQLRestore) bool) *v1.MySQLRestore { - var restore *v1.MySQLRestore +func (j *MySQLRestoreTestJig) waitForConditionOrFail(namespace, name string, timeout time.Duration, message string, conditionFn func(*v1alpha1.MySQLRestore) bool) *v1alpha1.MySQLRestore { + var restore *v1alpha1.MySQLRestore pollFunc := func() (bool, error) { - r, err := j.MySQLClient.MysqlV1().MySQLRestores(namespace).Get(name, metav1.GetOptions{}) + r, err := j.MySQLClient.MysqlV1alpha1().MySQLRestores(namespace).Get(name, metav1.GetOptions{}) if err != nil { return false, err } @@ -142,15 +142,15 @@ func (j *MySQLRestoreTestJig) waitForConditionOrFail(namespace, name string, tim // WaitForRestoreCompleteOrFail waits up to a given timeout for a MySQLRestore // to enter the complete phase. -func (j *MySQLRestoreTestJig) WaitForRestoreCompleteOrFail(namespace, name string, timeout time.Duration) *v1.MySQLRestore { +func (j *MySQLRestoreTestJig) WaitForRestoreCompleteOrFail(namespace, name string, timeout time.Duration) *v1alpha1.MySQLRestore { Logf("Waiting up to %v for MySQLRestore \"%s/%s\" to be complete executing", timeout, namespace, name) - restore := j.waitForConditionOrFail(namespace, name, timeout, "to complete executing", func(restore *v1.MySQLRestore) bool { + restore := j.waitForConditionOrFail(namespace, name, timeout, "to complete executing", func(restore *v1alpha1.MySQLRestore) bool { phase := restore.Status.Phase - if phase == v1.RestorePhaseComplete { + if phase == v1alpha1.RestorePhaseComplete { return true } - if phase == v1.RestorePhaseFailed { + if phase == v1alpha1.RestorePhaseFailed { ns := restore.Namespace events, err := j.KubeClient.CoreV1().Events(ns).List(metav1.ListOptions{}) if err != nil { @@ -162,7 +162,7 @@ func (j *MySQLRestoreTestJig) WaitForRestoreCompleteOrFail(namespace, name strin } Logf(e.String()) } - Failf("MySQLRestore entered state %q", v1.RestorePhaseFailed) + Failf("MySQLRestore entered state %q", v1alpha1.RestorePhaseFailed) } return false }) diff --git a/test/e2e/pod_crash.go b/test/e2e/pod_crash.go index b3200a6bf..9f8d0ece1 100644 --- a/test/e2e/pod_crash.go +++ b/test/e2e/pod_crash.go @@ -23,7 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" - "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" mysqlclientset "github.com/oracle/mysql-operator/pkg/generated/clientset/versioned" "github.com/oracle/mysql-operator/test/e2e/framework" ) @@ -86,7 +86,7 @@ var _ = Describe("Pod crash", func() { jig := framework.NewMySQLClusterTestJig(mcs, cs, clusterName) - cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1.MySQLCluster) { + cluster := jig.CreateAndAwaitMySQLClusterOrFail(ns, 3, func(cluster *v1alpha1.MySQLCluster) { cluster.Spec.MultiMaster = true }, framework.DefaultTimeout) diff --git a/test/examples/examples_test.go b/test/examples/examples_test.go index 094db4580..cd6f8a947 100644 --- a/test/examples/examples_test.go +++ b/test/examples/examples_test.go @@ -9,9 +9,9 @@ import ( yaml "github.com/ghodss/yaml" - api "github.com/oracle/mysql-operator/pkg/apis/mysql/v1" - corev1 "k8s.io/api/core/v1" + + "github.com/oracle/mysql-operator/pkg/apis/mysql/v1alpha1" ) func TestRemoveInstanceFromCluster(t *testing.T) { @@ -40,7 +40,7 @@ func validateMySQLCluster(t *testing.T, file string) { t.Errorf("Failed to read file: %s, err: %v", file, err) return } - var r api.MySQLCluster + var r v1alpha1.MySQLCluster err = yaml.Unmarshal(bytes, &r) if err != nil { t.Errorf("Failed to parse file: %s, err: %v", file, err) @@ -60,7 +60,7 @@ func validateMySQLBackup(t *testing.T, file string) { t.Errorf("Failed to read file: %s, err: %v", file, err) return } - var r api.MySQLBackup + var r v1alpha1.MySQLBackup err = yaml.Unmarshal(bytes, &r) if err != nil { t.Errorf("Failed to parse file: %s, err: %v", file, err) @@ -82,7 +82,7 @@ func validateMySQLRestore(t *testing.T, file string) { t.Errorf("Failed to read file: %s, err: %v", file, err) return } - var r api.MySQLRestore + var r v1alpha1.MySQLRestore err = yaml.Unmarshal(bytes, &r) if err != nil { t.Errorf("Failed to parse file: %s, err: %v", file, err) @@ -102,7 +102,7 @@ func validateMySQLBackupSchedule(t *testing.T, file string) { t.Errorf("Failed to read file: %s, err: %v", file, err) return } - var r api.MySQLBackupSchedule + var r v1alpha1.MySQLBackupSchedule err = yaml.Unmarshal(bytes, &r) if err != nil { t.Errorf("Failed to parse file: %s, err: %v", file, err)