diff --git a/db/Task.go b/db/Task.go index dbf186aa..6cc2b8d0 100644 --- a/db/Task.go +++ b/db/Task.go @@ -15,6 +15,7 @@ type DefaultTaskParams struct { type TerraformTaskParams struct { Plan bool `json:"plan"` + Destroy bool `json:"destroy"` AutoApprove bool `json:"auto_approve"` } diff --git a/db/Template.go b/db/Template.go index d04f8e6c..7fb90963 100644 --- a/db/Template.go +++ b/db/Template.go @@ -36,6 +36,11 @@ const ( SurveyVarEnum TemplateType = "enum" ) +type TerraformTemplateParams struct { + AllowDestroy bool `json:"allow_destroy"` + AllowAutoApprove bool `json:"allow_auto_approve"` +} + type SurveyVarEnumValue struct { Name string `json:"name" backup:"name"` Value string `json:"value" backup:"value"` diff --git a/services/tasks/LocalJob.go b/services/tasks/LocalJob.go index 61cd13b2..c0d46e62 100644 --- a/services/tasks/LocalJob.go +++ b/services/tasks/LocalJob.go @@ -238,11 +238,25 @@ func (t *LocalJob) getTerraformArgs(username string, incomingVersion *string) (a return } + var params db.TerraformTaskParams + err = t.Task.GetParams(¶ms) + if err != nil { + return + } + + if params.Destroy { + args = append(args, "-destroy") + } + for name, value := range extraVars { - if name == "semaphore_vars" { - continue + + var v []byte + v, err = json.Marshal(value) + if err != nil { + return } - args = append(args, "-var", fmt.Sprintf("%s=%s", name, value)) + + args = append(args, "-var", fmt.Sprintf("%s=%s", name, v)) } for _, secret := range t.Environment.Secrets { diff --git a/web/src/components/EnvironmentForm.vue b/web/src/components/EnvironmentForm.vue index 6dfd967f..0b7b3327 100644 --- a/web/src/components/EnvironmentForm.vue +++ b/web/src/components/EnvironmentForm.vue @@ -20,243 +20,255 @@ class="mb-4" > - - mdi-variable {{ $t('extraVariables') }} + + Variables + Secrets + - - - + + + + {{ $t('extraVariables') }} + + + + Variables passed via --extra-vars (Ansible) or -var (Terraform/OpenTofu). - + - + - - - Table - - - JSON - - - + + + Table + + + JSON + + + - + -
- - - -
- {{ $t('New Extra Variable') }} -
- Can't be displayed as table. -
- -
- - mdi-application-settings - {{ $t('environmentVariables') }} - - - - -
- {{ $t('New Environment Variable') }} -
-
- -
- - mdi-lock{{ $t('Secrets') }} - - - - - - -
- - - - - - mdi-variable - - {{ $t('Secret Extra Variable') }} - - - - mdi-application-settings - - {{ $t('Secret Environment Variable') }} - - - -
+ @click="addExtraVar()" + >{{ $t('New Extra Variable') }} +
+ Can't be displayed as table. + - +
+ + mdi-application-settings + {{ $t('environmentVariables') }} + + + + +
+ {{ $t('New Environment Variable') }} +
+
+ + + +
+ + {{ $t('Secrets') }} + + + + + + +
+ + + + + + mdi-variable + + {{ $t('Secret Extra Variable') }} + + + + mdi-application-settings + + {{ $t('Secret Environment Variable') }} + + + +
+ +
+ +
+ @@ -342,6 +354,8 @@ export default { env: [], secrets: [], + tab: 'variables', + cmOptions: { tabSize: 2, mode: 'application/json', diff --git a/web/src/components/TemplateForm.vue b/web/src/components/TemplateForm.vue index 0ac3e0f0..906a8323 100644 --- a/web/src/components/TemplateForm.vue +++ b/web/src/components/TemplateForm.vue @@ -74,7 +74,11 @@ - +