github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/scripts/get-name-from-managedosversion (about) 1 #!/bin/bash 2 3 # This script returns the OS version/channel name from ManagedOSVersion 4 5 set -e -x 6 7 # Variables 8 typeset -l KIND_OF_OS=$1 9 typeset -l CHECK_FOR_ISO=$2 10 typeset INVERTED="| not" 11 typeset GREP_OPTS="-v" 12 13 # Define if we check for stable or unstable OS 14 case ${KIND_OF_OS} in 15 dev|staging) 16 unset INVERTED 17 ;; 18 esac 19 20 # Define if we have to check for ISO image or not 21 [[ -n "${CHECK_FOR_ISO}" ]] && unset GREP_OPTS 22 23 # Get the value 24 VALUE=$(kubectl get ManagedOSVersion --namespace ${CLUSTER_NS} -o json 2>/dev/null \ 25 | jq -r ".items[] | select(.spec.metadata.displayName | contains(\"unstable\")${INVERTED}).metadata.name" 2>/dev/null \ 26 | grep ${GREP_OPTS} '\-iso' \ 27 | sort \ 28 | tail -1) 29 30 # Return VALUE without \n 31 echo -n ${VALUE}