77 "strings"
88
99 console "github.com/pluralsh/console/go/client"
10+ "github.com/pluralsh/deployment-operator/internal/metrics"
11+ consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
1012 "github.com/pluralsh/polly/algorithms"
1113 "github.com/samber/lo"
1214 batchv1 "k8s.io/api/batch/v1"
@@ -15,9 +17,6 @@ import (
1517 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1618 "k8s.io/apimachinery/pkg/types"
1719 "sigs.k8s.io/controller-runtime/pkg/log"
18-
19- "github.com/pluralsh/deployment-operator/internal/metrics"
20- consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
2120)
2221
2322const (
@@ -85,6 +84,10 @@ func (r *StackReconciler) reconcileRunJob(ctx context.Context, run *console.Stac
8584 return nil , err
8685 }
8786
87+ if _ , err = r .upsertRunSecret (ctx ); err != nil {
88+ return nil , err
89+ }
90+
8891 logger .V (2 ).Info ("generating job" , "namespace" , r .namespace , "name" , jobName )
8992 job := r .GenerateRunJob (run , jobName )
9093
@@ -208,6 +211,8 @@ func (r *StackReconciler) ensureDefaultContainer(containers []corev1.Container,
208211
209212 containers [index ].Args = r .getDefaultContainerArgs (run .ID )
210213
214+ containers [index ].EnvFrom = r .getDefaultContainerEnvFrom ()
215+
211216 containers [index ].VolumeMounts = ensureDefaultVolumeMounts (containers [index ].VolumeMounts )
212217 }
213218 return containers
@@ -224,6 +229,7 @@ func (r *StackReconciler) getDefaultContainer(run *console.StackRunFragment) cor
224229 },
225230 SecurityContext : ensureDefaultContainerSecurityContext (nil ),
226231 Env : make ([]corev1.EnvVar , 0 ),
232+ EnvFrom : r .getDefaultContainerEnvFrom (),
227233 }
228234}
229235
@@ -293,14 +299,22 @@ func (r *StackReconciler) getTag(run *console.StackRunFragment) string {
293299 return defaultImageTag
294300}
295301
296- func (r * StackReconciler ) getDefaultContainerArgs (runID string ) []string {
297- return []string {
298- fmt .Sprintf ("--console-url=%s" , r .consoleURL ),
299- fmt .Sprintf ("--console-token=%s" , r .deployToken ),
300- fmt .Sprintf ("--stack-run-id=%s" , runID ),
302+ func (r * StackReconciler ) getDefaultContainerEnvFrom () []corev1.EnvFromSource {
303+ return []corev1.EnvFromSource {
304+ {
305+ SecretRef : & corev1.SecretEnvSource {
306+ LocalObjectReference : corev1.LocalObjectReference {
307+ Name : jobRunSecretName ,
308+ },
309+ },
310+ },
301311 }
302312}
303313
314+ func (r * StackReconciler ) getDefaultContainerArgs (runID string ) []string {
315+ return []string {fmt .Sprintf ("--stack-run-id=%s" , runID )}
316+ }
317+
304318func ensureDefaultVolumeMounts (mounts []corev1.VolumeMount ) []corev1.VolumeMount {
305319 return append (
306320 algorithms .Filter (mounts , func (v corev1.VolumeMount ) bool {
0 commit comments