mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	Bash script syntax improvements
This commit is contained in:
		| @@ -37,12 +37,12 @@ top_level_models=$(grep '&[A-Za-z]*{},' /register.go | sed 's/.*&//;s/{},//') | |||||||
| VERSION="${1#*_}" | VERSION="${1#*_}" | ||||||
| for m in ${top_level_models} | for m in ${top_level_models} | ||||||
| do | do | ||||||
|   if grep -xq "=== ${VERSION}.$m" ./definitions.adoc |   if grep -xq "=== ${VERSION}.${m}" ./definitions.adoc | ||||||
|   then |   then | ||||||
|     buf+="* <<${VERSION}.$m>>\n" |     buf+="* <<${VERSION}.${m}>>\n" | ||||||
|   fi |   fi | ||||||
| done | done | ||||||
| sed -i "1i $buf" ./definitions.adoc | sed -i "1i ${buf}" ./definitions.adoc | ||||||
|  |  | ||||||
| # fix the links in .adoc, replace <<x.y>> with link:definitions.html#_x_y[x.y], and lowercase the _x_y part | # fix the links in .adoc, replace <<x.y>> with link:definitions.html#_x_y[x.y], and lowercase the _x_y part | ||||||
| sed -i -e 's|<<\(.*\)\.\(.*\)>>|link:#_\L\1_\2\E[\1.\2]|g' ./definitions.adoc | sed -i -e 's|<<\(.*\)\.\(.*\)>>|link:#_\L\1_\2\E[\1.\2]|g' ./definitions.adoc | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ set -o xtrace | |||||||
| # is an incoming variable Jenkins provides us for this job's scratch | # is an incoming variable Jenkins provides us for this job's scratch | ||||||
| # space. | # space. | ||||||
| export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | ||||||
| export PATH=$PATH:/usr/local/go/bin | export PATH=${PATH}:/usr/local/go/bin | ||||||
|  |  | ||||||
| # Skip gcloud update checking | # Skip gcloud update checking | ||||||
| export CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=true | export CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=true | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ set -o xtrace | |||||||
| # space. | # space. | ||||||
| export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | ||||||
| export GOPATH=${HOME}/_gopath | export GOPATH=${HOME}/_gopath | ||||||
| export PATH=${GOPATH}/bin:${HOME}/third_party/etcd:/usr/local/go/bin:$PATH | export PATH=${GOPATH}/bin:${HOME}/third_party/etcd:/usr/local/go/bin:${PATH} | ||||||
|  |  | ||||||
| # Install a few things needed by unit and /integration tests. | # Install a few things needed by unit and /integration tests. | ||||||
| command -v etcd &>/dev/null || ./hack/install-etcd.sh | command -v etcd &>/dev/null || ./hack/install-etcd.sh | ||||||
|   | |||||||
| @@ -139,9 +139,9 @@ function print_started() { | |||||||
|     # will be available as started["metadata"][KEY.lower()]. |     # will be available as started["metadata"][KEY.lower()]. | ||||||
|     echo "    \"metadata\": {" |     echo "    \"metadata\": {" | ||||||
|     local sep=""  # leading commas are easy to track |     local sep=""  # leading commas are easy to track | ||||||
|     for env_var in $metadata_keys; do |     for env_var in ${metadata_keys}; do | ||||||
|       local var_upper="${env_var#BUILD_METADATA_}" |       local var_upper="${env_var#BUILD_METADATA_}" | ||||||
|       echo "        $sep\"${var_upper,,}\": \"${!env_var}\"" |       echo "        ${sep}\"${var_upper,,}\": \"${!env_var}\"" | ||||||
|       sep="," |       sep="," | ||||||
|     done |     done | ||||||
|     echo "    }," |     echo "    }," | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ set -o xtrace | |||||||
|  |  | ||||||
| retry() { | retry() { | ||||||
|   for i in {1..5}; do |   for i in {1..5}; do | ||||||
|     "$@" && return 0 || sleep $i |     "$@" && return 0 || sleep "${i}" | ||||||
|   done |   done | ||||||
|   "$@" |   "$@" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ set -o xtrace | |||||||
| # space. | # space. | ||||||
| export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME | ||||||
| export GOPATH=${HOME}/_gopath | export GOPATH=${HOME}/_gopath | ||||||
| export PATH=${GOPATH}/bin:${HOME}/third_party/etcd:/usr/local/go/bin:$PATH | export PATH=${GOPATH}/bin:${HOME}/third_party/etcd:/usr/local/go/bin:${PATH} | ||||||
|  |  | ||||||
| # Install a few things needed by the verification tests. | # Install a few things needed by the verification tests. | ||||||
| command -v etcd &>/dev/null || ./hack/install-etcd.sh | command -v etcd &>/dev/null || ./hack/install-etcd.sh | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ kube::log::errexit() { | |||||||
|     kube::log::error "Call tree:" |     kube::log::error "Call tree:" | ||||||
|     for ((i=1;i<${#FUNCNAME[@]}-1;i++)) |     for ((i=1;i<${#FUNCNAME[@]}-1;i++)) | ||||||
|     do |     do | ||||||
|       kube::log::error " $i: ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]} ${FUNCNAME[$i]}(...)" |       kube::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)" | ||||||
|     done |     done | ||||||
|   fi   |   fi   | ||||||
|   kube::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err" "${1:-1}" 1 |   kube::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err" "${1:-1}" 1 | ||||||
| @@ -66,7 +66,7 @@ kube::log::stack() { | |||||||
|       local source_file=${BASH_SOURCE[$frame_no]} |       local source_file=${BASH_SOURCE[$frame_no]} | ||||||
|       local source_lineno=${BASH_LINENO[$((frame_no - 1))]} |       local source_lineno=${BASH_LINENO[$((frame_no - 1))]} | ||||||
|       local funcname=${FUNCNAME[$frame_no]} |       local funcname=${FUNCNAME[$frame_no]} | ||||||
|       echo "  $i: ${source_file}:${source_lineno} ${funcname}(...)" >&2 |       echo "  ${i}: ${source_file}:${source_lineno} ${funcname}(...)" >&2 | ||||||
|     done |     done | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										208
									
								
								hack/lib/test.sh
									
									
									
									
									
								
							
							
						
						
									
										208
									
								
								hack/lib/test.sh
									
									
									
									
									
								
							| @@ -76,25 +76,25 @@ kube::test::object_assert() { | |||||||
|   local args=${5:-} |   local args=${5:-} | ||||||
|  |  | ||||||
|   for j in $(seq 1 ${tries}); do |   for j in $(seq 1 ${tries}); do | ||||||
|     res=$(eval kubectl get "${kube_flags[@]}" ${args} $object -o go-template=\"$request\") |     res=$(eval kubectl get "${kube_flags[@]}" ${args} ${object} -o go-template=\"${request}\") | ||||||
|     if [[ "$res" =~ ^$expected$ ]]; then |     if [[ "${res}" =~ ^$expected$ ]]; then | ||||||
|         echo -n ${green} |         echo -n "${green}" | ||||||
|         echo "$(kube::test::get_caller 3): Successful get $object $request: $res" |         echo "$(kube::test::get_caller 3): Successful get ${object} ${request}: ${res}" | ||||||
|         echo -n ${reset} |         echo -n "${reset}" | ||||||
|         return 0 |         return 0 | ||||||
|     fi |     fi | ||||||
|     echo "Waiting for Get $object $request $args: expected: $expected, got: $res" |     echo "Waiting for Get ${object} ${request} ${args}: expected: ${expected}, got: ${res}" | ||||||
|     sleep $((${j}-1)) |     sleep $((${j}-1)) | ||||||
|   done |   done | ||||||
|  |  | ||||||
|   echo ${bold}${red} |   echo "${bold}${red}" | ||||||
|   echo "$(kube::test::get_caller 3): FAIL!" |   echo "$(kube::test::get_caller 3): FAIL!" | ||||||
|   echo "Get $object $request" |   echo "Get ${object} ${request}" | ||||||
|   echo "  Expected: $expected" |   echo "  Expected: ${expected}" | ||||||
|   echo "  Got:      $res" |   echo "  Got:      ${res}" | ||||||
|   echo ${reset}${red} |   echo "${reset}${red}" | ||||||
|   caller |   caller | ||||||
|   echo ${reset} |   echo "${reset}" | ||||||
|   return 1 |   return 1 | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -103,22 +103,22 @@ kube::test::get_object_jsonpath_assert() { | |||||||
|   local request=$2 |   local request=$2 | ||||||
|   local expected=$3 |   local expected=$3 | ||||||
|  |  | ||||||
|   res=$(eval kubectl get "${kube_flags[@]}" $object -o jsonpath=\"$request\") |   res=$(eval kubectl get "${kube_flags[@]}" ${object} -o jsonpath=\"${request}\") | ||||||
|  |  | ||||||
|   if [[ "$res" =~ ^$expected$ ]]; then |   if [[ "${res}" =~ ^$expected$ ]]; then | ||||||
|       echo -n ${green} |       echo -n "${green}" | ||||||
|       echo "$(kube::test::get_caller): Successful get $object $request: $res" |       echo "$(kube::test::get_caller): Successful get ${object} ${request}: ${res}" | ||||||
|       echo -n ${reset} |       echo -n "${reset}" | ||||||
|       return 0 |       return 0 | ||||||
|   else |   else | ||||||
|       echo ${bold}${red} |       echo "${bold}${red}" | ||||||
|       echo "$(kube::test::get_caller): FAIL!" |       echo "$(kube::test::get_caller): FAIL!" | ||||||
|       echo "Get $object $request" |       echo "Get ${object} ${request}" | ||||||
|       echo "  Expected: $expected" |       echo "  Expected: ${expected}" | ||||||
|       echo "  Got:      $res" |       echo "  Got:      ${res}" | ||||||
|       echo ${reset}${red} |       echo "${reset}${red}" | ||||||
|       caller |       caller | ||||||
|       echo ${reset} |       echo "${reset}" | ||||||
|       return 1 |       return 1 | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| @@ -128,27 +128,27 @@ kube::test::describe_object_assert() { | |||||||
|   local object=$2 |   local object=$2 | ||||||
|   local matches=${@:3} |   local matches=${@:3} | ||||||
|  |  | ||||||
|   result=$(eval kubectl describe "${kube_flags[@]}" $resource $object) |   result=$(eval kubectl describe "${kube_flags[@]}" ${resource} ${object}) | ||||||
|  |  | ||||||
|   for match in ${matches}; do |   for match in ${matches}; do | ||||||
|     if [[ ! $(echo "$result" | grep ${match}) ]]; then |     if [[ ! $(echo "${result}" | grep ${match}) ]]; then | ||||||
|       echo ${bold}${red} |       echo "${bold}${red}" | ||||||
|       echo "$(kube::test::get_caller): FAIL!" |       echo "$(kube::test::get_caller): FAIL!" | ||||||
|       echo "Describe $resource $object" |       echo "Describe ${resource} ${object}" | ||||||
|       echo "  Expected Match: $match" |       echo "  Expected Match: ${match}" | ||||||
|       echo "  Not found in:" |       echo "  Not found in:" | ||||||
|       echo "$result" |       echo "${result}" | ||||||
|       echo ${reset}${red} |       echo "${reset}${red}" | ||||||
|       caller |       caller | ||||||
|       echo ${reset} |       echo "${reset}" | ||||||
|       return 1 |       return 1 | ||||||
|     fi |     fi | ||||||
|   done |   done | ||||||
|  |  | ||||||
|   echo -n ${green} |   echo -n "${green}" | ||||||
|   echo "$(kube::test::get_caller): Successful describe $resource $object:" |   echo "$(kube::test::get_caller): Successful describe ${resource} ${object}:" | ||||||
|   echo "$result" |   echo "${result}" | ||||||
|   echo -n ${reset} |   echo -n "${reset}" | ||||||
|   return 0 |   return 0 | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -158,34 +158,34 @@ kube::test::describe_object_events_assert() { | |||||||
|     local showevents=${3:-"true"} |     local showevents=${3:-"true"} | ||||||
|  |  | ||||||
|     if [[ -z "${3:-}" ]]; then |     if [[ -z "${3:-}" ]]; then | ||||||
|         result=$(eval kubectl describe "${kube_flags[@]}" $resource $object) |         result=$(eval kubectl describe "${kube_flags[@]}" ${resource} ${object}) | ||||||
|     else |     else | ||||||
|         result=$(eval kubectl describe "${kube_flags[@]}" "--show-events=$showevents" $resource $object) |         result=$(eval kubectl describe "${kube_flags[@]}" "--show-events=${showevents}" ${resource} ${object}) | ||||||
|     fi |     fi | ||||||
|  |  | ||||||
|     if [[ -n $(echo "$result" | grep "No events.\|Events:") ]]; then |     if [[ -n $(echo "${result}" | grep "No events.\|Events:") ]]; then | ||||||
|         local has_events="true" |         local has_events="true" | ||||||
|     else |     else | ||||||
|         local has_events="false" |         local has_events="false" | ||||||
|     fi |     fi | ||||||
|     if [[ $showevents == $has_events ]]; then |     if [[ "${showevents}" == "${has_events}" ]]; then | ||||||
|         echo -n ${green} |         echo -n "${green}" | ||||||
|         echo "$(kube::test::get_caller): Successful describe" |         echo "$(kube::test::get_caller): Successful describe" | ||||||
|         echo "$result" |         echo "${result}" | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 0 |         return 0 | ||||||
|     else |     else | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "$(kube::test::get_caller): FAIL" |         echo "$(kube::test::get_caller): FAIL" | ||||||
|         if [[ $showevents == "false" ]]; then |         if [[ "${showevents}" == "false" ]]; then | ||||||
|             echo "  Events information should not be described in:" |             echo "  Events information should not be described in:" | ||||||
|         else |         else | ||||||
|             echo "  Events information not found in:" |             echo "  Events information not found in:" | ||||||
|         fi |         fi | ||||||
|         echo $result |         echo "${result}" | ||||||
|         echo ${reset}${red} |         echo "${reset}${red}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
| @@ -194,27 +194,27 @@ kube::test::describe_resource_assert() { | |||||||
|   local resource=$1 |   local resource=$1 | ||||||
|   local matches=${@:2} |   local matches=${@:2} | ||||||
|  |  | ||||||
|   result=$(eval kubectl describe "${kube_flags[@]}" $resource) |   result=$(eval kubectl describe "${kube_flags[@]}" ${resource}) | ||||||
|  |  | ||||||
|   for match in ${matches}; do |   for match in ${matches}; do | ||||||
|     if [[ ! $(echo "$result" | grep ${match}) ]]; then |     if [[ ! $(echo "${result}" | grep ${match}) ]]; then | ||||||
|       echo ${bold}${red} |       echo "${bold}${red}" | ||||||
|       echo "FAIL!" |       echo "FAIL!" | ||||||
|       echo "Describe $resource" |       echo "Describe ${resource}" | ||||||
|       echo "  Expected Match: $match" |       echo "  Expected Match: ${match}" | ||||||
|       echo "  Not found in:" |       echo "  Not found in:" | ||||||
|       echo "$result" |       echo "${result}" | ||||||
|       echo ${reset}${red} |       echo "${reset}${red}" | ||||||
|       caller |       caller | ||||||
|       echo ${reset} |       echo "${reset}" | ||||||
|       return 1 |       return 1 | ||||||
|     fi |     fi | ||||||
|   done |   done | ||||||
|  |  | ||||||
|   echo -n ${green} |   echo -n "${green}" | ||||||
|   echo "Successful describe $resource:" |   echo "Successful describe ${resource}:" | ||||||
|   echo "$result" |   echo "${result}" | ||||||
|   echo -n ${reset} |   echo -n "${reset}" | ||||||
|   return 0 |   return 0 | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -222,30 +222,30 @@ kube::test::describe_resource_events_assert() { | |||||||
|     local resource=$1 |     local resource=$1 | ||||||
|     local showevents=${2:-"true"} |     local showevents=${2:-"true"} | ||||||
|  |  | ||||||
|     result=$(eval kubectl describe "${kube_flags[@]}" "--show-events=$showevents" $resource) |     result=$(eval kubectl describe "${kube_flags[@]}" "--show-events=${showevents}" ${resource}) | ||||||
|  |  | ||||||
|     if [[ $(echo "$result" | grep "No events.\|Events:") ]]; then |     if [[ $(echo "${result}" | grep "No events.\|Events:") ]]; then | ||||||
|         local has_events="true" |         local has_events="true" | ||||||
|     else |     else | ||||||
|         local has_events="false" |         local has_events="false" | ||||||
|     fi |     fi | ||||||
|     if [[ $showevents == $has_events ]]; then |     if [[ "${showevents}" == "${has_events}" ]]; then | ||||||
|         echo -n ${green} |         echo -n "${green}" | ||||||
|         echo "Successful describe" |         echo "Successful describe" | ||||||
|         echo "$result" |         echo "${result}" | ||||||
|         echo -n ${reset} |         echo -n "${reset}" | ||||||
|         return 0 |         return 0 | ||||||
|     else |     else | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "FAIL" |         echo "FAIL" | ||||||
|         if [[ $showevents == "false" ]]; then |         if [[ "${showevents}" == "false" ]]; then | ||||||
|             echo "  Events information should not be described in:" |             echo "  Events information should not be described in:" | ||||||
|         else |         else | ||||||
|             echo "  Events information not found in:" |             echo "  Events information not found in:" | ||||||
|         fi |         fi | ||||||
|         echo $result |         echo "${result}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
| @@ -255,10 +255,10 @@ kube::test::if_sort_by_has_correct_order() { | |||||||
|   local array=($(echo "$1" |awk '{if(NR!=1) print $1}')) |   local array=($(echo "$1" |awk '{if(NR!=1) print $1}')) | ||||||
|   local var |   local var | ||||||
|   for i in "${array[@]}"; do |   for i in "${array[@]}"; do | ||||||
|     var+="$i:" |     var+="${i}:" | ||||||
|   done |   done | ||||||
|  |  | ||||||
|   kube::test::if_has_string "$var" "${@:$#}" |   kube::test::if_has_string "${var}" "${@:$#}" | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::if_has_string() { | kube::test::if_has_string() { | ||||||
| @@ -267,13 +267,13 @@ kube::test::if_has_string() { | |||||||
|  |  | ||||||
|   if grep -q "${match}" <<< "${message}"; then |   if grep -q "${match}" <<< "${message}"; then | ||||||
|     echo "Successful" |     echo "Successful" | ||||||
|     echo "message:$message" |     echo "message:${message}" | ||||||
|     echo "has:$match" |     echo "has:${match}" | ||||||
|     return 0 |     return 0 | ||||||
|   else |   else | ||||||
|     echo "FAIL!" |     echo "FAIL!" | ||||||
|     echo "message:$message" |     echo "message:${message}" | ||||||
|     echo "has not:$match" |     echo "has not:${match}" | ||||||
|     caller |     caller | ||||||
|     return 1 |     return 1 | ||||||
|   fi |   fi | ||||||
| @@ -285,22 +285,22 @@ kube::test::if_has_not_string() { | |||||||
|  |  | ||||||
|   if grep -q "${match}" <<< "${message}"; then |   if grep -q "${match}" <<< "${message}"; then | ||||||
|     echo "FAIL!" |     echo "FAIL!" | ||||||
|     echo "message:$message" |     echo "message:${message}" | ||||||
|     echo "has:$match" |     echo "has:${match}" | ||||||
|     caller |     caller | ||||||
|     return 1 |     return 1 | ||||||
|   else |   else | ||||||
|     echo "Successful" |     echo "Successful" | ||||||
|     echo "message:$message" |     echo "message:${message}" | ||||||
|     echo "has not:$match" |     echo "has not:${match}" | ||||||
|     return 0 |     return 0 | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::if_empty_string() { | kube::test::if_empty_string() { | ||||||
|   local match=$1 |   local match=$1 | ||||||
|   if [ -n "$match" ]; then |   if [ -n "${match}" ]; then | ||||||
|     echo "$match is not empty" |     echo "${match} is not empty" | ||||||
|     caller |     caller | ||||||
|     return 1 |     return 1 | ||||||
|   else |   else | ||||||
| @@ -332,26 +332,26 @@ kube::test::version::object_to_file() { | |||||||
|   name=$1 |   name=$1 | ||||||
|   flags=${2:-""} |   flags=${2:-""} | ||||||
|   file=$3 |   file=$3 | ||||||
|   kubectl version $flags | grep "$name Version:" | sed -e s/"$name Version: version.Info{"/'/' -e s/'}'/'/' -e s/', '/','/g -e s/':'/'=/g' -e s/'"'/""/g | tr , '\n' > "${file}" |   kubectl version ${flags} | grep "${name} Version:" | sed -e s/"${name} Version: version.Info{"/'/' -e s/'}'/'/' -e s/', '/','/g -e s/':'/'=/g' -e s/'"'/""/g | tr , '\n' > "${file}" | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::version::json_object_to_file() { | kube::test::version::json_object_to_file() { | ||||||
|   flags=$1 |   flags=$1 | ||||||
|   file=$2 |   file=$2 | ||||||
|   kubectl version $flags --output json | sed -e s/' '/''/g -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e s/'clientVersion:'/'clientVersion:,'/ -e s/'serverVersion:'/'serverVersion:,'/ | tr , '\n' > "${file}" |   kubectl version ${flags} --output json | sed -e s/' '/''/g -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e s/'clientVersion:'/'clientVersion:,'/ -e s/'serverVersion:'/'serverVersion:,'/ | tr , '\n' > "${file}" | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::version::json_client_server_object_to_file() { | kube::test::version::json_client_server_object_to_file() { | ||||||
|   flags=$1 |   flags=$1 | ||||||
|   name=$2 |   name=$2 | ||||||
|   file=$3 |   file=$3 | ||||||
|   kubectl version $flags --output json | jq -r ".${name}" | sed -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e /^$/d -e s/','/''/g  -e s/':'/'='/g > "${file}" |   kubectl version ${flags} --output json | jq -r ".${name}" | sed -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e /^$/d -e s/','/''/g  -e s/':'/'='/g > "${file}" | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::version::yaml_object_to_file() { | kube::test::version::yaml_object_to_file() { | ||||||
|   flags=$1 |   flags=$1 | ||||||
|   file=$2 |   file=$2 | ||||||
|   kubectl version $flags --output yaml | sed -e s/' '/''/g -e s/'\"'/''/g -e /^$/d > "${file}" |   kubectl version ${flags} --output yaml | sed -e s/' '/''/g -e s/'\"'/''/g -e /^$/d > "${file}" | ||||||
| } | } | ||||||
|  |  | ||||||
| kube::test::version::diff_assert() { | kube::test::version::diff_assert() { | ||||||
| @@ -361,63 +361,63 @@ kube::test::version::diff_assert() { | |||||||
|   local diff_msg=${4:-""} |   local diff_msg=${4:-""} | ||||||
|   local res="" |   local res="" | ||||||
|  |  | ||||||
|   if [ ! -f $original ]; then |   if [ ! -f "${original}" ]; then | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "FAIL! ${diff_msg}" |         echo "FAIL! ${diff_msg}" | ||||||
|         echo "the file '${original}' does not exit" |         echo "the file '${original}' does not exit" | ||||||
|         echo ${reset}${red} |         echo "${reset}${red}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
|   if [ ! -f $latest ]; then |   if [ ! -f "${latest}" ]; then | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "FAIL! ${diff_msg}" |         echo "FAIL! ${diff_msg}" | ||||||
|         echo "the file '${latest}' does not exit" |         echo "the file '${latest}' does not exit" | ||||||
|         echo ${reset}${red} |         echo "${reset}${red}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
|   sort ${original} > "${original}.sorted" |   sort ${original} > "${original}.sorted" | ||||||
|   sort ${latest} > "${latest}.sorted" |   sort ${latest} > "${latest}.sorted" | ||||||
|  |  | ||||||
|   if [ "$comparator" == "eq" ]; then |   if [ "${comparator}" == "eq" ]; then | ||||||
|     if [ "$(diff -iwB ${original}.sorted ${latest}.sorted)" == "" ] ; then |     if [ "$(diff -iwB ${original}.sorted ${latest}.sorted)" == "" ] ; then | ||||||
|         echo -n ${green} |         echo -n "${green}" | ||||||
|         echo "Successful: ${diff_msg}" |         echo "Successful: ${diff_msg}" | ||||||
|         echo -n ${reset} |         echo -n "${reset}" | ||||||
|         return 0 |         return 0 | ||||||
|     else |     else | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "FAIL! ${diff_msg}" |         echo "FAIL! ${diff_msg}" | ||||||
|         echo "  Expected: " |         echo "  Expected: " | ||||||
|         echo "$(cat ${original})" |         echo "$(cat ${original})" | ||||||
|         echo "  Got: " |         echo "  Got: " | ||||||
|         echo "$(cat ${latest})" |         echo "$(cat ${latest})" | ||||||
|         echo ${reset}${red} |         echo "${reset}${red}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|     fi |     fi | ||||||
|   else |   else | ||||||
|     if [ ! -z "$(diff -iwB ${original}.sorted ${latest}.sorted)" ] ; then |     if [ ! -z "$(diff -iwB ${original}.sorted ${latest}.sorted)" ] ; then | ||||||
|         echo -n ${green} |         echo -n "${green}" | ||||||
|         echo "Successful: ${diff_msg}" |         echo "Successful: ${diff_msg}" | ||||||
|         echo -n ${reset} |         echo -n "${reset}" | ||||||
|         return 0 |         return 0 | ||||||
|     else |     else | ||||||
|         echo ${bold}${red} |         echo "${bold}${red}" | ||||||
|         echo "FAIL! ${diff_msg}" |         echo "FAIL! ${diff_msg}" | ||||||
|         echo "  Expected: " |         echo "  Expected: " | ||||||
|         echo "$(cat ${original})" |         echo "$(cat ${original})" | ||||||
|         echo "  Got: " |         echo "  Got: " | ||||||
|         echo "$(cat ${latest})" |         echo "$(cat ${latest})" | ||||||
|         echo ${reset}${red} |         echo "${reset}${red}" | ||||||
|         caller |         caller | ||||||
|         echo ${reset} |         echo "${reset}" | ||||||
|         return 1 |         return 1 | ||||||
|       fi |       fi | ||||||
|   fi |   fi | ||||||
|   | |||||||
| @@ -115,14 +115,14 @@ if [ ${remote} = true ] ; then | |||||||
|   IFS=',' read -ra IM <<< "${images}" |   IFS=',' read -ra IM <<< "${images}" | ||||||
|        images="" |        images="" | ||||||
|        for i in "${IM[@]}"; do |        for i in "${IM[@]}"; do | ||||||
|          if [[ $(gcloud compute instances list "${instance_prefix}-$i" | grep ${i}) ]]; then |          if [[ $(gcloud compute instances list "${instance_prefix}-${i}" | grep ${i}) ]]; then | ||||||
|            if [[ ${hosts} != "" ]]; then |            if [[ "${hosts}" != "" ]]; then | ||||||
|              hosts="${hosts}," |              hosts="${hosts}," | ||||||
|            fi |            fi | ||||||
|            echo "Reusing host ${instance_prefix}-$i" |            echo "Reusing host ${instance_prefix}-${i}" | ||||||
|            hosts="${hosts}${instance_prefix}-${i}" |            hosts="${hosts}${instance_prefix}-${i}" | ||||||
|          else |          else | ||||||
|            if [[ ${images} != "" ]]; then |            if [[ "${images}" != "" ]]; then | ||||||
|              images="${images}," |              images="${images}," | ||||||
|            fi |            fi | ||||||
|            images="${images}${i}" |            images="${images}${i}" | ||||||
|   | |||||||
| @@ -55,7 +55,7 @@ API_LOGFILE=${API_LOGFILE:-/tmp/openapi-api-server.log} | |||||||
|  |  | ||||||
| kube::etcd::start | kube::etcd::start | ||||||
|  |  | ||||||
| echo "dummy_token,admin,admin" > $TMP_DIR/tokenauth.csv | echo "dummy_token,admin,admin" > ${TMP_DIR}/tokenauth.csv | ||||||
|  |  | ||||||
| # Start kube-apiserver | # Start kube-apiserver | ||||||
| kube::log::status "Starting kube-apiserver" | kube::log::status "Starting kube-apiserver" | ||||||
| @@ -67,7 +67,7 @@ kube::log::status "Starting kube-apiserver" | |||||||
|   --advertise-address="10.10.10.10" \ |   --advertise-address="10.10.10.10" \ | ||||||
|   --cert-dir="${TMP_DIR}/certs" \ |   --cert-dir="${TMP_DIR}/certs" \ | ||||||
|   --runtime-config="api/all=true" \ |   --runtime-config="api/all=true" \ | ||||||
|   --token-auth-file=$TMP_DIR/tokenauth.csv \ |   --token-auth-file="${TMP_DIR}/tokenauth.csv" \ | ||||||
|   --logtostderr \ |   --logtostderr \ | ||||||
|   --v=2 \ |   --v=2 \ | ||||||
|   --service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 & |   --service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 & | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ if (( ${KUBE_VERBOSE} >= 6 )); then | |||||||
| fi | fi | ||||||
|  |  | ||||||
| while getopts ":df" opt; do | while getopts ":df" opt; do | ||||||
|   case $opt in |   case ${opt} in | ||||||
|     d) # do not godep-restore into a temporary directory, but use the existing GOPATH |     d) # do not godep-restore into a temporary directory, but use the existing GOPATH | ||||||
|       DRY_RUN=true |       DRY_RUN=true | ||||||
|       ;; |       ;; | ||||||
| @@ -44,7 +44,7 @@ while getopts ":df" opt; do | |||||||
|       FAIL_ON_DIFF=true |       FAIL_ON_DIFF=true | ||||||
|       ;; |       ;; | ||||||
|     \?) |     \?) | ||||||
|       echo "Invalid option: -$OPTARG" >&2 |       echo "Invalid option: -${OPTARG}" >&2 | ||||||
|       exit 1 |       exit 1 | ||||||
|       ;; |       ;; | ||||||
|   esac |   esac | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ generate_pot="false" | |||||||
| generate_mo="false" | generate_mo="false" | ||||||
|  |  | ||||||
| while getopts "hf:xg" opt; do | while getopts "hf:xg" opt; do | ||||||
|   case $opt in |   case ${opt} in | ||||||
|     h) |     h) | ||||||
|       echo "$0 [-f files] [-x] [-g]" |       echo "$0 [-f files] [-x] [-g]" | ||||||
|       echo " -f <file-path>: Files to process" |       echo " -f <file-path>: Files to process" | ||||||
| @@ -78,10 +78,10 @@ fi | |||||||
| if [[ "${generate_mo}" == "true" ]]; then | if [[ "${generate_mo}" == "true" ]]; then | ||||||
|   echo "Generating .po and .mo files" |   echo "Generating .po and .mo files" | ||||||
|   for x in translations/*/*/*/*.po; do |   for x in translations/*/*/*/*.po; do | ||||||
|     msgcat -s $x > tmp.po |     msgcat -s ${x} > tmp.po | ||||||
|     mv tmp.po $x |     mv tmp.po ${x} | ||||||
|     echo "generating .mo file for: $x" |     echo "generating .mo file for: ${x}" | ||||||
|     msgfmt $x -o "$(dirname $x)/$(basename $x .po).mo" |     msgfmt ${x} -o "$(dirname ${x})/$(basename ${x} .po).mo" | ||||||
|   done |   done | ||||||
| fi | fi | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Roy Lenferink
					Roy Lenferink