Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove jq dependency #78

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF \

ENV KUBE_LATEST_VERSION="v1.25.4"

RUN apk add --update --no-cache ca-certificates=20220614-r0 curl=7.83.1-r4 jq=1.6-r1 \
RUN apk add --update --no-cache ca-certificates=20220614-r0 curl=7.83.1-r4 \
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/$TARGETARCH/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl

Expand Down
13 changes: 12 additions & 1 deletion wait_for.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,18 @@ get_pod_state() {
# example output with 2 services each matching a single pod would be: "falsefalse"
get_service_state() {
get_service_state_name="$1"
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)
if [ "$get_service_state_name" != "" ] ; then
# this guarantees that kubectl will always return .items as a top key
get_service_state_name=" --field-selector metadata.name=$get_service_state_name"
fi
get_service_state_selectors=$(kubectl get service $get_service_state_name $KUBECTL_ARGS -o go-template='
{{ $first := true }}
{{- range .items -}}
{{- range $key, $value := .spec.selector -}}
{{- if not $first}},{{else}}{{$first = false}}{{end -}}
{{- printf "%s=%s" $key $value -}}
{{- end -}}
{{- end -}}' 2>&1)
if [ $? -ne 0 ]; then
echo "$get_service_state_selectors" >&2
kill -s TERM $TOP_PID
Expand Down
Loading