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
7- REGISTRY_PORT : 5000
5+ REGISTRY_PORT : 5001
86 DAGGER_ENGINE_CONTAINER_NAME : e2e-dagger-engine
97
108tasks :
@@ -78,78 +76,36 @@ tasks:
7876 sources :
7977 - ./**/*.go
8078
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-
105- start-build-network :
106- desc : Create a docker network for image building used by the dagger engine and the registry
107- run : once
108- cmds :
109- - docker network create ${REGISTRY_NETWORK}
110- status :
111- - docker network inspect ${REGISTRY_NETWORK}
112-
11379 start-registry :
11480 desc : Start a container registry
11581 run : once
116- deps :
117- - generate-certs
118- - start-build-network
119- env :
82+ vars :
12083 # TODO: renovate
12184 REGISTRY_VERSION : 2
12285 cmds :
12386 - >
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}
87+ docker run -d --name {{ .REGISTRY_NAME }}
88+ -p {{ .REGISTRY_PORT }}:5000
89+ registry:{{ .REGISTRY_VERSION }}
13090 status :
131- - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${REGISTRY_NAME}" 2> /dev/null )" == 'true' \]
132-
91+ - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .REGISTRY_NAME }}" 2> /dev/null )" == 'true' \]
13392
134- # Start a dagger engine that mounts the CA certificate for the local registry.
93+ # Start a dagger engine that can use the local registry.
13594 start-dagger-engine-for-local-builds :
136- desc : Start a dagger engine mounting the CA
95+ desc : Start a dagger engine
13796 run : once
138- deps :
139- - generate-certs
140- - start-build-network
14197 vars :
14298 # renovate: datasource=github-tags depName=dagger/dagger versioning=semver
14399 DAGGER_VERSION : 0.15.1
144100 DAGGER_ENGINE_IMAGE : registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
145101 cmds :
146102 - >
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
103+ docker run -d -v /var/lib/dagger --name "{{ . DAGGER_ENGINE_CONTAINER_NAME } }"
104+ -v $(pwd)/hack/dagger-engine.toml:/etc/dagger/engine.toml
105+ --add-host "{{ .REGISTRY_NAME }}:host-gateway"
150106 --privileged {{ .DAGGER_ENGINE_IMAGE }}
151107 status :
152- - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "${ DAGGER_ENGINE_CONTAINER_NAME}" 2> /dev/null )" == 'true' \]
108+ - \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ . DAGGER_ENGINE_CONTAINER_NAME } }" 2> /dev/null )" == 'true' \]
153109
154110 # We build an image and push it to a local registry.
155111 # The name is always `plugin-barman-cloud:testing`.
@@ -161,12 +117,19 @@ tasks:
161117 env :
162118 # renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
163119 DAGGER_DOCKER_SHA : 14c1374e5878f082939aab575c36cdad19920e0d
164- _EXPERIMENTAL_DAGGER_RUNNER_HOST : docker-container://{{.DAGGER_ENGINE_CONTAINER_NAME}}
120+ _EXPERIMENTAL_DAGGER_RUNNER_HOST : docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
165121 cmds :
166122 - >
167123 GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
168124 build --dir . --file containers/Dockerfile.plugin --platform linux/amd64
169- publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/plugin-barman-cloud --tags testing
125+ publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/plugin-barman-cloud --tags testing
126+ sources :
127+ - ./go.mod
128+ - ./go.sum
129+ - ./containers/Dockerfile.plugin
130+ - ./**/*.go
131+ - ./Taskfile.yml
132+ - exclude : ./test/e2e/**
170133
171134 # We build an image and push it to a local registry.
172135 # The name is always `sidecar-barman-cloud:testing`.
@@ -183,7 +146,14 @@ tasks:
183146 - >
184147 GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
185148 build --dir . --file containers/Dockerfile.sidecar --platform linux/amd64
186- publish --ref ${REGISTRY_NAME}:${REGISTRY_PORT}/sidecar-barman-cloud --tags testing
149+ publish --ref {{ .REGISTRY_NAME }}:{{ .REGISTRY_PORT }}/sidecar-barman-cloud --tags testing
150+ sources :
151+ - ./go.mod
152+ - ./go.sum
153+ - ./containers/Dockerfile.sidecar
154+ - ./**/*.go
155+ - ./Taskfile.yml
156+ - exclude : ./test/e2e/**
187157
188158 build-images :
189159 desc : Build the container images for the plugin
@@ -194,11 +164,6 @@ tasks:
194164 # TODO: see if it is possible to daggerize this. It will have to manage docker to make kind work.
195165 # TODO: add a task to clean up the kind cluster for new test runs.
196166 # 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.
202167 e2e :
203168 desc : Run e2e tests
204169 deps :
0 commit comments