File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -132,14 +132,29 @@ data "external" "talosctl_version_check" {
132132 " sh" , " -c" , <<- EOT
133133 set -eu
134134
135+ parse() {
136+ case $1 in
137+ *[vV][0-9]*.[0-9]*.[0-9]*)
138+ v=$${1##*[vV]}
139+ maj=$${v%%.*}
140+ r=$${v#*.}
141+ min=$${r%%.*}
142+ patch=$${r#*.}
143+ patch=$${patch%%[^0-9]*}
144+ printf '%s %s %s\n' "$maj" "$min" "$patch"
145+ return 0
146+ ;;
147+ esac
148+ return 1
149+ }
150+
135151 parsed_version=$(
136- talosctl version --client --short | while IFS= read -r line; do
137- case $line in
138- *[vV][0-9]*.[0-9]*.[0-9]*)
139- v=$${line##*[vV]}; maj=$${v%%.*}; r=$${v#*.}; min=$${r%%.*}; patch=$${r#*.}
140- printf '%s %s %s\n' "$maj" "$min" "$patch"; break
141- ;;
142- esac
152+ talosctl version --client --short |
153+ while IFS= read -r line; do
154+ if out=$(parse "$line"); then
155+ printf '%s\n' "$out"
156+ break
157+ fi
143158 done
144159 )
145160 [ -n "$parsed_version" ] || { echo "Could not parse talosctl client version" >&2; exit 1; }
@@ -153,7 +168,7 @@ data "external" "talosctl_version_check" {
153168 exit 1
154169 fi
155170
156- echo "{\"talosctl_version\": \"$major.$minor.$patch\"}"
171+ printf '%s\n' "{\"talosctl_version\": \"$major.$minor.$patch\"}"
157172 EOT
158173 ]
159174}
You can’t perform that action at this time.
0 commit comments