-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
249 lines (224 loc) · 9.08 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# See: https://taskfile.dev/#/usage
version: "3"
dotenv: [".env"]
output: prefixed
silent: true
vars:
DEFAULT_GO_PACKAGES:
sh: |
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go package(s)"')
LDFLAGS:
CLUSTER_NAME: profiles-controller
CONTEXT_NAME: "k3d-{{.CLUSTER_NAME}}"
ISTIO_VERSION: "1.13.3"
ISTIOCTL: "istioctl --context={{.CONTEXT_NAME}}"
KUBECTL: "kubectl --context={{.CONTEXT_NAME}}"
KUBEAPPLY: "{{.KUBECTL}} apply"
KUSTOMIZE: "{{.KUBEAPPLY}} --kustomize"
KUBEWAIT: "{{.KUBECTL}} wait"
KUBEWAIT_AVAIL: "{{.KUBEWAIT}} --for=condition=available"
KUBEWAIT_READY: "{{.KUBEWAIT}} --for=condition=ready"
KUBECREATE: "{{.KUBECTL}} create -o yaml --dry-run=client"
TODAY: '{{ now | date "2006-01-02T15:04:05-07:00" }}'
BLACK: \033[:0;30m
RED: \033[:0;31m
GREEN: \033[:0;32m
ORANGE: \033[:0;33m
BLUE: \033[:0;34m
PURPLE: \033[:0;35m
CYAN: \033[:0;36m
LIGHT_GRAY: \033[:0;37m
DARK_GRAY: \033[:1;30m
LIGHT_RED: \033[:1;31m
LIGHT_GREEN: \033[:1;32m
YELLOW: \033[:1;33m
LIGHT_BLUE: \033[:1;34m
LIGHT_PURPLE: \033[:1;35m
LIGHT_CYAN: \033[:1;36m
WHITE: \033[:1;37m
NOCOLOR: \u001b[0m
REVERSED: \u001b[7m
tasks:
default:
prefix: ⚙️
cmds:
- task -l
silent: true
check:
desc: Check for problems associated with the project
deps:
- task: go:lint
- task: go:vet
- task: go:test
format:
desc: Format all files
deps:
- task: go:format
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
cmds:
- go build -v {{.LDFLAGS}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:fix:
desc: Modernize usages of outdated APIs
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:format:
desc: Format Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:lint:
desc: Lint Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- |
if ! which golint &>/dev/null; then
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
exit 1
fi
- |
golint \
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
go:test:
desc: Run unit tests
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- |
go test \
-v \
-short \
-run '{{default ".*" .GO_TEST_REGEX}}' \
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
-coverprofile=coverage_unit.txt \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:vet:
desc: Check for errors in Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
k3d:create:
prefix: ⚙️ > create
desc: create k3d cluster
cmds:
- k3d cluster create --config=cluster/config.yaml
k3d:create:dev:
prefix: ⚙️ > create
desc: create k3d cluster (devcontainers)
deps:
- k3d:create
cmds:
- sed -i -e "s/0.0.0.0/host.docker.internal/g" ${HOME}/.kube/config
k3d:destroy:
prefix: ⚙️ > destroy
desc: destroy k3d cluster
cmds:
- "k3d cluster delete {{.CLUSTER_NAME}}"
k3d:start:
prefix: ⚙️ > start
desc: starts knative environment
cmds:
- "k3d cluster start {{.CLUSTER_NAME}}"
k3d:stop:
prefix: ⚙️ > stop
desc: stop knative environment
cmds:
- "k3d cluster stop {{.CLUSTER_NAME}}"
profile:crd:
prefix: ⚙️ profile > crd
desc: |
Creates a namespace for test user, and creates a
kubeflow profile given a profile.yaml file located in the cluster dir
cmds:
- "{{.KUBEAPPLY}} -f https://raw.githubusercontent.com/kubeflow/kubeflow/master/components/profile-controller/config/crd/bases/kubeflow.org_profiles.yaml"
- "{{.KUBECTL}} wait --for condition=established --timeout=60s crd/profiles.kubeflow.org"
- "yq e '.metadata.name' cluster/profiles.yaml -o json | xargs -I{} sh -c '{{.KUBECTL}} create ns {} || true'"
- "{{.KUBEAPPLY}} -f cluster/profiles.yaml"
profile:delete:
prefix: ⚙️ profile < delete
desc: |
Deletes namespace(s) for test user(s) as defined in
/cluster/profiles.yaml.
cmds:
- "yq e '.metadata.name' cluster/profiles.yaml -o json | xargs -I{} sh -c '{{.KUBECTL}} delete ns {} || true'"
- "yq e '.metadata.name' cluster/profiles.yaml -o json | xargs -I{} sh -c '{{.KUBECTL}} delete profile {} || true'"
argocd:install:
prefix: argocd > install
desc: installs arcgocd cluster wide, and sets up namespace for gitea
cmds:
- "{{.KUBECTL}} create ns argocd || true"
- "{{.KUBEAPPLY}} -f https://raw.githubusercontent.com/argoproj/argo-cd/release-2.1/manifests/install.yaml -n argocd"
argocd:uninstall:
prefix: argocd < uninstall
desc: uninstalls argocd
cmds:
- kubectl delete ns argocd
argocd:password:
prefix: argocd < password
desc: get the password stored in argocd-initial-admin-secret
cmds:
- "echo username: admin"
- kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
istioctl:install:
prefix: istioctl > install
desc: Downloads Istioctl onto the user's machine in $HOME/bin.
cmds:
- ISTIO_ALREADY_INSTALLED=$(command -v istioctl) && if [[ $ISTIO_ALREADY_INSTALLED ]]; then echo istioctl is already installed; else curl -L https://istio.io/downloadIstio | ISTIO_VERSION={{.ISTIO_VERSION}} TARGET_ARCH=x86_64 sh - && mv istio-{{.ISTIO_VERSION}}/bin/istioctl $HOME/bin && rm -r istio-{{.ISTIO_VERSION}}; fi
istio:install:
prefix: istio > install
desc: Installs Istio onto the cluster in the current context using the demo istio profile.
cmds:
- "{{.ISTIOCTL}} install --set profile=demo -y"
env:create:
prefix: env > create
desc: |
Creates a .env file if it does not already exist, and adds unsensitive values to it, with
instructions for values that are sensitive.
cmds:
- touch .env
- echo "REQUEUE_TIME=500" >> .env
- echo "GITEA_PSQL_ADMIN_PASSWD=" >> .env
- echo "GITEA_PSQL_ADMIN_UNAME=" >> .env
- echo "GITEA_PSQL_HOSTNAME=" >> .env
- echo "GITEA_PSQL_MAINTENANCE_DB=" >> .env
- echo "GITEA_PSQL_PORT=" >> .env
- echo "BLOB_CSI_FDI_OPA_DAEMON_TICKER_MILLIS=2000" .env
- echo "BLOB_CSI_FDI_OPA_UNCLASS_ENDPOINT=http://localhost:8181/v1/data" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_SPN_SECRET_NAME=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_SPN_SECRET_NAMESPACE=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_PV_STORAGE_CAP=100Gi" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_STORAGE_ACCOUNT=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_RESOURCE_GROUP=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_AZURE_STORAGE_AUTH_TYPE=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_AZURE_STORAGE_SPN_CLIENTID=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_AZURE_STORAGE_SPN_TENANTID=" >> .env
- echo "BLOB_CSI_FDI_UNCLASS_AZURE_STORAGE_AAD_ENDPOINT=" >> .env
- echo "BLOB_CSI_FDI_OPA_PROTECTED_B_ENDPOINT=http://localhost:8182/v1/data" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_SPN_SECRET_NAME=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_SPN_SECRET_NAMESPACE=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_PV_STORAGE_CAP=100Gi"
- echo "BLOB_CSI_FDI_PROTECTED_B_STORAGE_ACCOUNT=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_RESOURCE_GROUP=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_AZURE_STORAGE_AUTH_TYPE=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_AZURE_STORAGE_SPN_CLIENTID=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_AZURE_STORAGE_SPN_TENANTID=" >> .env
- echo "BLOB_CSI_FDI_PROTECTED_B_AZURE_STORAGE_AAD_ENDPOINT=" >> .env
- echo "I have created a .env file template for you. Should any values be missing, contact an \
aaw developer for help."
status:
- test -f ./.env
blobcsi:dev:
prefix: blobcsi:dev
desc: setup local environment for development.
cmds:
- echo "To enable local testing for blobcsi, you need to be able to query the OPA gateways locally!"
- echo "Run the below commands in separate terminals"
- echo "Run the vscode debugger for blob-csi!"
deps: [env:create]