-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
132 lines (117 loc) · 3.72 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# https://taskfile.dev
version: '3'
vars:
WORKSPACE_DIR: "workspace"
tasks:
fix:
desc: Fix Terraform formatting
cmds:
- task: terraform-command
vars: { TF_COMMAND: "fmt -recursive -write=true", TF_CMD_DIR: "{{.ROOT_DIR}}" }
lint:
desc: Formatting and linting
cmds:
- task: terraform-validate
- task: terraform-format-check
plan:
desc: Run "terraform plan" in "{{.WORKSPACE_DIR}}"
requires:
vars: [OPSLEVEL_API_TOKEN]
cmds:
- task: init-and-plan
apply:
desc: Run "terraform apply" in "{{.WORKSPACE_DIR}}"
requires:
vars: [OPSLEVEL_API_TOKEN]
cmds:
- task: init-and-apply
apply-demo:
desc: Run "terraform apply" to generate a demo account
requires:
vars: [OPSLEVEL_API_TOKEN, SANDBOX_USER_EMAIL]
env:
TF_VAR_account_token:
sh: echo "$OPSLEVEL_API_TOKEN"
TF_VAR_user_email:
sh: echo "$SANDBOX_USER_EMAIL"
cmds:
- task: install-terraform
- "terraform -chdir={{.WORKSPACE_DIR}} init --upgrade"
- "terraform -chdir={{.WORKSPACE_DIR}} apply {{.CLI_ARGS}}"
destroy:
desc: Run "terraform destroy" in "{{.WORKSPACE_DIR}}"
requires:
vars: [OPSLEVEL_API_TOKEN]
cmds:
- task: init-and-destroy
factory-reset:
desc: Run script to destroy all resources in account
requires:
vars: [OPSLEVEL_API_TOKEN]
vars:
ACCOUNT_NAME:
sh: opslevel graphql -q='query { account { name }}' | jq -r '.[0].account.name'
cmds:
- echo "Destroying all resources in account '{{.ACCOUNT_NAME}}'..."
- ./clear_account.sh
prompt: "Are you sure you want to destroy all resources in account '{{.ACCOUNT_NAME}}'?"
init-and-*:
internal: true
desc: Run "terraform init -upgrade" in "{{.WORKSPACE_DIR}}" then '{{index .MATCH 0}}'
cmds:
- task: terraform-command
vars: { TF_COMMAND: 'init -upgrade', TF_CMD_DIR: "{{.WORKSPACE_DIR}}" }
- task: terraform-command
vars: { TF_COMMAND: '{{index .MATCH 0}}', TF_CMD_DIR: "{{.WORKSPACE_DIR}}" }
install-sample-integration:
desc: Install sample Github integration
deps:
- install-cli
vars:
GRAPHQL_QUERY: mutation createSampleGitIntegration { sampleIntegrationCreate { integration { name } } }
cmds:
- opslevel graphql -H "GraphQL-Visibility=internal" -q='{{.GRAPHQL_QUERY}}'
terraform-validate:
internal: true
cmds:
- task: terraform-command
vars: { TF_COMMAND: "validate -no-tests", TF_CMD_DIR: "{{.ROOT_DIR}}" }
terraform-format-check:
internal: true
cmds:
- cmd: echo "Listing all terraform files that need formatting..."
- task: terraform-command
vars: { TF_COMMAND: "fmt -recursive -check", TF_CMD_DIR: "{{.ROOT_DIR}}" }
terraform-command:
internal: true
requires:
vars: [TF_COMMAND, TF_CMD_DIR]
preconditions:
- sh: 'which terraform'
msg: '"terraform" needed - run "brew install terraform"'
cmds:
- task: install-terraform
- "terraform -chdir={{.TF_CMD_DIR}} {{.TF_COMMAND}} {{.CLI_ARGS}}"
install-cli:
internal: true
platforms: [darwin]
preconditions:
- sh: 'which brew'
msg: '"brew" needed to install OpsLevel CLI - see https://brew.sh'
status:
- test -n "command -v opslevel"
cmds:
- echo "Installing OpsLevel CLI..."
- brew install opslevel/tap/cli
install-terraform:
internal: true
platforms: [darwin]
preconditions:
- sh: 'which brew'
msg: '"brew" needed to install terraform - see https://brew.sh'
status:
- test -n "command -v terraform"
cmds:
- echo "Installing terraform..."
- brew tap hashicorp/tap
- brew install hashicorp/tap/terraform