File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
+ export IMAGE=$( oc status | grep ' ^pod' )
2
3
3
4
function version() {
4
5
# get version from image (major.minor.micro, e.g. v4.11.0)
5
- version=v$( \
6
- oc status | grep ' ^pod' | \
7
- sed -n -r -e ' s/.*(([[:digit:]])+\.([[:digit:]])+\.([[:digit:]])+).*/\1/p' \
8
- )
9
- # if version not found, fallback to imageID
10
- [ -z " ${version} " ] && version=$( oc status | grep ' ^pod.*runs' | sed -r -e ' s/^pod.*runs //' )
6
+ version=v$( sed -n -r -e ' s/.*(([[:digit:]])+\.([[:digit:]])+\.([[:digit:]])+).*/\1/p' <<< $IMAGE )
7
+
8
+ # if version is still not found, use 0.0.0-unknown
9
+ [ -z " ${version} " ] && version=" 0.0.0-unknown"
11
10
12
- # if version still not found, use Unknown
13
- [ -z " ${version} " ] && version=" Unknown"
14
11
echo ${version}
15
12
}
16
13
17
14
function imageId() {
18
- # get imageId (e.g. repository@digest )
19
- imageId=$( oc status | grep ' ^pod' | sed -r -e ' s/^pod.*runs //' | awk ' {print $2}' )
15
+ # get image id (e.g. repository@digest )
16
+ imageId=$( sed -r -e ' s/^pod.*runs //' <<< $IMAGE | awk ' {print $2}' )
17
+
18
+ # if image_id is not found, use Unknown
19
+ [ -z " ${imageId} " ] && imageId=" Unknown-Image"
20
20
21
- # if imageId is not found, use Unknown
22
- [ -z " ${imageId} " ] && imageId=" Unknown"
23
21
echo ${imageId}
24
22
25
23
}
You can’t perform that action at this time.
0 commit comments