From 1d5b98b524115e558e76ca75381cf53b38f81471 Mon Sep 17 00:00:00 2001 From: Francisco de Paz Galan Date: Fri, 24 Feb 2023 18:33:21 +0100 Subject: [PATCH] [bitnami/golang] Add VIB tests (#24157) * [bitnami/golang] Add VIB tests Signed-off-by: FraPazGal * Remove VIB trigger Signed-off-by: FraPazGal * Update pipelines' DSL definitions Signed-off-by: FraPazGal * Remove VIB trigger Signed-off-by: FraPazGal * Apply suggestions and launch verification Signed-off-by: FraPazGal * Remove VIB trigger Signed-off-by: FraPazGal --------- Signed-off-by: FraPazGal --- .vib/golang/goss/golang.yaml | 14 ++++++++++++++ .vib/golang/goss/goss.yaml | 9 +++++++++ .vib/golang/goss/vars.yaml | 3 +++ .vib/golang/vib-publish.json | 18 +++++++++++++++++- .vib/golang/vib-verify.json | 20 ++++++++++++++++++-- 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .vib/golang/goss/golang.yaml create mode 100644 .vib/golang/goss/goss.yaml create mode 100644 .vib/golang/goss/vars.yaml diff --git a/.vib/golang/goss/golang.yaml b/.vib/golang/goss/golang.yaml new file mode 100644 index 000000000000..795435245635 --- /dev/null +++ b/.vib/golang/goss/golang.yaml @@ -0,0 +1,14 @@ +command: + # Major and Minor versions are often shown as "x.0" and "x.y" instead of "x.0.0" and "x.y.0" + check-app-version: + exec: go version | grep "$(echo $APP_VERSION | sed -E 's|([0-9]+\.[0-9]+)\.0$|\1|g')" + exit-status: 0 + check-go-build: + {{- $filename := printf "test_%s" (randAlpha 5) }} + exec: | + echo 'package main; import "fmt"; func main() { fmt.Println("Hello VIB") }' > {{ $filename }}.go && \ + go build {{ $filename }}.go && \ + ./{{ $filename }} + exit-status: 0 + stdout: + - Hello VIB diff --git a/.vib/golang/goss/goss.yaml b/.vib/golang/goss/goss.yaml new file mode 100644 index 000000000000..45ebdb913d16 --- /dev/null +++ b/.vib/golang/goss/goss.yaml @@ -0,0 +1,9 @@ +gossfile: + # Goss tests exclusive to the current container + ../../golang/goss/golang.yaml: {} + # Load scripts from .vib/common/goss/templates + ../../common/goss/templates/check-binaries.yaml: {} + ../../common/goss/templates/check-broken-symlinks.yaml: {} + ../../common/goss/templates/check-ca-certs.yaml: {} + ../../common/goss/templates/check-linked-libraries.yaml: {} + ../../common/goss/templates/check-sed-in-place.yaml: {} diff --git a/.vib/golang/goss/vars.yaml b/.vib/golang/goss/vars.yaml new file mode 100644 index 000000000000..6ca44601b3f3 --- /dev/null +++ b/.vib/golang/goss/vars.yaml @@ -0,0 +1,3 @@ +binaries: + - go +root_dir: /opt/bitnami diff --git a/.vib/golang/vib-publish.json b/.vib/golang/vib-publish.json index f58738648055..ffcb77bfa719 100644 --- a/.vib/golang/vib-publish.json +++ b/.vib/golang/vib-publish.json @@ -3,7 +3,8 @@ "resources": { "url": "{VIB_ENV_CONTAINER_URL}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -33,6 +34,21 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "golang/goss/goss.yaml", + "vars_file": "golang/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-golang" + } + } + } + }, { "action_id": "trivy", "params": { diff --git a/.vib/golang/vib-verify.json b/.vib/golang/vib-verify.json index 835cd556e241..03a810b5e27a 100644 --- a/.vib/golang/vib-verify.json +++ b/.vib/golang/vib-verify.json @@ -3,7 +3,8 @@ "resources": { "url": "{SHA_ARCHIVE}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -29,6 +30,21 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "golang/goss/goss.yaml", + "vars_file": "golang/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-golang" + } + } + } + }, { "action_id": "trivy", "params": { @@ -50,4 +66,4 @@ ] } } -} \ No newline at end of file +}