|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
3 | 3 | CONTROLLER_TOOLS_VERSION="v0.7.0"
|
| 4 | +HELM_VERSION="v3.7" |
4 | 5 |
|
5 | 6 | # setting the -x option if debugging is true
|
6 | 7 | if [[ "${DEBUG:-"false"}" = "true" ]]; then
|
@@ -91,25 +92,41 @@ debug_msg() {
|
91 | 92 | echo "$__debug_prefix$__indent$__msg"
|
92 | 93 | }
|
93 | 94 |
|
94 |
| -# controller_gen_version_equals accepts a string version and returns 0 if the |
| 95 | +# k8s_controller_gen_version_equals accepts a string version and returns 0 if the |
95 | 96 | # installed version of controller-gen matches the supplied version, otherwise
|
96 | 97 | # returns 1
|
97 | 98 | #
|
98 | 99 | # Usage:
|
99 | 100 | #
|
100 |
| -# if controller_gen_version_equals "v0.4.0"; then |
| 101 | +# if k8s_controller_gen_version_equals "v0.4.0"; then |
101 | 102 | # echo "controller-gen is at version 0.4.0"
|
102 | 103 | # fi
|
103 | 104 | k8s_controller_gen_version_equals() {
|
104 |
| - currentver="$(controller-gen --version | cut -d' ' -f2 | tr -d '\n')"; |
105 |
| - requiredver="$1"; |
| 105 | + local currentver="$(controller-gen --version | cut -d' ' -f2 | tr -d '\n')"; |
| 106 | + local requiredver="$1"; |
106 | 107 | if [ "$currentver" = "$requiredver" ]; then
|
107 | 108 | return 0
|
108 | 109 | else
|
109 | 110 | return 1
|
110 | 111 | fi;
|
111 | 112 | }
|
112 | 113 |
|
| 114 | +# helm_version_equals_or_greater accepts a string version and returns 0 if the |
| 115 | +# installed version of helm matches or greater than the supplied version, |
| 116 | +# otherwise returns 1 |
| 117 | +# |
| 118 | +# Usage: |
| 119 | +# |
| 120 | +# if helm_version_equals_or_greater "v3.9.0"; then |
| 121 | +# echo "Installed helm version is greater than or equal to version v3.9.0" |
| 122 | +# fi |
| 123 | +helm_version_equals_or_greater() { |
| 124 | + local currentver="$(helm version --template='Version: {{.Version}}'| cut -d' ' -f2 | tr -d '\n')" |
| 125 | + local requiredver="$1" |
| 126 | + printf '%s\n%s\n' $requiredver $currentver | sort -C -V |
| 127 | + return $? |
| 128 | +} |
| 129 | + |
113 | 130 | # is_public_ecr_logged_in returns 0 if the Docker client is authenticated
|
114 | 131 | # with ECR public and therefore can pull and push to ECR public, otherwise
|
115 | 132 | # returns 1
|
|
0 commit comments