11version : 3
22
3- # Environment variables that are shared across tasks.
4- env :
5- REGISTRY_NETWORK : barman-cloud-plugin
3+ vars :
64 REGISTRY_NAME : registry.barman-cloud-plugin
5+ REGISTRY_NETWORK : barman-cloud-plugin
6+ REGISTRY_EXTERNAL_PORT : ' {{ default 5000 .REGISTRY_EXTERNAL_PORT }}'
77 REGISTRY_PORT : 5000
88 DAGGER_ENGINE_CONTAINER_NAME : e2e-dagger-engine
99
@@ -78,78 +78,47 @@ tasks:
7878 sources :
7979 - ./**/*.go
8080
81- generate-certs :
82- desc : Generate certificates for the local registry
83- run : once
84- cmds :
85- - >
86- mkdir -p certs &&
87- pushd certs &&
88- openssl genrsa -out ca-key.pem 4096 &&
89- openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem \
90- -subj "/O=CloudNativePG/OU=Barman Cloud Plugin Testing" &&
91- openssl genrsa -out server-key.pem 4096 &&
92- openssl req -subj "/CN=${REGISTRY_NAME}" -sha256 -new -key server-key.pem -out server.csr &&
93- echo subjectAltName = DNS:${REGISTRY_NAME},IP:127.0.0.1 >> extfile.cnf &&
94- echo extendedKeyUsage = serverAuth >> extfile.cnf &&
95- openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
96- -CAcreateserial -out server-cert.pem -extfile extfile.cnf &&
97- popd
98- status :
99- - test -f certs/ca-key.pem
100- - test -f certs/ca.pem
101- - test -f certs/server-key.pem
102- - test -f certs/server.csr
103- - test -f certs/server-cert.pem
104-
10581 start-build-network :
10682 desc : Create a docker network for image building used by the dagger engine and the registry
10783 run : once
10884 cmds :
109- - docker network create ${ REGISTRY_NETWORK}
85+ - docker network create {{ . REGISTRY_NETWORK } }
11086 status :
111- - docker network inspect ${ REGISTRY_NETWORK}
87+ - docker network inspect {{ . REGISTRY_NETWORK } }
11288
11389 start-registry :
11490 desc : Start a container registry
11591 run : once
11692 deps :
117- - generate-certs
11893 - start-build-network
119- env :
94+ vars :
12095 # TODO: renovate
12196 REGISTRY_VERSION : 2
12297 cmds :
12398 - >
124- docker run -d --name ${REGISTRY_NAME}
125- -p ${REGISTRY_PORT}:5000
126- --network ${REGISTRY_NETWORK}
127- -v $(pwd)/certs:/certs
128- -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server-cert.pem -e REGISTRY_HTTP_TLS_KEY=/certs/server-key.pem
129- registry:${REGISTRY_VERSION}
99+ docker run -d --name {{ .REGISTRY_NAME }}
100+ --network {{ .REGISTRY_NETWORK }}
101+ -p {{ .REGISTRY_EXTERNAL_PORT }}:{{ .REGISTRY_PORT }}
102+ registry:{{ .REGISTRY_VERSION }}
130103 status :
131- - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${ REGISTRY_NAME}" 2> /dev/null )" == 'true' \]
104+ - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ . REGISTRY_NAME } }" 2> /dev/null )" == 'true' \]
132105
133-
134- # Start a dagger engine that mounts the CA certificate for the local registry.
106+ # Start a dagger engine that can use the local registry.
135107 start-dagger-engine-for-local-builds :
136- desc : Start a dagger engine mounting the CA
108+ desc : Start a dagger engine
137109 run : once
138- deps :
139- - generate-certs
140- - start-build-network
141110 vars :
142111 # renovate: datasource=github-tags depName=dagger/dagger versioning=semver
143112 DAGGER_VERSION : 0.15.1
144113 DAGGER_ENGINE_IMAGE : registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
145114 cmds :
146115 - >
147- docker run -d -v /var/lib/dagger --name "${ DAGGER_ENGINE_CONTAINER_NAME}"
148- --network=${REGISTRY_NETWORK}
149- -v $(pwd)/certs/ca.pem:/usr/local/share/ca-certificates/ca.crt
116+ docker run -d -v /var/lib/dagger --name "{{ . DAGGER_ENGINE_CONTAINER_NAME } }"
117+ -v $(pwd)/hack/dagger-engine.toml:/etc/dagger/engine.toml
118+ --network {{ .REGISTRY_NETWORK }}
150119 --privileged {{ .DAGGER_ENGINE_IMAGE }}
151120 status :
152- - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${ DAGGER_ENGINE_CONTAINER_NAME}" 2> /dev/null )" == 'true' \]
121+ - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ . DAGGER_ENGINE_CONTAINER_NAME } }" 2> /dev/null )" == 'true' \]
153122
154123 # We build an image and push it to a local registry.
155124 # The name is always `plugin-barman-cloud:testing`.
@@ -161,12 +130,19 @@ tasks:
161130 env :
162131 # renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
163132 DAGGER_DOCKER_SHA : 14c1374e5878f082939aab575c36cdad19920e0d
164- _EXPERIMENTAL_DAGGER_RUNNER_HOST : docker-container://{{.DAGGER_ENGINE_CONTAINER_NAME}}
133+ _EXPERIMENTAL_DAGGER_RUNNER_HOST : docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
165134 cmds :
166135 - >
167136 GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
168137 build --dir . --file containers/Dockerfile.plugin --platform linux/amd64
169- publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/plugin-barman-cloud --tags testing
138+ publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/plugin-barman-cloud --tags testing
139+ sources :
140+ - ./go.mod
141+ - ./go.sum
142+ - ./containers/Dockerfile.plugin
143+ - ./**/*.go
144+ - ./Taskfile.yml
145+ - exclude : ./test/e2e/**
170146
171147 # We build an image and push it to a local registry.
172148 # The name is always `sidecar-barman-cloud:testing`.
@@ -183,7 +159,14 @@ tasks:
183159 - >
184160 GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
185161 build --dir . --file containers/Dockerfile.sidecar --platform linux/amd64
186- publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/sidecar-barman-cloud --tags testing
162+ publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/sidecar-barman-cloud --tags testing
163+ sources :
164+ - ./go.mod
165+ - ./go.sum
166+ - ./containers/Dockerfile.sidecar
167+ - ./**/*.go
168+ - ./Taskfile.yml
169+ - exclude : ./test/e2e/**
187170
188171 build-images :
189172 desc : Build the container images for the plugin
@@ -194,11 +177,6 @@ tasks:
194177 # TODO: see if it is possible to daggerize this. It will have to manage docker to make kind work.
195178 # TODO: add a task to clean up the kind cluster for new test runs.
196179 # Run the e2e tests. This task will start a kind cluster, deploy the plugin, and run the tests.
197- # Running the e2e tests requires:
198- # * The registry to have a valid TLS certificate.
199- # * The registry to be in the same network of the dagger-engine.
200- # * The dagger-engine to mount the CA.
201- # * The kind cluster to mount the CA.
202180 e2e :
203181 desc : Run e2e tests
204182 deps :
0 commit comments