Skip to content

Commit

Permalink
bundle: set ROLEARN env variable in noobaa subscription
Browse files Browse the repository at this point in the history
If ROLEARN env variable is set, then pass on that env variable
to noobaa subscription.

Signed-off-by: Nikhil-Ladha <[email protected]>
  • Loading branch information
Nikhil-Ladha committed Dec 6, 2023
1 parent 47e5643 commit 6b26a12
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions controllers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"os"

"go.uber.org/multierr"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -63,6 +64,30 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator
actualSub.Spec.Config = desiredSubscription.Spec.Config
}

// Always add ROLEARN env variable to noobaa config, if env is set in odf-operator
if actualSub.Spec.Package == NoobaaSubscriptionPackage {
roleARN := os.Getenv("ROLEARN")
if roleARN != "" {
if actualSub.Spec.Config.Env == nil {
actualSub.Spec.Config.Env = make([]corev1.EnvVar, 0)
} else {
roleAdded := false
for _, env := range actualSub.Spec.Config.Env {
if env.Name == "ROLEARN" {
env.Value = roleARN
roleAdded = true
}
}
if !roleAdded {
actualSub.Spec.Config.Env = append(actualSub.Spec.Config.Env, corev1.EnvVar{
Name: "ROLEARN",
Value: roleARN,
})
}
}
}
}

desiredSubscription = actualSub
}
}
Expand Down Expand Up @@ -243,6 +268,18 @@ func GetStorageClusterSubscriptions() []*operatorv1alpha1.Subscription {
},
}

roleARN := os.Getenv("ROLEARN")
if roleARN != "" {
noobaaSubscription.Spec.Config = &operatorv1alpha1.SubscriptionConfig{
Env: []corev1.EnvVar{
{
Name: "ROLEARN",
Value: roleARN,
},
},
}
}

ocsSubscription := &operatorv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: OcsSubscriptionName,
Expand Down

0 comments on commit 6b26a12

Please sign in to comment.