feat: add destroy flag and rename env to var groups

This commit is contained in:
Denis Gukov 2024-12-02 00:04:23 +05:00
parent 9e6439b20f
commit d5fc539aae
6 changed files with 274 additions and 236 deletions

View File

@ -15,6 +15,7 @@ type DefaultTaskParams struct {
type TerraformTaskParams struct {
Plan bool `json:"plan"`
Destroy bool `json:"destroy"`
AutoApprove bool `json:"auto_approve"`
}

View File

@ -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"`

View File

@ -238,11 +238,25 @@ func (t *LocalJob) getTerraformArgs(username string, incomingVersion *string) (a
return
}
for name, value := range extraVars {
if name == "semaphore_vars" {
continue
var params db.TerraformTaskParams
err = t.Task.GetParams(&params)
if err != nil {
return
}
args = append(args, "-var", fmt.Sprintf("%s=%s", name, value))
if params.Destroy {
args = append(args, "-destroy")
}
for name, value := range extraVars {
var v []byte
v, err = json.Marshal(value)
if err != nil {
return
}
args = append(args, "-var", fmt.Sprintf("%s=%s", name, v))
}
for _, secret := range t.Environment.Secrets {

View File

@ -20,8 +20,15 @@
class="mb-4"
></v-text-field>
<v-tabs grow v-model="tab">
<v-tab key="variables">Variables</v-tab>
<v-tab key="secrets">Secrets</v-tab>
</v-tabs>
<v-tabs-items v-model="tab">
<v-tab-item key="variables">
<v-subheader class="px-0">
<v-icon class="mr-1">mdi-variable</v-icon> {{ $t('extraVariables') }}
{{ $t('extraVariables') }}
<v-tooltip bottom color="black" open-delay="300" max-width="400">
<template v-slot:activator="{ on, attrs }">
@ -168,10 +175,12 @@
>{{ $t('New Environment Variable') }}</v-btn>
</div>
</div>
</v-tab-item>
<v-tab-item key="secrets">
<div>
<v-subheader class="px-0 mt-4">
<v-icon class="mr-1">mdi-lock</v-icon>{{ $t('Secrets') }}
{{ $t('Secrets') }}
</v-subheader>
<v-data-table
@ -258,6 +267,9 @@
</div>
</v-tab-item>
</v-tabs-items>
</v-form>
</template>
@ -342,6 +354,8 @@ export default {
env: [],
secrets: [],
tab: 'variables',
cmOptions: {
tabSize: 2,
mode: 'application/json',

View File

@ -74,7 +74,11 @@
<v-row>
<v-col cols="12" md="6" class="pb-0">
<v-card class="mb-6" :color="$vuetify.theme.dark ? '#212121' : 'white'">
<v-card
class="mb-6"
:color="$vuetify.theme.dark ? '#212121' : 'white'"
style="background: #8585850f"
>
<v-tabs
fixed-tabs
v-model="itemTypeIndex"

View File

@ -43,7 +43,7 @@ export default {
youHaveReadonlyAccess: 'You have read-only access',
taskTemplates: 'Task Templates',
inventory: 'Inventory',
environment: 'Environment Variables',
environment: 'Variable Groups',
keyStore: 'Key Store',
repositories: 'Repositories',
darkMode: 'Dark Mode',
@ -68,10 +68,10 @@ export default {
cancel: 'Cancel',
noViews: 'No views',
addView: 'Add view',
editEnvironment: 'Edit Environment',
deleteEnvironment: 'Delete environment',
newEnvironment: 'New Environment',
environmentName: 'Environment Name',
editEnvironment: 'Edit Variable Group',
deleteEnvironment: 'Delete variable group',
newEnvironment: 'New Group',
environmentName: 'Group Name',
extraVariables: 'Extra variables',
enterExtraVariablesJson: 'Enter extra variables JSON...',
environmentVariables: 'Environment variables',
@ -177,7 +177,7 @@ export default {
exampleSiteyml: 'Example: site.yml',
inventory2: 'Inventory *',
repository: 'Repository',
environment3: 'Environment *',
environment3: 'Variable Group *',
vaultPassword: 'Vault Password',
vaultPassword2: 'Vault Password',
view: 'View',