Skip to content

Commit

Permalink
Set constants at the correct place
Browse files Browse the repository at this point in the history
These are not types, thus moving them into the main const.go file.
  • Loading branch information
cschwede committed Feb 26, 2024
1 parent 20f94a7 commit a405664
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 30 deletions.
22 changes: 0 additions & 22 deletions api/v1beta1/common_types.go

This file was deleted.

5 changes: 3 additions & 2 deletions controllers/swiftring_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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{}
Expand Down
3 changes: 2 additions & 1 deletion controllers/swiftstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{}) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/swift/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ const (
ServiceDescription = "Swift Object Storage"

ClaimName = "srv"

RingConfigMapName = "swift-ring-files"
DeviceConfigMapName = "swift-storage-devices"
)
3 changes: 2 additions & 1 deletion pkg/swiftproxy/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/swiftring/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion pkg/swiftring/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/swiftstorage/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/swiftstorage/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down

0 comments on commit a405664

Please sign in to comment.