Skip to content

Commit 6eb6ed4

Browse files
Update ScalityUI and ScalityUIComponentExposer to standardize ConfigMap naming
1 parent d53517a commit 6eb6ed4

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

config/crd/bases/ui.scality.com_scalityuis.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ spec:
4949
type: string
5050
image:
5151
description: |-
52-
Image specifies the container image to be used for the Scality UI.
53-
This should be a valid container image reference, including the tag.
52+
INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
53+
Important: Run "make" to regenerate code after modifying this file
5454
type: string
5555
logo:
5656
type: string

internal/controller/scalityui_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ func (r *ScalityUIReconciler) createOrUpdateDeployment(ctx context.Context, depl
122122

123123
mountPath := "/usr/share/nginx/html/shell"
124124
configVolumeName := scalityui.Name + "-config-volume"
125-
deployedAppsVolumeName := scalityui.Name + "-deployed-apps-volume"
126-
configMapDeployedAppsName := scalityui.Name + "-deployed-apps"
125+
deployedAppsVolumeName := scalityui.Name + "-deployed-ui-apps-volume"
126+
configMapDeployedAppsName := scalityui.Name + "-deployed-ui-apps"
127127

128128
zero := intstr.FromInt(0)
129129
one := intstr.FromInt(1)
@@ -264,7 +264,7 @@ func (r *ScalityUIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
264264
// ConfigMap for config.json is ensured to exist by createOrUpdateOwnedConfigMap
265265

266266
// Define ConfigMap for deployed-ui-apps.json
267-
configMapDeployedAppsName := scalityui.Name + "-deployed-apps"
267+
configMapDeployedAppsName := scalityui.Name + "-deployed-ui-apps"
268268
configMapDeployedApps := &corev1.ConfigMap{
269269
ObjectMeta: metav1.ObjectMeta{
270270
Name: configMapDeployedAppsName,

internal/controller/scalityui_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var _ = Describe("ScalityUI Controller", func() {
4343
productName = "Test Product"
4444
imageName = "nginx:latest"
4545
baseMountPath = "/usr/share/nginx/html/shell" // Updated to match controller
46-
configMapDeployedAppsExt = "-deployed-apps"
46+
configMapDeployedAppsExt = "-deployed-ui-apps"
4747
)
4848

4949
ctx := context.Background()
@@ -150,7 +150,7 @@ var _ = Describe("ScalityUI Controller", func() {
150150
Expect(themesData["light"]).To(HaveKeyWithValue("name", "artescaLight"))
151151
Expect(themesData["dark"]).To(HaveKeyWithValue("name", "darkRebrand"))
152152

153-
// Verify deployed-apps ConfigMap
153+
// Verify deployed-ui-apps ConfigMap
154154
deployedAppsCm := &corev1.ConfigMap{}
155155
Eventually(func() error {
156156
return k8sClient.Get(ctx, types.NamespacedName{Name: resourceName + configMapDeployedAppsExt, Namespace: resourceNamespace}, deployedAppsCm)
@@ -175,7 +175,7 @@ var _ = Describe("ScalityUI Controller", func() {
175175
SubPath: "config.json",
176176
},
177177
corev1.VolumeMount{
178-
Name: resourceName + "-deployed-apps-volume",
178+
Name: resourceName + "-deployed-ui-apps-volume",
179179
MountPath: filepath.Join(baseMountPath, "deployed-ui-apps.json"),
180180
SubPath: "deployed-ui-apps.json",
181181
},
@@ -196,7 +196,7 @@ var _ = Describe("ScalityUI Controller", func() {
196196
},
197197
},
198198
corev1.Volume{
199-
Name: resourceName + "-deployed-apps-volume",
199+
Name: resourceName + "-deployed-ui-apps-volume",
200200
VolumeSource: corev1.VolumeSource{
201201
ConfigMap: &corev1.ConfigMapVolumeSource{
202202
LocalObjectReference: corev1.LocalObjectReference{Name: resourceName + configMapDeployedAppsExt},

internal/controller/scalityuicomponentexposer_controller.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -496,21 +496,10 @@ func (r *ScalityUIComponentExposerReconciler) reconcileScalityUIDeployedApps(ctx
496496
Namespace: ui.Namespace,
497497
}, configMap)
498498

499-
if err != nil && !errors.IsNotFound(err) {
499+
if err != nil {
500500
return fmt.Errorf("failed to get deployed-ui-apps ConfigMap: %w", err)
501501
}
502502

503-
// Initialize empty ConfigMap if not found
504-
if errors.IsNotFound(err) {
505-
configMap = &corev1.ConfigMap{
506-
ObjectMeta: metav1.ObjectMeta{
507-
Name: configMapName,
508-
Namespace: ui.Namespace,
509-
},
510-
Data: make(map[string]string),
511-
}
512-
}
513-
514503
logger.Info("Reconciling deployed-ui-apps ConfigMap",
515504
"namespace", configMap.Namespace,
516505
"name", configMap.Name)
@@ -589,7 +578,7 @@ func (r *ScalityUIComponentExposerReconciler) reconcileScalityUIDeployedApps(ctx
589578

590579
// TODO: This is a temporary function to determine the URL for the component.
591580
func determineComponentURL(component *uiv1alpha1.ScalityUIComponent) string {
592-
ingressPath := fmt.Sprintf("http://localhost:7780%s", component.Status.PublicPath)
581+
ingressPath := component.Status.PublicPath
593582

594583
return ingressPath
595584
}

internal/controller/scalityuicomponentexposer_controller_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
117117
Expect(k8sClient.Create(ctx, deployment)).To(Succeed())
118118
}
119119

120+
deployedAppsConfigMap := &corev1.ConfigMap{
121+
ObjectMeta: metav1.ObjectMeta{
122+
Name: uiName + "-deployed-ui-apps",
123+
Namespace: testNamespace,
124+
},
125+
Data: map[string]string{
126+
"deployed-ui-apps.json": "[]",
127+
},
128+
}
129+
err = k8sClient.Get(ctx, types.NamespacedName{Name: uiName + "-deployed-ui-apps", Namespace: testNamespace}, &corev1.ConfigMap{})
130+
if err != nil && errors.IsNotFound(err) {
131+
Expect(k8sClient.Create(ctx, deployedAppsConfigMap)).To(Succeed())
132+
}
133+
120134
// Finally create the ScalityUIComponentExposer
121135
err = k8sClient.Get(ctx, typeNamespacedName, scalityuicomponentexposer)
122136
if err != nil && errors.IsNotFound(err) {
@@ -176,6 +190,13 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
176190
if err == nil {
177191
Expect(k8sClient.Delete(ctx, ui)).To(Succeed())
178192
}
193+
194+
// Cleanup deployed-ui-apps ConfigMap
195+
deployedAppsConfigMap := &corev1.ConfigMap{}
196+
err = k8sClient.Get(ctx, types.NamespacedName{Name: uiName + "-deployed-ui-apps", Namespace: testNamespace}, deployedAppsConfigMap)
197+
if err == nil {
198+
Expect(k8sClient.Delete(ctx, deployedAppsConfigMap)).To(Succeed())
199+
}
179200
})
180201

181202
It("should successfully reconcile the resource", func() {

0 commit comments

Comments
 (0)