Skip to content

Commit

Permalink
Rename configmap for sail
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Jan 3, 2024
1 parent f3a0b66 commit c1ab8d1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"encoding/json"
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/env"
Expand Down Expand Up @@ -320,11 +321,12 @@ func (r *KuadrantReconciler) registerExternalAuthorizerOSSM(ctx context.Context,

func (r *KuadrantReconciler) getIstioConfigObjects(ctx context.Context, logger logr.Logger) ([]common.ConfigWrapper, error) {
var configsToUpdate []common.ConfigWrapper

configMapName := ""
iop := &iopv1alpha1.IstioOperator{}
istKey := client.ObjectKey{Name: controlPlaneProviderName(), Namespace: controlPlaneProviderNamespace()}
err := r.GetResource(ctx, istKey, iop)
if err == nil || apierrors.IsNotFound(err) {
configMapName = controlPlaneConfigMapName(false)
configsToUpdate = append(configsToUpdate, istio.NewOperatorWrapper(iop))
} else if !apimeta.IsNoMatchError(err) {
logger.V(1).Info("failed to get istiooperator object", "key", istKey, "err", err)
Expand All @@ -342,11 +344,12 @@ func (r *KuadrantReconciler) getIstioConfigObjects(ctx context.Context, logger l
return nil, err
}
}
configMapName = controlPlaneConfigMapName(true)
configsToUpdate = append(configsToUpdate, istio.NewSailWrapper(ist))
}

istioConfigMap := &corev1.ConfigMap{}
if err := r.GetResource(ctx, client.ObjectKey{Name: controlPlaneConfigMapName(), Namespace: controlPlaneProviderNamespace()}, istioConfigMap); err != nil {
if err := r.GetResource(ctx, client.ObjectKey{Name: configMapName, Namespace: controlPlaneProviderNamespace()}, istioConfigMap); err != nil {
logger.V(1).Info("failed to get istio configMap", "key", istKey, "err", err)
return configsToUpdate, err
}
Expand Down Expand Up @@ -380,7 +383,10 @@ func controlPlaneProviderName() string {
return env.GetString("ISTIOOPERATOR_NAME", "istiocontrolplane")
}

func controlPlaneConfigMapName() string {
func controlPlaneConfigMapName(isSail bool) string {
if isSail {
return env.GetString("ISTIOCONFIGMAP_NAME", fmt.Sprintf("istio-%s", controlPlaneProviderName()))
}
return env.GetString("ISTIOCONFIGMAP_NAME", "istio")
}

Expand Down

0 comments on commit c1ab8d1

Please sign in to comment.