plugin-barman-cloud/Taskfile.yml
Tao Li 6d0c1e2840
ci(e2e): migrate e2e test to kind cluster
Signed-off-by: Tao Li <tao.li@enterprisedb.com>
2026-08-31 20:03:15 +08:00

569 lines
24 KiB
YAML

version: 3
# We have multiple parallel tasks that run for a long time. Prefix their output with the task name so we can understand
# what task is writing.
output: prefixed
# Variables that are shared across tasks.
vars:
GO_VERSION:
sh: sed -n 's/^toolchain go//p' go.mod | grep . || sed -n 's/^go //p' go.mod
# renovate: datasource=docker depName=kindest/node versioning=semver
E2E_KUBERNETES_VERSION: v1.37.0
E2E_CLUSTER_NAME: barman-cloud-plugin-e2e-{{.E2E_KUBERNETES_VERSION}}
REGISTRY_NETWORK: barman-cloud-plugin
REGISTRY_NAME: '{{ .REGISTRY_NAME | default "registry.dev" }}'
REGISTRY_PORT: '{{ .REGISTRY_PORT | default 5000 }}'
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY | default "cloudnative-pg/plugin-barman-cloud"}}'
DAGGER_ENGINE_CONTAINER_NAME: e2e-dagger-engine
tasks:
####################################
## ALL
####################################
all:ci:
desc: Run the CI pipeline
deps:
- core:ci
####################################
## CORE
####################################
core:ci:
desc: Run the CI core pipeline
deps:
- internal:spellcheck
- internal:commitlint
- internal:uncommitted
- internal:lint
- internal:go-test
- documentation:docusaurus-build-test
- documentation:docusaurus-version-is-aligned
# run the go linters
core:lint:
desc: Run the linters
deps:
- internal:lint
# run the go linters
core:uncommitted:
desc: Check for uncommitted changes
deps:
- internal:uncommitted
# run the spellcheck
core:spellcheck:
desc: Run the spellcheck
deps:
- internal:spellcheck
# Generate the manifest from the current branch
core:manifest:
desc: Generate the manifest to be uploaded to the release or as a workflow artifact
deps:
- internal:controller-gen
vars:
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY | default "cloudnative-pg/plugin-barman-cloud"}}'
CURRENT_BRANCH:
sh: git rev-parse --abbrev-ref HEAD
GITHUB_REF: '{{.GITHUB_REF | default (printf "refs/heads/%s" .CURRENT_BRANCH)}}'
GITHUB_REF_NAME: '{{.GITHUB_REF_NAME | default .CURRENT_BRANCH}}'
cmds:
- task: internal:manifest
vars:
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY}}'
GITHUB_REF: '{{.GITHUB_REF}}'
GITHUB_REF_NAME: '{{.GITHUB_REF_NAME}}'
core:go-test:
desc: Run the Go tests
deps:
- internal:go-test
core:publish:
desc: Publish the container images
requires:
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
# to prevent running this task locally by accident.
vars:
- CI
- REGISTRY_USER
- REGISTRY_PASSWORD
vars:
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY | default "cloudnative-pg/plugin-barman-cloud"}}'
CURRENT_BRANCH:
sh: git rev-parse --abbrev-ref HEAD
GITHUB_REF: '{{.GITHUB_REF | default (printf "refs/heads/%s" .CURRENT_BRANCH)}}'
GITHUB_REF_NAME: '{{.GITHUB_REF_NAME | default .CURRENT_BRANCH}}'
cmds:
- task: internal:publish
vars:
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY}}'
GITHUB_REF: '{{.GITHUB_REF}}'
GITHUB_REF_NAME: '{{.GITHUB_REF_NAME}}'
REGISTRY_USER: '{{.REGISTRY_USER}}'
REGISTRY_PASSWORD: '{{.REGISTRY_PASSWORD}}'
core:upload-manifest-to-release:
desc: Upload the manifest to the release
requires:
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
# to prevent running this task locally by accident.
vars:
- CI
- GITHUB_TOKEN
env:
# renovate: datasource=git-refs depName=gh lookupName=https://github.com/sagikazarmark/daggerverse
DAGGER_GH_SHA: ff27cd50f6b4eed2e3753c520632cd6099e1ce52
preconditions:
- sh: "[[ {{.GITHUB_REF}} =~ 'refs/tags/v.*' ]]"
msg: not a tag, failing
vars:
GITHUB_REPOSITORY: '{{.GITHUB_REPOSITORY | default "cloudnative-pg/plugin-barman-cloud"}}'
CURRENT_BRANCH:
sh: git rev-parse --abbrev-ref HEAD
GITHUB_REF: '{{.GITHUB_REF | default (printf "refs/heads/%s" .CURRENT_BRANCH)}}'
GITHUB_REF_NAME: '{{.GITHUB_REF_NAME | default .CURRENT_BRANCH}}'
cmds:
- >
GITHUB_REF= dagger -s call -m github.com/sagikazarmark/daggerverse/gh@${DAGGER_GH_SHA}
with-source --source .
run --repo {{.GITHUB_REPOSITORY}} --token env:GITHUB_TOKEN
--cmd "release upload {{.GITHUB_REF_NAME}} manifest.yaml"
core:build-images:
desc: Build the container images for the plugin
deps:
- internal:build-plugin-image
- internal:build-sidecar-image
####################################
## INTERNAL
####################################
internal:lint:
desc: Run golangci-lint
env:
# renovate: datasource=git-refs depName=golangci-lint lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
DAGGER_GOLANGCI_LINT_SHA: ff27cd50f6b4eed2e3753c520632cd6099e1ce52
# renovate: datasource=docker depName=golangci/golangci-lint versioning=docker
GOLANGCI_LINT_VERSION: v2.13.2
internal: true
cmds:
- >
GITHUB_REF= dagger -sc "github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA}
--version ${GOLANGCI_LINT_VERSION} |
run . --config .golangci.yml | stdout"
sources:
- ./**/*.go
internal:wordlist-ordered:
desc: Order the word list file
internal: true
cmds:
- LANG=C LC_ALL=C sort .wordlist.txt > .wordlist.txt.new
- mv -f .wordlist.txt.new .wordlist.txt
sources:
- .wordlist.txt
internal:spellcheck:
desc: Run spellcheck
deps:
- internal:wordlist-ordered
env:
# renovate: datasource=git-refs depName=spellcheck lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
DAGGER_SPELLCHECK_SHA: 26cd57fb6ad66e88c036b675b0478d38df93962d
internal: true
cmds:
- >
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/spellcheck@${DAGGER_SPELLCHECK_SHA}
spellcheck --source . with-exec --use-entrypoint --args="" stdout
sources:
- ./**/*.md
- .spellcheck.yaml
- .wordlist.txt
internal:commitlint:
desc: Check for conventional commits
env:
# renovate: datasource=git-refs depName=commitlint lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
DAGGER_COMMITLINT_SHA: 26cd57fb6ad66e88c036b675b0478d38df93962d
internal: true
cmds:
- >
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/commitlint@${DAGGER_COMMITLINT_SHA}
lint --source . --args "--from=origin/main" stdout
internal:uncommitted:
desc: Check for uncommitted changes
deps:
- task: internal:manifest
vars:
GITHUB_REPOSITORY: cloudnative-pg/plugin-barman-cloud
GITHUB_REF: main
GITHUB_REF_NAME: main
- documentation:apidoc
- internal:wordlist-ordered
env:
# renovate: datasource=git-refs depName=uncommitted lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
DAGGER_UNCOMMITTED_SHA: 26cd57fb6ad66e88c036b675b0478d38df93962d
internal: true
cmds:
- GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/uncommitted@${DAGGER_UNCOMMITTED_SHA} check-uncommitted --source . stdout
sources:
- ./**
internal:go-test:
desc: Run go test
env:
# renovate: datasource=git-refs depName=kubernetes packageName=https://github.com/kubernetes/kubernetes versioning=semver
K8S_VERSION: 1.31.0
# renovate: datasource=git-refs depName=controller-runtime packageName=https://github.com/kubernetes-sigs/controller-runtime versioning=semver
SETUP_ENVTEST_VERSION: 0.24.1
internal: true
cmds:
- >
GITHUB_REF= dagger -s call -m ./dagger/gotest
--go-version {{.GO_VERSION}}
--kube-version ${K8S_VERSION}
--setup-envtest-version ${SETUP_ENVTEST_VERSION}
unit-test --src .
stdout
sources:
- ./**/*.go
internal:generate-certs:
desc: Generate certificates for the local registry
internal: true
run: once
cmds:
- >
mkdir -p certs &&
docker volume create certs &&
docker run -v certs:/certs -w /certs --name certs --entrypoint=/bin/sh alpine/openssl -c '
openssl genrsa -out ca-key.pem 4096 &&
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem \
-subj "/O=CloudNativePG/OU=Barman Cloud Plugin Testing" &&
openssl genrsa -out server-key.pem 4096 &&
openssl req -subj "/CN={{ .REGISTRY_NAME }}" -sha256 -new -key server-key.pem -out server.csr &&
echo subjectAltName = DNS:{{ .REGISTRY_NAME }},IP:127.0.0.1 >> extfile.cnf &&
echo extendedKeyUsage = serverAuth >> extfile.cnf &&
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
-CAcreateserial -out server-cert.pem -extfile extfile.cnf'
docker cp certs:/certs/ca.pem certs/ca.pem &&
docker rm certs
status:
- docker volume inspect certs
- test -f certs/ca.pem
internal:start-build-network:
desc: Create a docker network for image building used by the dagger engine and the registry
run: once
internal: true
cmds:
- docker network create {{ .REGISTRY_NETWORK}}
status:
- docker network inspect {{ .REGISTRY_NETWORK }}
internal:start-registry:
desc: Start a container registry
run: once
internal: true
deps:
- internal:generate-certs
- internal:start-build-network
env:
# renovate: datasource=docker depName=registry versioning=semver
REGISTRY_VERSION: 2
cmds:
- >
docker run -d --name {{ .REGISTRY_NAME }}
-p {{ .REGISTRY_PORT }}:5000
--network {{ .REGISTRY_NETWORK }}
-v certs:/certs
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server-cert.pem -e REGISTRY_HTTP_TLS_KEY=/certs/server-key.pem
registry:${REGISTRY_VERSION}
status:
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .REGISTRY_NAME }}" 2> /dev/null )" == 'true' \]
internal:registry-network-connect:
desc: Make sure the registry is connected to the registry network
summary: If we started the registry on our own, it should already be connected. However, if the registry was started
somewhere else, it may not be on the expected network.
internal: true
deps:
- internal:start-registry
run: once
cmds:
- docker network connect {{ .REGISTRY_NETWORK }} {{ .REGISTRY_NAME }} || true
status:
- docker network inspect {{ .REGISTRY_NETWORK }} -f '{{ range .Containers }}{{ .Name }} {{ end }}' | grep "{{ .REGISTRY_NAME }}"
# We build an image and push it to a local registry.
# The name is always `plugin-barman-cloud:testing`.
internal:build-plugin-image:
desc: Build the operator container image for the plugin using the local Docker engine
internal: true
deps:
- internal:registry-network-connect
cmds:
- >
dagger run docker buildx build -f containers/Dockerfile.plugin --build-arg GO_VERSION={{.GO_VERSION}}
--tag localhost:{{.REGISTRY_PORT}}/plugin-barman-cloud:testing --push .
# We build an image and push it to a local registry.
# The name is always `sidecar-barman-cloud:testing`.
internal:build-sidecar-image:
desc: Build the sidecar container image for the plugin using the local Docker engine
internal: true
deps:
- internal:registry-network-connect
cmds:
- >
dagger run docker buildx build -f containers/Dockerfile.sidecar --build-arg GO_VERSION={{.GO_VERSION}}
--tag localhost:{{.REGISTRY_PORT}}/sidecar-barman-cloud:testing --push .
internal:publish:
desc: Build and publish a container image for the plugin
requires:
vars:
- GITHUB_REPOSITORY
- GITHUB_REF
- GITHUB_REF_NAME
- REGISTRY_USER
- REGISTRY_PASSWORD
vars:
PLUGIN_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
SIDECAR_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}-sidecar{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
# remove /merge suffix from the branch name. This is a workaround for the GitHub workflow on PRs,
# where the branch name is suffixed with /merge. Prepend pr- to the branch name on PRs.
# Any remaining "/" (e.g. from namespaced branches like "dev/foo") is replaced with "-" since
# "/" is not a valid character in a Docker tag.
IMAGE_VERSION: '{{replace "/" "-" (regexReplaceAll "(\\d+)/merge" .GITHUB_REF_NAME "pr-${1}")}}'
env:
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
DAGGER_DOCKER_SHA: ee12c1a4a2630e194ec20c5a9959183e3a78c192
internal: true
cmds:
- >
GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
--registry ghcr.io --username $REGISTRY_USER --password env:REGISTRY_PASSWORD
build --dir . --file containers/Dockerfile.plugin --args GO_VERSION={{.GO_VERSION}} --platform linux/amd64 --platform linux/arm64
publish --ref {{.PLUGIN_IMAGE_NAME}} --tags {{.IMAGE_VERSION}}
- >
GITHUB_REF= dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
--registry ghcr.io --username $REGISTRY_USER --password env:REGISTRY_PASSWORD
build --dir . --file containers/Dockerfile.sidecar --args GO_VERSION={{.GO_VERSION}} --platform linux/amd64 --platform linux/arm64
publish --ref {{.SIDECAR_IMAGE_NAME}} --tags {{.IMAGE_VERSION}}
internal:controller-gen:
desc: Run controller-gen
run: once
env:
# renovate: datasource=git-refs depName=controller-gen lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
DAGGER_CONTROLLER_GEN_SHA: 26cd57fb6ad66e88c036b675b0478d38df93962d
internal: true
cmds:
- >
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/controller-gen@${DAGGER_CONTROLLER_GEN_SHA}
controller-gen --source . --args object:headerFile=hack/boilerplate.go.txt --args paths=./api/...
file --path api/v1/zz_generated.deepcopy.go export --path api/v1/zz_generated.deepcopy.go
- >
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/controller-gen@${DAGGER_CONTROLLER_GEN_SHA}
controller-gen --source . --args rbac:roleName=plugin-barman-cloud --args crd --args webhook
--args paths=./api/... --args paths=./internal/... --args output:crd:artifacts:config=config/crd/bases
directory --path config/
filter --include crd/bases/,rbac/
export --path config/
sources:
- ./api/**/*.go
- ./internal/**/*.go
generates:
- ./api/v1/zz_generated.deepcopy.go
- ./config/rbac/role.yaml
- ./config/crd/bases/*.yaml
internal:manifest:
desc: Update the image in the Kustomization
label: manifest-internal-{{.GITHUB_REF_NAME}}
internal: true
requires:
vars:
- GITHUB_REPOSITORY
- GITHUB_REF
- GITHUB_REF_NAME
vars:
PLUGIN_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
SIDECAR_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}-sidecar{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
# remove /merge suffix from the branch name. This is a workaround for the GitHub workflow on PRs,
# where the branch name is suffixed with /merge. Prepend pr- to the branch name on PRs.
# Any remaining "/" (e.g. from namespaced branches like "dev/foo") is replaced with "-" since
# "/" is not a valid character in a Docker tag.
IMAGE_VERSION: '{{replace "/" "-" (regexReplaceAll "(\\d+)/merge" .GITHUB_REF_NAME "pr-${1}")}}'
env:
# renovate: datasource=git-refs depName=kustomize lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
DAGGER_KUSTOMIZE_SHA: ff27cd50f6b4eed2e3753c520632cd6099e1ce52
cmds:
- >
GITHUB_REF= dagger -s call -m https://github.com/sagikazarmark/daggerverse/kustomize@${DAGGER_KUSTOMIZE_SHA}
edit --source . --dir kubernetes
set image --image plugin-barman-cloud={{.PLUGIN_IMAGE_NAME}}:{{.IMAGE_VERSION}}
set secret --secret plugin-barman-cloud --from-literal SIDECAR_IMAGE={{.SIDECAR_IMAGE_NAME}}:{{.IMAGE_VERSION}}
directory directory --path kubernetes export --path manifest-build
- >
GITHUB_REF= dagger -s call -m github.com/sagikazarmark/daggerverse/kustomize@${DAGGER_KUSTOMIZE_SHA}
build --source . --dir manifest-build export --path manifest.yaml
sources:
- ./config/**/*.yaml
- ./kubernetes/**/*.yaml
generates:
- ./manifest.yaml
internal:clean:
desc: Remove autogenerated artifacts
internal: true
cmds:
- rm -rf .task/
####################################
## DOCUMENTATION
####################################
documentation:apidoc:
desc: Update the API Reference section of the documentation
deps:
- internal:controller-gen
env:
# renovate: datasource=git-refs depName=crd-gen-refs lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
DAGGER_CRDGENREF_SHA: 7174b66d283da487638a98b431b7707b311a9a32
# renovate: datasource=go depName=github.com/elastic/crd-ref-docs
CRDREFDOCS_VERSION: v0.3.0
cmds:
- >
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/crd-ref-docs@${DAGGER_CRDGENREF_SHA}
--version ${CRDREFDOCS_VERSION}
generate
--src .
--source-path api/v1
--config-file hack/crd-gen-refs/config.yaml
--renderer markdown
--templates-dir hack/crd-gen-refs/markdown
file --path out.md
export --path web/docs/plugin-barman-cloud.v1.md
sources:
- ./api/**/*.go
- ./hack/docs/crd-gen-refs/**/*
- ./Taskfile.yml
documentation:docusaurus-build-test:
desc: Check that the documentation builds
deps:
- documentation:apidoc
env:
# renovate: datasource=git-refs depName=docusaurus lookupName=https://github.com/levlaz/daggerverse currentValue=main
DAGGER_DOCUSAURUS_SHA: 93f57fccbd5afd22fa917107ab7697f3e7db0e5a
cmds:
- GITHUB_REF= dagger -s call -m github.com/levlaz/daggerverse/docusaurus@${DAGGER_DOCUSAURUS_SHA}
--src web --yarn build
sources:
- ./web/**/*
documentation:docusaurus-version-is-aligned:
desc: Verify that a documentation version exists for the current version of the plugin
cmds:
- $(GITHUB_REF= dagger -s call -m dagger/check-doc-version has-version-documentation --src .)
sources:
- .release-please-manifest.json
- ./web/versions.json
####################################
## integration
####################################
# Deploy the plugin-barman-cloud to kind cluster
# To use KIND_CLUSTER_NAME=pg-operator-e2e-v1-33-1 task integration:deploy-to-kind
integration:deploy-to-kind:
desc: Deploy the operator on a kind cluster generated by the CNPG hack setup script
summary: |
Deploys the plugin-barman-cloud operator to a Kind cluster for integration testing. This task assumes a
Kind cluster has been previously created by the CloudNativePG hack/setup-cluster.sh script. It loads
the appropriate kubeconfig and applies the operator manifest via kustomize.
deps:
- internal:build-plugin-image
- internal:build-sidecar-image
run: once
requires:
vars:
- KIND_CLUSTER_NAME
vars:
KUBECONFIG_PATH:
sh: mktemp -t kubeconfig-XXXXX
KIND_HOSTPORT:
# This command extracts the host port for the control plane of the Kind cluster.
# Redundant curly braces are used to escape the template syntax in Taskfile.
sh: docker inspect --format '{{"{{"}} (index (index .HostConfig.PortBindings "6443/tcp") 0).HostPort {{"}}"}}' {{ .KIND_CLUSTER_NAME }}-control-plane
PLUGIN_IMAGE_REPOSITORY: '{{ .PLUGIN_IMAGE_REPOSITORY | default (printf "%s:%s/plugin-barman-cloud" .REGISTRY_NAME .REGISTRY_PORT) }}'
PLUGIN_IMAGE_TAG: '{{ .PLUGIN_IMAGE_TAG | default "testing" }}'
SIDECAR_IMAGE_REPOSITORY: '{{ .SIDECAR_IMAGE_REPOSITORY | default (printf "%s:%s/sidecar-barman-cloud" .REGISTRY_NAME .REGISTRY_PORT) }}'
SIDECAR_IMAGE_TAG: '{{ .SIDECAR_IMAGE_TAG | default "testing" }}'
# renovate: datasource=docker depName=alpine/k8s versioning=docker
ALPINE_K8S_VERSION: 1.36.2@sha256:44ef4942e171939b9c665a4a84beb80e2dcdb9a24330d4651cfdfd2e9deecc47
# renovate: datasource=github-releases depName=cert-manager/cert-manager versioning=semver
CERT_MANAGER_VERSION: v1.21.1
# Cache busting timestamp to prevent Dagger from caching the deployment steps
CACHE_BUST:
sh: date +%s
cmds:
- kind get kubeconfig --name {{ .KIND_CLUSTER_NAME }} > {{ .KUBECONFIG_PATH }}
- |
dagger shell << "."
container | from alpine/k8s:{{ .ALPINE_K8S_VERSION }} | with-mounted-file /kube/.config $(host | file {{ .KUBECONFIG_PATH }}) |
with-directory /src . |
with-env-variable KUBECONFIG /kube/.config |
with-service-binding localhost tcp://127.0.0.1:{{ .KIND_HOSTPORT }} |
with-exec -- sh -c "kubectl config set-cluster kind-{{ .KIND_CLUSTER_NAME }} --server=https://localhost:{{ .KIND_HOSTPORT }}" |
with-exec -- sh -c "kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/{{ .CERT_MANAGER_VERSION }}/cert-manager.yaml" |
with-exec -- sh -c "kubectl wait --for=condition=Available --timeout=120s -n cert-manager deployment --all" |
with-env-variable CACHE_BUST {{ .CACHE_BUST }} |
with-workdir /src/kubernetes |
with-exec -- sh -c "kustomize edit set image plugin-barman-cloud={{ .PLUGIN_IMAGE_REPOSITORY }}:{{ .PLUGIN_IMAGE_TAG }}" |
with-exec -- sh -c "kustomize edit set secret plugin-barman-cloud --from-literal=SIDECAR_IMAGE={{ .SIDECAR_IMAGE_REPOSITORY }}:{{ .SIDECAR_IMAGE_TAG }}" |
with-exec -- sh -c "kustomize build . | kubectl apply -f -"
.
- rm -f {{ .KUBECONFIG_PATH }}
integration:e2e:
desc: Run the e2e tests
deps:
- integration:deploy-to-kind
run: once
requires:
vars:
- KIND_CLUSTER_NAME
vars:
KUBECONFIG_PATH:
sh: mktemp -t kubeconfig-XXXXX
KIND_HOSTPORT:
# This command extracts the host port for the control plane of the Kind cluster.
# Redundant curly braces are used to escape the template syntax in Taskfile.
sh: docker inspect --format '{{"{{"}} (index (index .HostConfig.PortBindings "6443/tcp") 0).HostPort {{"}}"}}' {{ .KIND_CLUSTER_NAME }}-control-plane
cmds:
- kind get kubeconfig --name {{ .KIND_CLUSTER_NAME }} > {{ .KUBECONFIG_PATH }}
# kind writes the external server address as https://127.0.0.1:<port>, which is only valid on
# the host. Rewrite it to the "kubernetes" alias that --svc below binds inside the dagger container.
- >
sed -i.bak "s#server: https://[^:]*:[0-9]*#server: https://kubernetes:{{ .KIND_HOSTPORT }}#" {{ .KUBECONFIG_PATH }}
- >
GITHUB_REF= dagger call -m dagger/e2e/ run
--source .
--kubeconfig {{.KUBECONFIG_PATH}}
--svc tcp://127.0.0.1:{{.KIND_HOSTPORT}}
--go-version {{.GO_VERSION}}
- rm -f {{ .KUBECONFIG_PATH }} {{ .KUBECONFIG_PATH }}.bak