@@ -77,6 +77,12 @@ type ReconcileTerraform struct {
77
77
// Value of this field will come from the owning deployment and cached.
78
78
InheritTolerations bool
79
79
TolerationsCacheKey string
80
+
81
+ // When requireApproval is true, the require-approval plugin is injected into the plan pod
82
+ // when generating the pod manifest. The require-approval image is not modifiable via the Terraform
83
+ // Resource in order to ensure the highest compatibility with the other TFO projects (like
84
+ // terraform-operator-api and terraform-operator-dashboard).
85
+ RequireApprovalImage string
80
86
}
81
87
82
88
// createEnvFromSources adds any of the global environment vars defined at the controller scope
@@ -318,9 +324,10 @@ type TaskOptions struct {
318
324
// as the download location for the script to execute in the task.
319
325
urlSource string
320
326
321
- versionedName string
322
- requireApproval bool
323
- restartPolicy corev1.RestartPolicy
327
+ versionedName string
328
+ requireApproval bool
329
+ requireApprovalImage string
330
+ restartPolicy corev1.RestartPolicy
324
331
325
332
volumes []corev1.Volume
326
333
volumeMounts []corev1.VolumeMount
@@ -329,7 +336,7 @@ type TaskOptions struct {
329
336
sidecarPlugins []corev1.Pod
330
337
}
331
338
332
- func newTaskOptions (tf * tfv1beta1.Terraform , task tfv1beta1.TaskName , generation int64 , globalEnvFrom []corev1.EnvFromSource , affinity * corev1.Affinity , nodeSelector map [string ]string , tolerations []corev1.Toleration ) TaskOptions {
339
+ func newTaskOptions (tf * tfv1beta1.Terraform , task tfv1beta1.TaskName , generation int64 , globalEnvFrom []corev1.EnvFromSource , affinity * corev1.Affinity , nodeSelector map [string ]string , tolerations []corev1.Toleration , requireApprovalImage string ) TaskOptions {
333
340
// TODO Read the tfstate and decide IF_NEW_RESOURCE based on that
334
341
// applyAction := false
335
342
resourceName := tf .Name
@@ -541,6 +548,7 @@ func newTaskOptions(tf *tfv1beta1.Terraform, task tfv1beta1.TaskName, generation
541
548
outputsToOmit : outputsToOmit ,
542
549
urlSource : urlSource ,
543
550
requireApproval : requireApproval ,
551
+ requireApprovalImage : requireApprovalImage ,
544
552
restartPolicy : restartPolicy ,
545
553
volumes : volumes ,
546
554
volumeMounts : volumeMounts ,
@@ -725,7 +733,7 @@ func (r *ReconcileTerraform) Reconcile(ctx context.Context, request reconcile.Re
725
733
podType := currentStage .TaskType
726
734
generation := currentStage .Generation
727
735
affinity , nodeSelector , tolerations := r .getNodeSelectorsFromCache ()
728
- runOpts := newTaskOptions (tf , currentStage .TaskType , generation , globalEnvFrom , affinity , nodeSelector , tolerations )
736
+ runOpts := newTaskOptions (tf , currentStage .TaskType , generation , globalEnvFrom , affinity , nodeSelector , tolerations , r . RequireApprovalImage )
729
737
730
738
if podType == tfv1beta1 .RunNil {
731
739
// podType is blank when the terraform workflow has completed for
@@ -864,7 +872,7 @@ func (r *ReconcileTerraform) Reconcile(ctx context.Context, request reconcile.Re
864
872
if (podType == tfv1beta1 .RunPlan || podType == tfv1beta1 .RunPlanDelete ) && runOpts .requireApproval {
865
873
requireApprovalSidecarPlugin := tfv1beta1.Plugin {
866
874
ImageConfig : tfv1beta1.ImageConfig {
867
- Image : "ghcr.io/galleybytes/require-approval:0.1.1" ,
875
+ Image : runOpts . requireApprovalImage ,
868
876
ImagePullPolicy : corev1 .PullIfNotPresent ,
869
877
},
870
878
Must : true ,
@@ -1518,7 +1526,7 @@ func (r ReconcileTerraform) getNodeSelectorsFromCache() (*corev1.Affinity, map[s
1518
1526
// Define a set of TaskOptions specific for the plugin task
1519
1527
func (r ReconcileTerraform ) getPluginRunOpts (tf * tfv1beta1.Terraform , pluginTaskName tfv1beta1.TaskName , pluginConfig tfv1beta1.Plugin , globalEnvFrom []corev1.EnvFromSource ) TaskOptions {
1520
1528
affinity , nodeSelector , tolerations := r .getNodeSelectorsFromCache ()
1521
- pluginRunOpts := newTaskOptions (tf , pluginTaskName , tf .Generation , globalEnvFrom , affinity , nodeSelector , tolerations )
1529
+ pluginRunOpts := newTaskOptions (tf , pluginTaskName , tf .Generation , globalEnvFrom , affinity , nodeSelector , tolerations , r . RequireApprovalImage )
1522
1530
pluginRunOpts .image = pluginConfig .Image
1523
1531
pluginRunOpts .imagePullPolicy = pluginConfig .ImagePullPolicy
1524
1532
return pluginRunOpts
0 commit comments