Skip to content

Commit 237ebca

Browse files
committed
remove jq dependency
1 parent 79b1f15 commit 237ebca

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF \
1414

1515
ENV 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

wait_for.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,18 @@ get_pod_state() {
132132
# example output with 2 services each matching a single pod would be: "falsefalse"
133133
get_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

0 commit comments

Comments
 (0)