From 3c7f095e3ac46ad3a8cb838196c132dbdde975be Mon Sep 17 00:00:00 2001 From: Michal Drla Date: Tue, 1 Feb 2022 10:18:25 +0100 Subject: [PATCH] feat(byon): Create task and pipeline resource for image validation Signed-off-by: Michal Drla --- charts/meteor-pipelines/Chart.yaml | 2 +- .../byon-validate-jupyterhub-image.yaml | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 charts/meteor-pipelines/templates/byon-validate-jupyterhub-image.yaml diff --git a/charts/meteor-pipelines/Chart.yaml b/charts/meteor-pipelines/Chart.yaml index 9f20d06..cf233e3 100644 --- a/charts/meteor-pipelines/Chart.yaml +++ b/charts/meteor-pipelines/Chart.yaml @@ -5,7 +5,7 @@ icon: https://avatars.githubusercontent.com/u/33906690?v=4 type: application -version: 0.2.4 +version: 0.2.5 appVersion: "1.0.0" sources: diff --git a/charts/meteor-pipelines/templates/byon-validate-jupyterhub-image.yaml b/charts/meteor-pipelines/templates/byon-validate-jupyterhub-image.yaml new file mode 100644 index 0000000..d58d3a4 --- /dev/null +++ b/charts/meteor-pipelines/templates/byon-validate-jupyterhub-image.yaml @@ -0,0 +1,47 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: byon-validate-jupyterhub-image +spec: + params: + - name: url + results: + - name: python-runtime + description: Python runtime + - name: pip-packages + description: Packages installed in runtime + - name: message + description: Messages passed down from task + steps: + - name: jupyter-book-build + image: $(params.url) + script: | + #!/usr/bin/env bash + + # Default values for easier handling when error occurs + echo -n "" > $(results.message.path) + echo -n "[]" > $(results.python-runtime.path) + echo -n "[]" > $(results.pip-packages.path) + + # Check Python versionand + echo "Validating image:" + + # Check if Python was found, if not save that information to a message + if command -v python >/dev/null; then + version=$(python --version | cut -d ' ' -f 2) + echo -n "[{\"name\":\"Python\",\"version\":\"$version\"}]" > $(results.python-runtime.path) + echo " Python: $version" + else + echo " Python: Not available" + echo "{\"severity\":\"error\",\"message\":\"Python not found\"}" >> $(results.message.path) + fi + + # Check if Pip was found, if not save that information to a message + if command -v pip >/dev/null; then + echo -n $(pip list --disable-pip-version-check --not-required --format json) > $(results.pip-packages.path) + echo -n " Packages: " + echo $(pip list --disable-pip-version-check --not-required --format=freeze) + else + echo " Packages: Not available" + echo "{\"severity\":\"error\",\"message\":\"Pip not found\"}" >> $(results.message.path) + fi