From 06ac54c6f28065ffeeb99c7ab05166827e327700 Mon Sep 17 00:00:00 2001 From: Ilya Bumarskov Date: Tue, 12 Apr 2022 15:57:41 +0400 Subject: [PATCH] Align zookeeperbackup with operator-sdk 1.13 --- api/group.go | 16 ---- api/v1beta1/zz_generated.deepcopy.go | 4 - ...zookeeper.pravega.io_zookeeperbackups.yaml | 89 +++++++++++++++++++ ...eeper.pravega.io_zookeeperbackups_crd.yaml | 78 ---------------- config/crd/kustomization.yaml | 3 + config/rbac/role.yaml | 1 + ...zookeeper_v1beta1_zookeeperbackup_cr.yaml} | 0 deploy/role.yaml | 40 --------- go.mod | 1 + go.sum | 2 + pkg/apis/zookeeper/group.go | 16 ---- .../zookeeperbackup_controller.go | 2 +- 12 files changed, 97 insertions(+), 155 deletions(-) delete mode 100644 api/group.go create mode 100644 config/crd/bases/zookeeper.pravega.io_zookeeperbackups.yaml delete mode 100644 config/crd/bases/zookeeper.pravega.io_zookeeperbackups_crd.yaml rename config/{crd/bases/zookeeper.pravega.io_v1beta1_zookeeperbackup_cr.yaml => samples/pravega/zookeeper_v1beta1_zookeeperbackup_cr.yaml} (100%) delete mode 100644 deploy/role.yaml delete mode 100644 pkg/apis/zookeeper/group.go diff --git a/api/group.go b/api/group.go deleted file mode 100644 index a5983b58a..000000000 --- a/api/group.go +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2018 Dell Inc., or its subsidiaries. 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 - */ - -// Package zookeeper contains zookeeper API versions. -// -// This file ensures Go source parsers acknowledge the zookeeper package -// and any child packages. It can be removed if any other Go source files are -// added to this package. -package zookeeper diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 83b77e6c6..643bd79a0 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -298,7 +298,6 @@ func (in *ZookeeperBackup) DeepCopyInto(out *ZookeeperBackup) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec out.Status = in.Status - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZookeeperBackup. @@ -331,7 +330,6 @@ func (in *ZookeeperBackupList) DeepCopyInto(out *ZookeeperBackupList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZookeeperBackupList. @@ -356,7 +354,6 @@ func (in *ZookeeperBackupList) DeepCopyObject() runtime.Object { func (in *ZookeeperBackupSpec) DeepCopyInto(out *ZookeeperBackupSpec) { *out = *in out.Image = in.Image - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZookeeperBackupSpec. @@ -372,7 +369,6 @@ func (in *ZookeeperBackupSpec) DeepCopy() *ZookeeperBackupSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ZookeeperBackupStatus) DeepCopyInto(out *ZookeeperBackupStatus) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZookeeperBackupStatus. diff --git a/config/crd/bases/zookeeper.pravega.io_zookeeperbackups.yaml b/config/crd/bases/zookeeper.pravega.io_zookeeperbackups.yaml new file mode 100644 index 000000000..2ae91b82c --- /dev/null +++ b/config/crd/bases/zookeeper.pravega.io_zookeeperbackups.yaml @@ -0,0 +1,89 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.6.2 + creationTimestamp: null + name: zookeeperbackups.zookeeper.pravega.io +spec: + group: zookeeper.pravega.io + names: + kind: ZookeeperBackup + listKind: ZookeeperBackupList + plural: zookeeperbackups + singular: zookeeperbackup + scope: Namespaced + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: ZookeeperBackup is the Schema for the zookeeperbackups API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ZookeeperBackupSpec defines the desired state of ZookeeperBackup + properties: + backupsToKeep: + default: "7" + description: Number of backups to store + type: string + dataCapacity: + default: 1Gi + description: Data Storage Capacity + type: string + dataStorageClass: + description: Data Storage Class name + type: string + image: + description: Image for backup procedure + properties: + pullPolicy: + description: PullPolicy describes a policy for if/when to pull + a container image + enum: + - Always + - Never + - IfNotPresent + type: string + repository: + type: string + tag: + type: string + type: object + schedule: + default: 0 0 */1 * * + description: Schedule in Cron format + type: string + zookeeperCluster: + description: Name of the ZookeeperCluster to backup + type: string + required: + - zookeeperCluster + type: object + status: + description: ZookeeperBackupStatus defines the observed state of ZookeeperBackup + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/bases/zookeeper.pravega.io_zookeeperbackups_crd.yaml b/config/crd/bases/zookeeper.pravega.io_zookeeperbackups_crd.yaml deleted file mode 100644 index ba3761650..000000000 --- a/config/crd/bases/zookeeper.pravega.io_zookeeperbackups_crd.yaml +++ /dev/null @@ -1,78 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: zookeeperbackups.zookeeper.pravega.io -spec: - group: zookeeper.pravega.io - names: - kind: ZookeeperBackup - listKind: ZookeeperBackupList - plural: zookeeperbackups - singular: zookeeperbackup - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: ZookeeperBackup is the Schema for the zookeeperbackups API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ZookeeperBackupSpec defines the desired state of ZookeeperBackup - properties: - backupsToKeep: - default: "7" - description: Number of backups to store - type: string - dataCapacity: - default: 1Gi - description: Data Storage Capacity - type: string - dataStorageClass: - description: Data Storage Class name - type: string - image: - description: Image for backup procedure - properties: - pullPolicy: - description: PullPolicy describes a policy for if/when to pull - a container image - enum: - - Always - - Never - - IfNotPresent - type: string - repository: - type: string - tag: - type: string - type: object - schedule: - default: 0 0 */1 * * - description: Schedule in Cron format - type: string - zookeeperCluster: - description: Name of the ZookeeperCluster to backup - type: string - required: - - zookeeperCluster - type: object - status: - description: ZookeeperBackupStatus defines the observed state of ZookeeperBackup - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 2d4e4fd53..6111dd49f 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -3,16 +3,19 @@ # It should be run by config/default resources: - bases/zookeeper.pravega.io_zookeeperclusters.yaml +- bases/zookeeper.pravega.io.zookeeper.pravega.io_zookeeperbackups.yaml # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_zookeeperclusters.yaml +#- patches/webhook_in_zookeeperbackups.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_zookeeperclusters.yaml +#- patches/cainjection_in_zookeeperbackups.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 1e291690d..8dbeb06da 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -10,6 +10,7 @@ rules: - zookeeper.pravega.io.zookeeper.pravega.io resources: - zookeeperclusters + - zookeeperbackups verbs: - create - delete diff --git a/config/crd/bases/zookeeper.pravega.io_v1beta1_zookeeperbackup_cr.yaml b/config/samples/pravega/zookeeper_v1beta1_zookeeperbackup_cr.yaml similarity index 100% rename from config/crd/bases/zookeeper.pravega.io_v1beta1_zookeeperbackup_cr.yaml rename to config/samples/pravega/zookeeper_v1beta1_zookeeperbackup_cr.yaml diff --git a/deploy/role.yaml b/deploy/role.yaml deleted file mode 100644 index 56a10fd34..000000000 --- a/deploy/role.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - creationTimestamp: null - name: zookeeper-operator.fullname -rules: - - apiGroups: - - zookeeper.pravega.io - resources: - - '*' - - zookeeperbackups - verbs: - - '*' - - apiGroups: - - "" - resources: - - pods - - services - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - policy - resources: - - poddisruptionbudgets - verbs: - - '*' \ No newline at end of file diff --git a/go.mod b/go.mod index ffc58b365..c13ce1b2f 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.17 require ( github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/go-logr/logr v0.4.0 + github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/onsi/ginkgo v1.16.4 github.com/onsi/gomega v1.15.0 github.com/operator-framework/operator-lib v0.7.0 diff --git a/go.sum b/go.sum index 4093e0866..3387c48b1 100644 --- a/go.sum +++ b/go.sum @@ -339,6 +339,8 @@ github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= diff --git a/pkg/apis/zookeeper/group.go b/pkg/apis/zookeeper/group.go deleted file mode 100644 index a5983b58a..000000000 --- a/pkg/apis/zookeeper/group.go +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2018 Dell Inc., or its subsidiaries. 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 - */ - -// Package zookeeper contains zookeeper API versions. -// -// This file ensures Go source parsers acknowledge the zookeeper package -// and any child packages. It can be removed if any other Go source files are -// added to this package. -package zookeeper diff --git a/pkg/controller/zookeeperbackup/zookeeperbackup_controller.go b/pkg/controller/zookeeperbackup/zookeeperbackup_controller.go index cb3646cb1..353339dc6 100644 --- a/pkg/controller/zookeeperbackup/zookeeperbackup_controller.go +++ b/pkg/controller/zookeeperbackup/zookeeperbackup_controller.go @@ -22,7 +22,7 @@ import ( "strings" "time" - zookeeperv1beta1 "github.com/pravega/zookeeper-operator/pkg/apis/zookeeper/v1beta1" + zookeeperv1beta1 "github.com/pravega/zookeeper-operator/api/v1beta1" batchv1 "k8s.io/api/batch/v1" batchv1beta1 "k8s.io/api/batch/v1beta1" corev1 "k8s.io/api/core/v1"