File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
3
function version() {
4
- # get version from image
5
- version=$( \
6
- oc status | grep ' ^pod' | \
7
- sed -n -r -e ' s/.*([[:digit:]]+\.[[:digit:]]+(:?\.[[:digit:]])?(:?-[^@]+)?).*/\1/p' \
8
- )
9
4
10
- # if version not found, fallback to imageID
11
- [ -z " ${version} " ] && version= $ ( oc status | grep ' ^ pod.*runs ' | sed -r -e ' s/^pod.*runs // ' )
5
+ # get gather container image and imageID
6
+ read -r image imageID < < ( oc get pod ${POD_NAME} -o jsonpath= ' {range .status.containerStatuses[?(@.name=="gather")]}{.image} {.imageID}{end} ' )
12
7
13
- # if version still not found, use Unknown
8
+ # attempt to get semantic-like version from image
9
+ version=$( echo ${image} | sed -n -r -e ' s/.*:([[:digit:]]+\.[[:digit:]]+(:?\.[[:digit:]])?(:?-[^@]+)?).*/\1/p' )
10
+
11
+ # if version is not set, fallback to imageID
12
+ [ -z " ${version} " ] && version=${imageID}
13
+
14
+ # if version still not set, use Unknown
14
15
[ -z " ${version} " ] && version=" Unknown"
15
16
16
17
echo ${version}
You can’t perform that action at this time.
0 commit comments