-
-
Save l0rd/ab40dfe1c5dd014ab00820356b974119 to your computer and use it in GitHub Desktop.
devfile-registry-nodejs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
DEVFILES_DIR="$(pwd)/stacks" | |
# The stacks to test as a string separated by spaces | |
STACKS=$("$(pwd)/tests/get_stacks.sh") | |
replaceVariables() { | |
image=$1 | |
VAR_KEYS=(liberty-version) | |
VAR_VALUES=(22.0.0.1) | |
for i in "${!VAR_KEYS[@]}"; do | |
key='{{' | |
key+=${VAR_KEYS[i]} | |
key+='}}' | |
value=${VAR_VALUES[i]} | |
image=${image/${key}/${value}} | |
done | |
echo "$image" | |
} | |
getContainerComponentsNum() { | |
devfilePath=$1 | |
component_num=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | length' "$devfilePath" -r) | |
echo "${component_num}" | |
} | |
getName() { | |
devfilePath=$1 | |
name=$($YQ_PATH eval '.metadata.name' "$devfilePath" -r) | |
echo "${name}" | |
} | |
getFirstContainerComponentImage() { | |
devfilePath=$1 | |
image_original=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.image' "$devfilePath" -r) | |
image_processed=$(replaceVariables "${image_original}") | |
echo "${image_processed}" | |
} | |
hasNode() { | |
_int_image=$1 | |
echo " PARAMS: image --> $_int_image" | |
if podman run -ti --rm $_int_image which node >/dev/null 2>&1; then | |
echo " SUCCESS: The image has node" | |
# return 0 | |
else | |
echo " ERROR: The image doesn't have node" | |
# return 1 | |
fi | |
} | |
YQ_PATH=${YQ_PATH:-yq} | |
TEST_NAMESPACE=${TEST_NAMESPACE:-default} | |
if [ -z "${ENV:-}" ]; then | |
ENV=minikube | |
fi | |
if [ "$ENV" != "minikube" ] && [ "$ENV" != "openshift" ]; then | |
echo "ERROR:: Allowed values for ENV are either \"minikube\" (default) or \"openshift\"." | |
exit 1 | |
fi | |
for stack in $STACKS; do | |
devfile_path="$DEVFILES_DIR/$stack/devfile.yaml" | |
if [ ! -f "$devfile_path" ]; then | |
echo "WARN: Devfile not found at path $devfile_path" | |
continue | |
fi | |
echo "=======================" | |
echo "Testing ${devfile_path}" | |
IFS=" " read -r -a components_num <<<"$(getContainerComponentsNum "$devfile_path")" | |
# components_num=($(getContainerComponentsNum "$devfile_path")) | |
# if there are zero components of type container skip | |
if ((components_num = 0)); then | |
echo "WARNING: Devfile with no container component found (""$devfile_path""). Skipping." | |
echo "=======================" | |
continue | |
fi | |
# if there is more than one component of type container skip (we may want to cover this case in the future) | |
if ((components_num > 1)); then | |
echo "WARNING: Devfile with more than one container component found (""$devfile_path""). Skipping." | |
echo "=======================" | |
continue | |
fi | |
name=$(getName "$devfile_path") | |
image=$(getFirstContainerComponentImage "$devfile_path") | |
hasNode "${image}" | |
echo "=======================" | |
done | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./tests/check_nodejs.sh | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-nextjs/1.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-nextjs/1.0.3/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-wildfly/devfile.yaml | |
PARAMS: image --> quay.io/wildfly/wildfly-centos7:26.1 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs/2.1.1/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs/2.2.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-quarkus/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/openjdk-17 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/php-laravel/devfile.yaml | |
PARAMS: image --> quay.io/devfile/composer:2.4 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/go/2.0.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi9/go-toolset:1.18.9-14 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/go/1.0.2/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi9/go-toolset:1.18.9-14 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-nuxtjs/1.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-nuxtjs/1.0.3/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-vue/1.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-vue/1.0.2/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/python/3.0.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi9/python-39:1-108 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/python/2.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi9/python-39:1-108 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-websphereliberty/devfile.yaml | |
PARAMS: image --> icr.io/appcafe/websphere-liberty-devfile-stack:22.0.0.1 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/python-django/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi9/python-39:1-108 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/dotnet50/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/dotnet-50:5.0 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-vertx/devfile.yaml | |
PARAMS: image --> quay.io/eclipse/che-java11-maven:next | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-springboot/2.0.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/openjdk-11:latest | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-springboot/1.2.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/openjdk-11:latest | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-react/2.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-react/2.0.2/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/dotnet60/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/dotnet-60:6.0 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-svelte/1.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-svelte/1.0.3/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-websphereliberty-gradle/devfile.yaml | |
PARAMS: image --> icr.io/appcafe/websphere-liberty-devfile-stack:22.0.0.1-gradle | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-openliberty-gradle/devfile.yaml | |
PARAMS: image --> icr.io/appcafe/open-liberty-devfile-stack:22.0.0.1-gradle | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-openliberty/devfile.yaml | |
PARAMS: image --> icr.io/appcafe/open-liberty-devfile-stack:22.0.0.1 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-angular/2.1.0/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-18:1-32 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/nodejs-angular/2.0.2/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/nodejs-16:latest | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-wildfly-bootable-jar/devfile.yaml | |
PARAMS: image --> quay.io/jaegertracing/all-in-one:1.27 | |
ERROR: The image doesn't have node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/dotnetcore31/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/dotnet-31:3.1 | |
SUCCESS: The image has node | |
======================= | |
======================= | |
Testing /Users/mloriedo/Git/devfileio-registry/stacks/java-maven/devfile.yaml | |
PARAMS: image --> registry.access.redhat.com/ubi8/openjdk-11:latest | |
ERROR: The image doesn't have node | |
======================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment