Skip to content

Commit

Permalink
fix: const in resourcetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Gniadek committed Aug 18, 2024
1 parent f45d977 commit 3ef2b4d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/controller/interpolator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const (
typeAvailableInterpolator = "Synced"
typeDegradedInterpolator = "Degraded"
interpolatorFinalizer = "interpolator.interpolator.io/finalizer"
interpolatorConfigMap = "ConfigMap"
interpolatorSecret = "Secret"
resourceTypeSecret = "Secret"
resourceTypeConfigMap = "ConfigMap"
)

func (r *InterpolatorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down Expand Up @@ -147,15 +147,15 @@ func (r *InterpolatorReconciler) Reconcile(ctx context.Context, req ctrl.Request

log.Info("fetching and processing input secrets")
for i, inputsecret := range interpolator.Spec.InputSecrets {
if inputsecret.Kind == interpolatorSecret {
if inputsecret.Kind == resourceTypeSecret {
secrets := &v1.Secret{}
if err := r.Get(ctx, types.NamespacedName{Namespace: inputsecret.Namespace, Name: inputsecret.Name}, secrets); err != nil {
log.Error(err, "failed to get data from secret", "name", inputsecret.Name, "namespace", inputsecret.Namespace)
return ctrl.Result{}, nil
}
secretValues[inputsecret.Key] = string(secrets.Data[inputsecret.Key])
interpolator.Spec.InputSecrets[i].Value = string(secrets.Data[inputsecret.Key])
} else if inputsecret.Kind == interpolatorConfigMap {
} else if inputsecret.Kind == resourceTypeConfigMap {
configmaps := &v1.ConfigMap{}
if err := r.Get(ctx, types.NamespacedName{Namespace: inputsecret.Namespace, Name: inputsecret.Name}, configmaps); err != nil {
log.Error(err, "failed to get data from configmap", "name", inputsecret.Name, "namespace", inputsecret.Namespace)
Expand Down Expand Up @@ -193,17 +193,17 @@ func (r *InterpolatorReconciler) Reconcile(ctx context.Context, req ctrl.Request
outputKey = secret.Key
}
// Convert the final value to []byte and store it in the map
if interpolator.Spec.OutputKind == "Secret" {
if interpolator.Spec.OutputKind == resourceTypeSecret {
FinalSecrets[outputKey] = []byte(templateValue)
} else if interpolator.Spec.OutputKind == "ConfigMap" {
} else if interpolator.Spec.OutputKind == resourceTypeConfigMap {
FinalSecretsString[outputKey] = templateValue
}
}

secret := &v1.Secret{}
configmap := &v1.ConfigMap{}

if interpolator.Spec.OutputKind == "Secret" {
if interpolator.Spec.OutputKind == resourceTypeSecret {
secret, _ = r.secretForInterpolator(interpolator, FinalSecrets)
err = r.Create(ctx, secret)
if apierrors.IsAlreadyExists(err) {
Expand Down Expand Up @@ -239,7 +239,7 @@ func (r *InterpolatorReconciler) Reconcile(ctx context.Context, req ctrl.Request
log.Error(err, "failed to create new secret")
return ctrl.Result{}, nil
}
} else if interpolator.Spec.OutputKind == "ConfigMap" {
} else if interpolator.Spec.OutputKind == resourceTypeConfigMap {
configmap, _ = r.configmapForInterpolator(interpolator, FinalSecretsString)
err = r.Create(ctx, configmap)
if apierrors.IsAlreadyExists(err) {
Expand Down

0 comments on commit 3ef2b4d

Please sign in to comment.