diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go deleted file mode 100644 index 0cc47ec0..00000000 --- a/api/v1beta1/common_types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023. - -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 v1beta1 - -const ( - RingConfigMapName = "swift-ring-files" - DeviceConfigMapName = "swift-storage-devices" -) diff --git a/controllers/swiftring_controller.go b/controllers/swiftring_controller.go index 248f7d04..5aa49baf 100644 --- a/controllers/swiftring_controller.go +++ b/controllers/swiftring_controller.go @@ -35,6 +35,7 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/job" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" + "github.com/openstack-k8s-operators/swift-operator/pkg/swift" "github.com/openstack-k8s-operators/swift-operator/pkg/swiftring" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -133,7 +134,7 @@ func (r *SwiftRingReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // Check if the device list ConfigMap did change and if so, delete the // rebalance Job. This will result in a new Job that rebalances with // the updated device list - _, deviceListHash, err := configmap.GetConfigMapAndHashWithName(ctx, helper, swiftv1beta1.DeviceConfigMapName, instance.Namespace) + _, deviceListHash, err := configmap.GetConfigMapAndHashWithName(ctx, helper, swift.DeviceConfigMapName, instance.Namespace) if err != nil { return ctrl.Result{}, err } @@ -196,7 +197,7 @@ func (r *SwiftRingReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( func (r *SwiftRingReconciler) SetupWithManager(mgr ctrl.Manager) error { deviceConfigMapFilter := func(ctx context.Context, o client.Object) []reconcile.Request { result := []reconcile.Request{} - if o.GetName() == swiftv1beta1.DeviceConfigMapName { + if o.GetName() == swift.DeviceConfigMapName { // There should be only one SwiftRing instance within // the Namespace - that needs to be reconciled swiftRings := &swiftv1beta1.SwiftRingList{} diff --git a/controllers/swiftstorage_controller.go b/controllers/swiftstorage_controller.go index 5b48dd04..b4304052 100644 --- a/controllers/swiftstorage_controller.go +++ b/controllers/swiftstorage_controller.go @@ -41,6 +41,7 @@ import ( "k8s.io/client-go/kubernetes" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" + "github.com/openstack-k8s-operators/swift-operator/pkg/swift" "github.com/openstack-k8s-operators/swift-operator/pkg/swiftstorage" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" @@ -144,7 +145,7 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request // not, create an initial device list to bootstrap the cluster with The // weights are simply set to the requested size, this will be changed // once all StatefulSets are running - _, ctrlResult, err := configmap.GetConfigMap(ctx, helper, instance, swiftv1beta1.DeviceConfigMapName, 5*time.Second) + _, ctrlResult, err := configmap.GetConfigMap(ctx, helper, instance, swift.DeviceConfigMapName, 5*time.Second) if err != nil { return ctrlResult, err } else if (ctrlResult != ctrl.Result{}) { diff --git a/pkg/swift/const.go b/pkg/swift/const.go index 994a8e78..242e8009 100644 --- a/pkg/swift/const.go +++ b/pkg/swift/const.go @@ -31,4 +31,7 @@ const ( ServiceDescription = "Swift Object Storage" ClaimName = "srv" + + RingConfigMapName = "swift-ring-files" + DeviceConfigMapName = "swift-storage-devices" ) diff --git a/pkg/swiftproxy/volumes.go b/pkg/swiftproxy/volumes.go index 245ea49b..bc19b9e4 100644 --- a/pkg/swiftproxy/volumes.go +++ b/pkg/swiftproxy/volumes.go @@ -18,6 +18,7 @@ package swiftproxy import ( swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" + "github.com/openstack-k8s-operators/swift-operator/pkg/swift" corev1 "k8s.io/api/core/v1" ) @@ -45,7 +46,7 @@ func getProxyVolumes(instance *swiftv1beta1.SwiftProxy) []corev1.Volume { VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: swiftv1beta1.RingConfigMapName, + Name: swift.RingConfigMapName, }, }, }, diff --git a/pkg/swiftring/job.go b/pkg/swiftring/job.go index 21ed8c46..c700b46f 100644 --- a/pkg/swiftring/job.go +++ b/pkg/swiftring/job.go @@ -32,7 +32,7 @@ func GetRingJob(instance *swiftv1beta1.SwiftRing, labels map[string]string) *bat securityContext := swift.GetSecurityContext() envVars := map[string]env.Setter{} - envVars["CM_NAME"] = env.SetValue(swiftv1beta1.RingConfigMapName) + envVars["CM_NAME"] = env.SetValue(swift.RingConfigMapName) envVars["NAMESPACE"] = env.SetValue(instance.Namespace) envVars["SWIFT_PART_POWER"] = env.SetValue(fmt.Sprint(*instance.Spec.PartPower)) envVars["SWIFT_REPLICAS"] = env.SetValue(fmt.Sprint(*instance.Spec.RingReplicas)) diff --git a/pkg/swiftring/volumes.go b/pkg/swiftring/volumes.go index ea748904..7341cc9f 100644 --- a/pkg/swiftring/volumes.go +++ b/pkg/swiftring/volumes.go @@ -18,6 +18,7 @@ package swiftring import ( swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" + "github.com/openstack-k8s-operators/swift-operator/pkg/swift" corev1 "k8s.io/api/core/v1" ) @@ -54,7 +55,7 @@ func getRingVolumes(instance *swiftv1beta1.SwiftRing) []corev1.Volume { VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: swiftv1beta1.DeviceConfigMapName, + Name: swift.DeviceConfigMapName, }, }, }, diff --git a/pkg/swiftstorage/templates.go b/pkg/swiftstorage/templates.go index d30c4f3f..c01e9bc2 100644 --- a/pkg/swiftstorage/templates.go +++ b/pkg/swiftstorage/templates.go @@ -20,6 +20,7 @@ import ( "fmt" "github.com/openstack-k8s-operators/lib-common/modules/common/util" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" + "github.com/openstack-k8s-operators/swift-operator/pkg/swift" ) func ConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, labels map[string]string, memcachedServers string) []util.Template { @@ -58,7 +59,7 @@ func DeviceConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, devices strin return []util.Template{ { - Name: swiftv1beta1.DeviceConfigMapName, + Name: swift.DeviceConfigMapName, Namespace: instance.Namespace, Type: util.TemplateTypeNone, InstanceType: instance.Kind, diff --git a/pkg/swiftstorage/volumes.go b/pkg/swiftstorage/volumes.go index 9cc3e662..8835753d 100644 --- a/pkg/swiftstorage/volumes.go +++ b/pkg/swiftstorage/volumes.go @@ -57,7 +57,7 @@ func getStorageVolumes(instance *swiftv1beta1.SwiftStorage) []corev1.Volume { VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: swiftv1beta1.RingConfigMapName, + Name: swift.RingConfigMapName, }, }, },