File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF \
1414
1515ENV KUBE_LATEST_VERSION="v1.25.4"
1616
17- RUN apk add --update --no-cache ca-certificates=20220614-r0 curl=7.83.1-r4 jq=1.6-r1 \
17+ RUN apk add --update --no-cache ca-certificates=20220614-r0 curl=7.83.1-r4 \
1818 && curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/$TARGETARCH/kubectl -o /usr/local/bin/kubectl \
1919 && chmod +x /usr/local/bin/kubectl
2020
Original file line number Diff line number Diff line change @@ -132,7 +132,18 @@ get_pod_state() {
132132# example output with 2 services each matching a single pod would be: "falsefalse"
133133get_service_state () {
134134 get_service_state_name=" $1 "
135- get_service_state_selectors=$( kubectl get service " $get_service_state_name " $KUBECTL_ARGS -ojson | jq -cr ' if . | has("items") then .items[] else . end | [ .spec.selector | to_entries[] | "\(.key)=\(.value)" ] | join(",") ' 2>&1 )
135+ if [ " $get_service_state_name " != " " ] ; then
136+ # this guarantees that kubectl will always return .items as a top key
137+ get_service_state_name=" --field-selector metadata.name=$get_service_state_name "
138+ fi
139+ get_service_state_selectors=$( kubectl get service $get_service_state_name $KUBECTL_ARGS -o go-template='
140+ {{ $first := true }}
141+ {{- range .items -}}
142+ {{- range $key, $value := .spec.selector -}}
143+ {{- if not $first}},{{else}}{{$first = false}}{{end -}}
144+ {{- printf "%s=%s" $key $value -}}
145+ {{- end -}}
146+ {{- end -}}' 2>&1 )
136147 if [ $? -ne 0 ]; then
137148 echo " $get_service_state_selectors " >&2
138149 kill -s TERM $TOP_PID
You can’t perform that action at this time.
0 commit comments