forked from agntcy/dir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
1953 lines (1783 loc) · 75.3 KB
/
Taskfile.yml
File metadata and controls
1953 lines (1783 loc) · 75.3 KB
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
version: "3"
env:
GOWORK: off
vars:
## Version
RELEASE_VERSION:
sh: grep 'version:' versions.yaml | awk '{print $2}'
RELEASE_VERSION_LDFLAG: "-X 'github.com/agntcy/dir/api/version.Version={{ .RELEASE_VERSION }}'"
COMMIT_SHA:
sh: git rev-parse --short HEAD
COMMIT_SHA_LDFLAG: "-X 'github.com/agntcy/dir/api/version.CommitHash={{ .COMMIT_SHA }}'"
VERSION_LDFLAGS: "{{ .RELEASE_VERSION_LDFLAG }} {{ .COMMIT_SHA_LDFLAG }}"
## Image config
IMAGE_REPO: '{{ .IMAGE_REPO | default "ghcr.io/agntcy" }}'
IMAGE_TAG: "{{ .IMAGE_TAG | default .COMMIT_SHA }}"
IMAGE_BAKE_ENV: "IMAGE_REPO={{.IMAGE_REPO}} IMAGE_TAG={{.IMAGE_TAG}}"
IMAGE_BAKE_OPTS: '{{ .IMAGE_BAKE_OPTS | default "" }}'
BAKE_ENV: '{{ .IMAGE_BAKE_ENV }} EXTRA_LDFLAGS="{{.VERSION_LDFLAGS}}"'
COVERAGE_IMAGE_TAG: "{{ .IMAGE_TAG | default .COMMIT_SHA }}-coverage"
COVERAGE_IMAGE_BAKE_ENV: "IMAGE_REPO={{.IMAGE_REPO}} IMAGE_TAG={{.COVERAGE_IMAGE_TAG}}"
COVERAGE_BAKE_ENV: '{{ .COVERAGE_IMAGE_BAKE_ENV }} EXTRA_LDFLAGS="{{.VERSION_LDFLAGS}}"'
COVERAGE_PKGS: '{{ .COVERAGE_PKGS | default "github.com/agntcy/dir/api/...,github.com/agntcy/dir/cli/...,github.com/agntcy/dir/client/...,github.com/agntcy/dir/importer/...,github.com/agntcy/dir/utils/..." }}'
## Dependency config
BIN_DIR: "{{ .ROOT_DIR }}/bin"
DIRCTL_BIN: "{{ .BIN_DIR}}/dirctl"
HELM_VERSION: "4.0.5"
HELM_BIN: "{{ .BIN_DIR }}/helm-{{.HELM_VERSION}}"
KUBECTL_VERSION: "1.35.0"
KUBECTL_BIN: "{{ .BIN_DIR }}/kubectl-{{.KUBECTL_VERSION}}"
KIND_VERSION: "0.31.0"
KIND_BIN: "{{ .BIN_DIR }}/kind-{{.KIND_VERSION}}"
PROTOC_VERSION: "33.4"
PROTOC_BIN: "{{ .BIN_DIR }}/protoc-{{.PROTOC_VERSION}}"
BUFBUILD_VERSION: "1.63.0"
BUFBUILD_BIN: "{{ .BIN_DIR }}/bufbuild-{{.BUFBUILD_VERSION}}"
GO_VERSION: "1.25.6"
MULTIMOD_VERSION: "0.28.1"
MULTIMOD_BIN: "{{ .BIN_DIR }}/multimod-{{.MULTIMOD_VERSION}}"
GOLANGCI_LINT_VERSION: "2.8.0"
GOLANGCI_LINT_BIN: "{{ .BIN_DIR }}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}"
LICENSEI_VERSION: "0.9.0"
LICENSEI_BIN: "{{ .BIN_DIR }}/licensei-{{.LICENSEI_VERSION}}"
UV_VERSION: "0.9.26"
UV_BIN: "{{ .BIN_DIR }}/uv-{{.UV_VERSION}}"
UV_PUBLISH_TOKEN: '{{ .UV_PUBLISH_TOKEN | default "" }}'
COSIGN_VERSION: "3.0.4"
COSIGN_BIN: "{{ .BIN_DIR }}/cosign-{{.COSIGN_VERSION}}"
HUB_API_VERSION: "main"
ZOT_VERSION: "2.1.13"
SPIRE_VERSION: "1.14.1"
## Go module discovery
GO_MOD_DIR:
sh: find . -name go.mod -not -path "./tmp*" -exec dirname {} \;
GO_MOD_DIR_UNIT_TEST:
sh: find . -name go.mod -not -path "./e2e*" -not -path "./tmp*" -exec dirname {} \;
tasks:
##
## General
##
default:
cmds:
- task -l
gen:
desc: Generate code for all components
cmds:
- task: api:gen
- task: helm:gen
check:
desc: Checks for all code violations
cmds:
- task: lint
- task: license
build:
desc: Build images for all components
deps:
- task: deps:tidy
- task: gen
vars:
GOARCH: "{{ .GOARCH | default ARCH }}"
EXTRA_FLAGS: '{{ .EXTRA_FLAGS | default "" }}'
cmds:
- "{{.BAKE_ENV}} docker buildx bake {{.IMAGE_BAKE_OPTS}} --set *.platform=linux/{{.GOARCH}} {{.EXTRA_FLAGS}}"
build:coverage:
desc: Build images for all components with coverage instrumentation
cmds:
- task: build
vars:
BAKE_ENV: "{{ .COVERAGE_BAKE_ENV }}"
# TODO: -coverpkg should be set to include all packages (server, api, utils) in the coverage report
# but it's not working as expected, so we're using the default coverage package for now
EXTRA_FLAGS: 'coverage --set *.args.BUILD_OPTS="-cover -covermode=atomic"'
build:all:
desc: Build images for all components for multiple platforms
cmds:
- "{{.BAKE_ENV}} docker buildx bake {{.IMAGE_BAKE_OPTS}} --set *.platform=linux/amd64,linux/arm64"
pull:
desc: Pull images for all components
cmds:
- |
images=$({{.BAKE_ENV}} docker buildx bake default --print | jq -r '.target | with_entries(.value |= .tags[0]) | to_entries[] | .value')
echo "$images" | while read image; do
echo "Pulling image: $image"
docker pull $image
done
push:
desc: Build and push images for all components
prompt:
- Are you sure you want to push the images to remote registry?
cmds:
- "{{.BAKE_ENV}} docker buildx bake {{.IMAGE_BAKE_OPTS}} --set=*.output=type=registry"
release:create:
desc: Prepare release
deps:
- task: deps:multimod-bin
- task: sdk:deps:python
- task: sdk:deps:javascript
vars:
RELEASE_VERSION: "{{ .RELEASE_VERSION }}"
cmds:
# Switch to new branch
- 'if [ "$(git rev-parse --abbrev-ref HEAD)" != "release/{{.RELEASE_VERSION}}" ]; then git checkout -b release/{{.RELEASE_VERSION}}; fi'
# Update versions.yaml with the new version
- 'awk ''{gsub(/version: .*/,"version: {{.RELEASE_VERSION}}")}1'' versions.yaml > versions.yaml.tmp'
- "mv versions.yaml.tmp versions.yaml"
# Update SDK packages with the new version
- "cd sdk/dir-py && {{ .UV_BIN }} version {{.RELEASE_VERSION}} && cd -"
- "cd sdk/dir-js && npm version {{.RELEASE_VERSION}} --allow-same-version --no-git-tag-version && cd -"
# Add release changes
- |
git add .
git commit -S -m "release(dir): prepare release {{.RELEASE_VERSION}}"
# Verify Go release
- |
{{ .MULTIMOD_BIN }} verify
{{ .MULTIMOD_BIN }} prerelease --all-module-sets --skip-go-mod-tidy=true --commit-to-different-branch=false
# Push prepared release
- task: release:push
release:push:
internal: true
vars:
RELEASE_VERSION: "{{ .RELEASE_VERSION }}"
prompt:
- "Are you sure you want to push the release branch release/{{.RELEASE_VERSION}} to remote repository?"
cmds:
- |
git push --set-upstream origin release/{{.RELEASE_VERSION}} || true
##
## API
##
api:gen:
desc: Generates API stubs
dir: ./proto
deps:
- task: deps:protoc
- task: deps:bufbuild
# NOTE(ramizpolic): This allows Taskfile YAML parsing to accept '{' as a starting command token.
# In translation, this is interpreted as a regular multi-line shell script.
cmds:
- "{{.BUFBUILD_BIN}} dep update"
- "{{.BUFBUILD_BIN}} generate"
api:clean:
desc: Clean generated API stubs
deps:
- api:clean:go
- api:clean:python
- api:clean:javascript
api:clean:go:
desc: Clean generated golang API stubs
dir: ./api
cmds:
- find . \( -name "*.pb.go" \) -type f -delete
api:clean:python:
desc: Clean generated Python API stubs
dir: ./sdk/dir-py/agntcy
cmd: rm -drf ./dir
api:clean:javascript:
desc: Clean generated JS/TS API stubs
dir: ./sdk/dir-js/
cmd: rm -drf ./api
##
## CLI
##
cli:compile:
desc: Compile CLI binaries
dir: ./cli
vars:
GOOS: "{{ .GOOS | default OS }}"
GOARCH: "{{ .GOARCH | default ARCH }}"
BINARY_NAME: '{{ .BINARY_NAME | default "dirctl" }}'
OUT_BINARY: '{{ if eq OS "windows" }}{{ .ROOT_DIR }}\\bin\\{{ .BINARY_NAME }}.exe{{ else }}{{ .ROOT_DIR }}/bin/{{ .BINARY_NAME }}{{ end }}'
LDFLAGS: "-s -w -extldflags -static {{ .VERSION_LDFLAGS }}"
TRY_SKIP_COMPILE: '{{ .TRY_SKIP_COMPILE | default "false" }}'
cmds:
- |
if [ "{{.TRY_SKIP_COMPILE}}" = "true" ]; then
if [ -f "{{.OUT_BINARY}}" ]; then
echo "Binary {{.OUT_BINARY}} already exists, skipping compilation."
exit 0
else
echo "Binary {{.OUT_BINARY}} does not exist, proceeding with compilation."
fi
fi
CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags="{{ .LDFLAGS }}" -o "{{.OUT_BINARY}}" cli.go
cli:compile:all:
desc: Compile CLI client binaries for multiple platforms
aliases: [compile]
cmds:
- for:
matrix:
OS: ["linux", "darwin", "windows"]
ARCH: ["amd64", "arm64"]
cmd: |
# Skip unsupported combinations (e.g., Windows ARM64)
if [ "{{.ITEM.OS}}" = "windows" ] && [ "{{.ITEM.ARCH}}" = "arm64" ]; then
echo "Skipping unsupported platform: {{.ITEM.OS}}/{{.ITEM.ARCH}}"
else
GOOS={{.ITEM.OS}} GOARCH={{.ITEM.ARCH}} BINARY_NAME=dirctl-{{.ITEM.OS}}-{{.ITEM.ARCH}} task cli:compile
fi
##
## MCP Server
##
mcp:build:
desc: Build the MCP server
dir: ./mcp
vars:
GOOS: "{{ .GOOS | default OS }}"
GOARCH: "{{ .GOARCH | default ARCH }}"
OUT_BINARY: "{{ .BIN_DIR }}/mcp-server"
cmds:
- mkdir -p {{ .BIN_DIR }}
- CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -o "{{.OUT_BINARY}}" main.go
mcp:build:server:
desc: Build the Directory Server binary for local MCP use
dir: ./server/cmd
vars:
GOOS: "{{ .GOOS | default OS }}"
GOARCH: "{{ .GOARCH | default ARCH }}"
OUT_BINARY: "{{ .BIN_DIR }}/dir-server"
cmds:
- mkdir -p {{ .BIN_DIR }}
- CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -o "{{.OUT_BINARY}}" main.go
##
## Client SDK
##
sdk:deps:common:
desc: Common dependencies for SDKs
vars:
TRY_SKIP_COMPILE: "{{ .TRY_SKIP_COMPILE }}"
cmds:
- task: deps:cosign
- task: cli:compile
vars:
TRY_SKIP_COMPILE: "{{.TRY_SKIP_COMPILE}}"
- task: sdk:deps:javascript
- task: sdk:deps:python
sdk:deps:cicd:iodc-token-generation:
desc: Get Fulcio OIDC token for CICD
requires:
vars: [CLIENT_ID]
cmds:
- |
OIDC_TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sigstore" | jq -r '.value')
CLIENT_ID="{{.CLIENT_ID}}"
PROVIDER_URL="https://token.actions.githubusercontent.com"
echo "OIDC_PROVIDER_URL=${PROVIDER_URL}"
echo "CLIENT_ID=${CLIENT_ID}"
echo "OIDC_TOKEN=${OIDC_TOKEN}"
sdk:build:all:
desc: Build all client SDK package
cmds:
- task: sdk:build:javascript
- task: sdk:build:python
sdk:build:python:
desc: Build python client SDK package
dir: ./sdk/dir-py
deps:
- task: sdk:deps:python
cmds:
- "{{.UV_BIN}} build"
sdk:build:javascript:
desc: Build javascript client SDK package
dir: ./sdk/dir-js
deps:
- task: sdk:deps:javascript
cmds:
- npm run build
sdk:test-env:create:
desc: Create Kubernetes cluster test environment
cmds:
- task: deploy:kubernetes:local
vars:
DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL: 1s
- task: deploy:kubernetes:local:port-forward
sdk:test-env:delete:
desc: Delete Kubernetes cluster test environment
cmds:
- task: deploy:kubernetes:local:port-forward:cleanup
- task: deploy:kubernetes:local:cleanup
sdk:test-env:spiffe:load-test-image:
desc: Load the SDK tests into KinD
deps:
- task: api:gen
vars:
GOARCH: "{{ .GOARCH | default ARCH }}"
cmds:
- "{{.BAKE_ENV}} docker buildx bake sdks-test --set *.platform=linux/{{.GOARCH}} {{.IMAGE_BAKE_OPTS}}"
- "{{.KUBECTL_BIN}} config use-context kind-dir.example"
- "{{.KIND_BIN}} load docker-image ghcr.io/agntcy/sdks-test:{{.IMAGE_TAG}} --name dir.example"
sdk:test:all:spiffe:
desc: Test all client SDK pacakges with spiffe
dir: ./e2e/sdk
cmds:
- "{{.KUBECTL_BIN}} config use-context kind-dir.example"
- "{{.HELM_BIN}} uninstall sdk-tests --wait --keep-history --ignore-not-found > /dev/null || true"
- "{{.HELM_BIN}} install --replace --timeout 3m --wait --wait-for-jobs sdk-tests ./chart -f chart/values.yaml --set image.tag={{.IMAGE_TAG}} > /dev/null || true"
- |
status=$({{.KUBECTL_BIN}} get job sdks-test -o jsonpath='{.status.conditions[0].type}')
status_value=$({{.KUBECTL_BIN}} get job sdks-test -o jsonpath='{.status.conditions[0].status}')
if [[ "$status" == "SuccessCriteriaMet" ]] && [[ "$status_value" == "True" ]]; then
echo "SDKs test are finished successfully! ✅"
exit 0
fi
if [[ "$status" == "FailureTarget" ]] && [[ "$status_value" == "True" ]]; then
{{.KUBECTL_BIN}} logs jobs/sdks-test
echo "SDKs test are failed! ❎"
exit 1
fi
echo "Unknown error happend, check logs! ⚠️"
exit 1
sdk:test:all:
desc: Test all client SDK packages
cmds:
- task: sdk:test:javascript
- task: sdk:test:python
sdk:test:python:
desc: Test python client SDK package
dir: ./sdk/dir-py
deps:
- task: sdk:deps:python
env:
KIND_CLUSTER_NAME: "sdk-py-test"
cmds:
- task: sdk:test-env:create
- defer: { task: sdk:test-env:delete }
- |
export DIRCTL_PATH="$(printf "%s" "${DIRCTL_PATH:-{{ .DIRCTL_BIN }}}")"
export COSIGN_PATH="$(printf "%s" "${COSIGN_PATH:-{{ .COSIGN_BIN }}}")"
# Run SDK tests
'{{.UV_BIN}}' run pytest
# Run SDK example to verify it works
cd {{ .ROOT_DIR }}/sdk/examples/example-py
'{{.UV_BIN}}' sync
'{{.UV_BIN}}' run python example.py
sdk:test:javascript:
desc: Test javascript client SDK package
dir: ./sdk/dir-js
deps:
- task: sdk:deps:javascript
env:
KIND_CLUSTER_NAME: "sdk-js-test"
cmds:
- task: sdk:test-env:create
- defer: { task: sdk:test-env:delete }
- |
export DIRCTL_PATH="$(printf "%s" "${DIRCTL_PATH:-{{ .DIRCTL_BIN }}}")"
export COSIGN_PATH="$(printf "%s" "${COSIGN_PATH:-{{ .COSIGN_BIN }}}")"
# Run SDK tests
npm run test
# Run SDK example to verify it works
cd {{ .ROOT_DIR }}/sdk/examples/example-js
npm install
npm run example
sdk:deps:python:
desc: Install deps for python SDK package
dir: ./sdk/dir-py
deps:
- task: deps:bufbuild
- task: deps:uv
cmds:
- task: api:gen
- "{{.UV_BIN}} sync --all-packages"
sdk:deps:javascript:
desc: Install deps for javascript SDK package
dir: ./sdk/dir-js
cmds:
- npm install
- task: api:gen
sdk:release:all:
desc: Release all client SDK package
env:
UV_PUBLISH_TOKEN: "{{ .UV_PUBLISH_TOKEN }}"
cmds:
- task: sdk:release:javascript
- task: sdk:release:python
sdk:release:python:
desc: Release python client SDK package
dir: ./sdk/dir-py
env:
UV_PUBLISH_TOKEN: "{{ .UV_PUBLISH_TOKEN }}"
deps:
- task: deps:uv
cmds:
- "{{.UV_BIN}} publish"
sdk:release:javascript:
desc: Release javascript client SDK package
dir: ./sdk/dir-js
cmd: |
version=$(npm pkg get version)
if [[ $version == *"rc"* ]]; then
npm publish --scope=@agntcy --access public --tag rc-{{.COMMIT_SHA}}
else
npm publish --scope=@agntcy --access public
fi
##
## Server
##
server:build:
desc: Build Directory server image
cmds:
- "{{.BAKE_ENV}} docker buildx bake {{.IMAGE_BAKE_OPTS}} dir-apiserver"
server:start:
desc: Start Directory server
dir: server/cmd
env:
# Local development settings:
# - Faster publication scheduling for quicker feedback
# - OASF validation disabled (no external schema dependency)
DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL: 1s
DIRECTORY_SERVER_OASF_API_VALIDATION_DISABLE: "true"
cmds:
- defer: { task: server:store:stop }
- task: server:store:start
- go run main.go
server:store:pull:
desc: Pull local OCI registry server docker image
vars:
IMAGE: "{{.IMAGE}}"
cmds:
- |
docker pull {{.IMAGE}}
server:store:start:
desc: Start local OCI registry server for storage
internal: true
vars:
IMAGE: ghcr.io/project-zot/zot-linux-{{ARCH}}:v{{.ZOT_VERSION}}
deps:
- task: server:store:pull
vars:
IMAGE: "{{.IMAGE}}"
cmds:
- |
# mount config
cat > /tmp/config.json <<EOF
{
"distSpecVersion": "1.1.1",
"storage": {
"rootDirectory": "/tmp/zot"
},
"http": {
"address": "0.0.0.0",
"port": "5000"
},
"log": {
"level": "debug"
},
"extensions": {
"search": {
"enable": true
},
"trust": {
"enable": true,
"cosign": true,
"notation": false
}
}
}
EOF
# run docker with attached volume
docker run \
-it \
--rm -d -p 5000:5000 \
-v /tmp/config.json:/config.json:ro \
--name oci-registry {{.IMAGE}} serve /config.json
server:store:stop:
desc: Stop local OCI registry node
internal: true
cmds:
- docker stop oci-registry
server:bench:
desc: Benchmark Directory server code
dir: ./server
cmds:
- go -C . test -run=^$ -bench=. ./...
##
## Deploy
##
deploy:kubernetes:setup-cluster:
desc: Create a kind cluster and load Docker images
deps:
- deps:helm
- deps:kubectl
- deps:kind
vars:
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
KIND_CREATE_OPTS: '{{ .KIND_CREATE_OPTS | default "" }}'
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_BAKE_ENV: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_BAKE_ENV }}{{ else }}{{ .BAKE_ENV }}{{ end }}'
DEPLOY_BAKE_GROUP: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}coverage{{ else }}default{{ end }}'
cmds:
# Create ephemeral cluster
- "{{ .KIND_BIN }} create cluster {{ .KIND_CREATE_OPTS }} --name {{ .KIND_CLUSTER_NAME }}"
- "{{ .KIND_BIN }} export kubeconfig --name {{ .KIND_CLUSTER_NAME }}"
# Check cluster status
- "{{ .KUBECTL_BIN }} cluster-info"
# Import images
- |
images=$({{.DEPLOY_BAKE_ENV}} docker buildx bake {{.DEPLOY_BAKE_GROUP}} --print | jq -r '.target | with_entries(.value |= .tags[0]) | to_entries[] | .value')
echo "$images" | while read image; do
{{ .KIND_BIN }} load docker-image $image --name {{ .KIND_CLUSTER_NAME }}
done
deploy:kubernetes:gen-htpasswd-creds:
desc: Generate htpasswd credentials and files for DIR deployment
vars:
HTPASSWD_USERNAME: '{{ .HTPASSWD_USERNAME | default "apiserver" }}'
HTPASSWD_SYNC_USERNAME: '{{ .HTPASSWD_SYNC_USERNAME | default "sync-user" }}'
CREDS_FILE: '{{ .CREDS_FILE | default "/tmp/dir-htpasswd-creds.env" }}'
HTPASSWD_FILE: '{{ .HTPASSWD_FILE | default "/tmp/dir-htpasswd" }}'
cmds:
- |
# Generate fresh passwords
HTPASSWD_PASSWORD="$(openssl rand -hex 16)"
HTPASSWD_SYNC_PASSWORD="$(openssl rand -hex 16)"
# Generate derived values
HTPASSWD_AUTH_HEADER="$(echo -n "{{ .HTPASSWD_USERNAME }}:${HTPASSWD_PASSWORD}" | base64)"
HTPASSWD_ADMIN="$(htpasswd -nbB "{{ .HTPASSWD_USERNAME }}" "${HTPASSWD_PASSWORD}" | sed 's/^{{ .HTPASSWD_USERNAME }}://')"
HTPASSWD_SYNC="$(htpasswd -nbB "{{ .HTPASSWD_SYNC_USERNAME }}" "${HTPASSWD_SYNC_PASSWORD}" | sed 's/^{{ .HTPASSWD_SYNC_USERNAME }}://')"
# Write credentials to env file (for helm --set commands)
cat > {{ .CREDS_FILE }} << EOF
export HTPASSWD_USERNAME="{{ .HTPASSWD_USERNAME }}"
export HTPASSWD_PASSWORD="${HTPASSWD_PASSWORD}"
export HTPASSWD_AUTH_HEADER="${HTPASSWD_AUTH_HEADER}"
export HTPASSWD_SYNC_USERNAME="{{ .HTPASSWD_SYNC_USERNAME }}"
export HTPASSWD_SYNC_PASSWORD="${HTPASSWD_SYNC_PASSWORD}"
EOF
# Write htpasswd file (for helm --set-file commands)
cat > {{ .HTPASSWD_FILE }} << EOF
{{ .HTPASSWD_USERNAME }}:${HTPASSWD_ADMIN}
{{ .HTPASSWD_SYNC_USERNAME }}:${HTPASSWD_SYNC}
EOF
deploy:kubernetes:cleanup-htpasswd-creds:
desc: Cleanup htpasswd credentials and files
vars:
CREDS_FILE: '{{ .CREDS_FILE | default "/tmp/dir-htpasswd-creds.env" }}'
HTPASSWD_FILE: '{{ .HTPASSWD_FILE | default "/tmp/dir-htpasswd" }}'
cmds:
- rm -f {{ .CREDS_FILE }}
- rm -f {{ .HTPASSWD_FILE }}
deploy:kubernetes:local:
aliases: [deploy:local]
desc: Deploy a local Directory server in Kubernetes
deps:
- deploy:kubernetes:setup-cluster
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
KIND_CREATE_OPTS: '{{ .KIND_CREATE_OPTS | default "" }}'
# Helm args
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
cmds:
# TODO: make logic idempotent so that running functional tests does not change previous contexts
# Generate credentials and htpasswd file (using defaults)
- task: deploy:kubernetes:gen-htpasswd-creds
# Cleanup credentials on exit (using defaults)
- defer:
task: deploy:kubernetes:cleanup-htpasswd-creds
# Deploy chart
- |
# Load credentials
source /tmp/dir-htpasswd-creds.env
{{ .HELM_BIN }} dependency build {{ .HELM_CHART_PATH }}
{{ .HELM_BIN }} upgrade dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
{{ if .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/dir-htpasswd" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if .DIRECTORY_SERVER_RATELIMIT_ENABLED }}--set apiserver.config.ratelimit.enabled="{{ .DIRECTORY_SERVER_RATELIMIT_ENABLED }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_GLOBAL_RPS }}--set apiserver.config.ratelimit.global_rps="{{ .DIRECTORY_SERVER_RATELIMIT_GLOBAL_RPS }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_GLOBAL_BURST }}--set apiserver.config.ratelimit.global_burst="{{ .DIRECTORY_SERVER_RATELIMIT_GLOBAL_BURST }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_RPS }}--set apiserver.config.ratelimit.per_client_rps="{{ .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_RPS }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_BURST }}--set apiserver.config.ratelimit.per_client_burst="{{ .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_BURST }}"{{ end }} \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
{{ if .DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL }}--set apiserver.config.oasf_api_validation.schema_url="{{ .DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL }}"{{ end }} \
{{ if .DIRECTORY_SERVER_OASF_API_VALIDATION_DISABLE }}--set apiserver.config.oasf_api_validation.disable="{{ .DIRECTORY_SERVER_OASF_API_VALIDATION_DISABLE }}"{{ end }} \
{{ if ne .DIRECTORY_SERVER_OASF_API_VALIDATION_STRICT_MODE nil }}--set apiserver.config.oasf_api_validation.strict_mode="{{ .DIRECTORY_SERVER_OASF_API_VALIDATION_STRICT_MODE }}"{{ end }} \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
deploy:kubernetes:context:
desc: Switch context to given Kubernetes cluster
vars:
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
- "{{ .KIND_BIN }} export kubeconfig --name {{ .KIND_CLUSTER_NAME }}"
deploy:kubernetes:dir:
desc: Deploy DIR helm chart
vars:
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
HELM_EXTRA_ARGS: '{{ .HELM_EXTRA_ARGS | default "" }}'
cmds:
# Generate credentials and htpasswd file (using defaults)
- task: deploy:kubernetes:gen-htpasswd-creds
# Cleanup credentials on exit (using defaults)
- defer:
task: deploy:kubernetes:cleanup-htpasswd-creds
# Deploy chart
- |
# Load credentials
source /tmp/dir-htpasswd-creds.env
{{ .HELM_BIN }} dependency build {{ .HELM_CHART_PATH }}
{{ .HELM_BIN }} upgrade --install dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .IMAGE_TAG }}" \
{{ if .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/dir-htpasswd" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
--set apiserver.log_level="DEBUG" \
{{ .HELM_EXTRA_ARGS }} \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
deploy:kubernetes:dirctl:
desc: Deploy DIRCTL helm chart
vars:
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-client" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dirctl"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dirctl/values.yaml"
HELM_EXTRA_ARGS: '{{ .HELM_EXTRA_ARGS | default "" }}'
cmds:
- |
{{ .HELM_BIN }} upgrade --install dirctl \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set image.tag="{{ .IMAGE_TAG }}" \
{{ .HELM_EXTRA_ARGS }} \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
deploy:kubernetes:spire:
desc: Deploy SPIRE helm chart
vars:
TRUST_DOMAIN: '{{ .TRUST_DOMAIN | default "example.org" }}'
SERVICE_TYPE: '{{ .SERVICE_TYPE | default "LoadBalancer" }}'
BUNDLE_PATH: '{{ .BUNDLE_PATH | default "/tmp/spire-bundle.spiffe" }}'
cmds:
- |
{{ .HELM_BIN }} upgrade --install spire-crds spire-crds \
--repo https://spiffe.github.io/helm-charts-hardened/ \
--namespace spire-crds \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
- |
{{ .HELM_BIN }} upgrade --install spire spire \
--repo https://spiffe.github.io/helm-charts-hardened/ \
--set global.spire.trustDomain="{{ .TRUST_DOMAIN }}" \
--set spire-server.image.tag="{{ .SPIRE_VERSION }}" \
--set spire-agent.image.tag="{{ .SPIRE_VERSION }}" \
--set spire-server.service.type="{{ .SERVICE_TYPE }}" \
--set spire-server.federation.enabled="true" \
--set spire-server.controllerManager.watchClassless="true" \
--set spire-server.controllerManager.className="dir-spire" \
--namespace spire \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
- |
{{ .KUBECTL_BIN }} get configmap -n spire spire-bundle -o json | jq '.data."bundle.spiffe"' -r > {{ .BUNDLE_PATH }}
deploy:kubernetes:local:port-forward:
aliases: [deploy:local:port-forward]
desc: Set up port-forwarding for the local deployment
vars:
# Helm args
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server" }}'
cmds:
# Port-forward dependency services
- |
{{ .KUBECTL_BIN }} port-forward service/dir-apiserver 8888:8888 -n {{ .HELM_NAMESPACE }} &
{{ .KUBECTL_BIN }} port-forward service/dir-apiserver 9090:9090 -n {{ .HELM_NAMESPACE }} &
{{ .KUBECTL_BIN }} port-forward service/dir-ingress-controller 8080:80 -n {{ .HELM_NAMESPACE }} &
# Delay to ensure services are online
- sleep 10
deploy:kubernetes:local:port-forward:cleanup:
aliases: [deploy:local:port-forward:cleanup]
desc: Cleanup port-forwarding processes
cmds:
# Kill any existing port-forward processes for the dir-apiserver and dir-ingress-controller services
- kill -9 $(ps aux | grep port-forward | grep -E "(dir-apiserver|dir-ingress-controller)" | awk '{print $2}') || true
deploy:kubernetes:local:cleanup:
aliases: [deploy:local:cleanup, deploy:kubernetes:cleanup]
desc: Cleanup Kubernetes environment for local deployment
deps:
- deps:kind
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
- "{{ .KIND_BIN }} delete cluster --name {{ .KIND_CLUSTER_NAME }}"
deploy:kubernetes:network:bootstrap:
internal: true
desc: Deploy a bootstrap Directory server in Kubernetes
deps:
- task: deploy:kubernetes:setup-cluster
vars:
E2E_COVERAGE_ENABLED: "{{ .E2E_COVERAGE_ENABLED }}"
- deps:dirctl-bin
vars:
# Helm args
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
cmds:
# Generate private key if it doesn't exist
- |
test -f /tmp/node.privkey || {{ .BIN_DIR }}/dirctl network init --output /tmp/node.privkey
# Generate the bootstrap peer ID and export it to the environment file
- |
bootstrap_peerid=$({{ .BIN_DIR }}/dirctl network info /tmp/node.privkey)
echo "PEER ID: ${bootstrap_peerid}"
echo BOOTSTRAP_PEER_ID="${bootstrap_peerid}" > .env
# Generate credentials and htpasswd file
- task: deploy:kubernetes:gen-htpasswd-creds
vars:
CREDS_FILE: "/tmp/dir-htpasswd-creds-bootstrap.env"
HTPASSWD_FILE: "/tmp/zot-htpasswd-bootstrap"
# Cleanup credentials on exit
- defer:
task: deploy:kubernetes:cleanup-htpasswd-creds
vars:
CREDS_FILE: "/tmp/dir-htpasswd-creds-bootstrap.env"
HTPASSWD_FILE: "/tmp/zot-htpasswd-bootstrap"
# Deploy the bootstrap server using Helm
- |
# Load credentials
source /tmp/dir-htpasswd-creds-bootstrap.env
{{ .HELM_BIN }} dependency build {{ .HELM_CHART_PATH }}
{{ .HELM_BIN }} upgrade agntcy-dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
{{ if .PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.secrets.privKey="$(cat /tmp/node.privkey)" \
--set apiserver.config.routing.key_path="/etc/agntcy/dir/node.privkey" \
--set apiserver.config.routing.listen_address="/ip4/0.0.0.0/tcp/8999" \
--set apiserver.config.routing.directory_api_address="agntcy-dir-apiserver.bootstrap.svc.cluster.local:8888" \
--set apiserver.config.store.oci.registry_address="agntcy-dir-zot.bootstrap.svc.cluster.local:5000" \
--set apiserver.zot.extraVolumes[0].persistentVolumeClaim.claimName="agntcy-dir-zot-config" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/zot-htpasswd-bootstrap" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
--namespace "bootstrap" \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
deploy:kubernetes:network:
aliases: [deploy:network]
desc: Deploy a network of Directory servers in Kubernetes (1 bootstrap + 3 peers)
vars:
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
cmds:
# Deploy bootstrap with explicit var passing (not as dependency)
- task: deploy:kubernetes:network:bootstrap
vars:
PUBLICATION_SCHEDULER_INTERVAL: "{{ .PUBLICATION_SCHEDULER_INTERVAL }}"
E2E_COVERAGE_ENABLED: "{{ .E2E_COVERAGE_ENABLED }}"
# Deploy the peer servers using Helm
- for:
matrix:
PEER: ["peer1", "peer2", "peer3"]
cmd: |
export $(cat .env)
# Generate fresh credentials for this peer using helper task
task deploy:kubernetes:gen-htpasswd-creds \
CREDS_FILE=/tmp/dir-htpasswd-creds-{{ .ITEM.PEER }}.env \
HTPASSWD_FILE=/tmp/zot-htpasswd-{{ .ITEM.PEER }}
# Load credentials
source /tmp/dir-htpasswd-creds-{{ .ITEM.PEER }}.env
{{ .HELM_BIN }} dependency build {{ .HELM_CHART_PATH }}
{{ .HELM_BIN }} upgrade agntcy-dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
{{ if .PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.config.store.oci.registry_address="agntcy-dir-zot.{{ .ITEM.PEER }}.svc.cluster.local:5000" \
--set apiserver.config.routing.bootstrap_peers[0]="/dns4/agntcy-dir-apiserver-routing.bootstrap.svc.cluster.local/tcp/8999/p2p/${BOOTSTRAP_PEER_ID}" \
--set apiserver.config.routing.directory_api_address="agntcy-dir-apiserver.{{ .ITEM.PEER }}.svc.cluster.local:8888" \
--set apiserver.zot.extraVolumes[0].persistentVolumeClaim.claimName="agntcy-dir-zot-config" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/zot-htpasswd-{{ .ITEM.PEER }}" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
--namespace "{{ .ITEM.PEER }}" \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
# Cleanup temp files
rm -f /tmp/zot-htpasswd-{{ .ITEM.PEER }}
rm -f /tmp/dir-htpasswd-creds-{{ .ITEM.PEER }}.env
deploy:kubernetes:network:port-forward:
aliases: [deploy:network:port-forward]
desc: Set up port-forwarding for the peers
cmds:
# Port-forward dependency services
- "{{ .KUBECTL_BIN }} port-forward svc/agntcy-dir-apiserver -n peer1 8890:8888 &"
- "{{ .KUBECTL_BIN }} port-forward svc/agntcy-dir-apiserver -n peer2 8891:8888 &"
- "{{ .KUBECTL_BIN }} port-forward svc/agntcy-dir-apiserver -n peer3 8892:8888 &"
# Delay to ensure services are online
- sleep 10
deploy:kubernetes:network:port-forward:cleanup:
aliases: [deploy:network:port-forward:cleanup]
desc: Cleanup port-forwarding processes
cmds:
# Kill any existing port-forward processes for the agntcy-dir-apiserver service
- kill -9 $(ps aux | grep port-forward | grep agntcy-dir-apiserver | awk '{print $2}') || true
deploy:kubernetes:network:cleanup:
aliases: [deploy:network:cleanup]
desc: Cleanup Kubernetes environment for network deployment
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
# Delete helm releases
- for:
matrix:
PEER: ["bootstrap", "peer1", "peer2", "peer3"]
cmd: |
{{ .HELM_BIN }} delete --namespace {{ .ITEM.PEER }} agntcy-dir
- "{{ .KIND_BIN }} delete cluster --name {{ .KIND_CLUSTER_NAME }}"
##
## Test