Skip to content

Commit

Permalink
Use jq's IN() instead of index()
Browse files Browse the repository at this point in the history
The end result is the same, but the construction is more ergonomic.
  • Loading branch information
tianon committed Oct 16, 2024
1 parent a2995ab commit f9b92d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ENV HAPROXY_SHA256 {{ .sha256 }}
# Since 5.4 is supported on haproxy, better use it now, but only for
# newer versions since there could be some minor incompatibilities
# for existing scripts: https://www.lua.org/manual/5.4/manual.html#8
if ([ "2.2", "2.4", "2.6", "2.8" ] | index(env.version)) then
if env.version | IN("2.2", "2.4", "2.6", "2.8") then
"5.3"
else
"5.4"
Expand All @@ -81,7 +81,7 @@ RUN set -eux; \
pcre2-dev \
readline-dev \
tar \
{{ if ([ "2.2" ] | index(env.version)) then ( -}}
{{ if env.version == "2.2" then ( -}}
zlib-dev \
{{ ) else "" end -}}
; \
Expand All @@ -95,7 +95,7 @@ RUN set -eux; \
libssl-dev \
make \
wget \
{{ if ([ "2.2" ] | index(env.version)) then ( -}}
{{ if env.version == "2.2" then ( -}}
zlib1g-dev \
{{ ) else "" end -}}
; \
Expand All @@ -122,15 +122,15 @@ RUN set -eux; \
USE_LUA=1 LUA_INC=/usr/include/lua{{ lua }}{{ if env.variant == "alpine" then (" LUA_LIB=/usr/lib/lua" + lua) else "" end }} \
USE_OPENSSL=1 \
USE_PCRE2=1 USE_PCRE2_JIT=1 \
{{ if ([ "2.2" ] | index(env.version)) then ( -}}
{{ if env.version == "2.2" then ( -}}
USE_ZLIB=1 \
{{ ) else "" end -}}
{{ if ([ "2.2" ] | index(env.version) | not) then ( -}}
{{ if env.version == "2.2" then "" else ( -}}
USE_PROMEX=1 \
{{ ) else "" end -}}
{{ ) end -}}
\
EXTRA_OBJS=" \
{{ if [ "2.2" ] | index(env.version) then ( -}}
{{ if env.version == "2.2" then ( -}}
# see https://github.com/docker-library/haproxy/issues/94#issuecomment-505673353 for more details about prometheus support
contrib/prometheus-exporter/service-prometheus.o \
{{ ) else "" end -}}
Expand Down Expand Up @@ -188,12 +188,12 @@ RUN set -eux; \
STOPSIGNAL SIGUSR1

COPY docker-entrypoint.sh /usr/local/bin/
{{ if [ "2.2" ] | index(env.version) then ( -}}
{{ if env.version == "2.2" then ( -}}
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
{{ ) else "" end -}}
ENTRYPOINT ["docker-entrypoint.sh"]

{{ if [ "2.2" ] | index(env.version) then ( -}}
{{ if env.version == "2.2" then ( -}}
# no USER for backwards compatibility (to try to avoid breaking existing users)
{{ ) else ( -}}
USER haproxy
Expand Down
2 changes: 1 addition & 1 deletion versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for version in "${versions[@]}"; do
alpine: env.alpine,
}
# remove Alpine from versions where it cannot be built on any active Alpine release
| if [ "2.2" ] | index(env.version) then del(.alpine) else . end
| if env.version == "2.2" then del(.alpine) else . end
'
)"

Expand Down

0 comments on commit f9b92d6

Please sign in to comment.