- Avoid mangling whitespace by using gsub instead of assigning to
fields OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-docker_label_helper?expand=0&rev=6
This commit is contained in:
parent
536800aa7a
commit
1d91897f61
@ -19,8 +19,9 @@ if [ -e "${BUILD_DATA}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Note: Avoid assigning to $1 etc. as that converts whitespace (field separators) to single spaces.
|
||||
gawk -i inplace '
|
||||
match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
|
||||
labelprefix != "" && match($0, /^(PREFIXED)?LABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[2], m[3]; $1 = "LABEL" }
|
||||
labelprefix != "" && match($0, /^(PREFIXED)?LABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[2], m[3]; gsub(/^PREFIXEDLABEL/, "LABEL") }
|
||||
match($0, /^# endlabelprefix/) { labelprefix=""; next }
|
||||
1' Dockerfile
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 21 12:50:28 UTC 2022 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
- Avoid mangling whitespace by using gsub instead of assigning to
|
||||
fields
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Dec 15 14:52:19 UTC 2021 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package obs-service-docker_label_helper
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
|
18
test.sh
18
test.sh
@ -10,18 +10,21 @@ cd $tmpdir
|
||||
# Test old syntax
|
||||
cat >Dockerfile <<EOF
|
||||
# labelprefix=org.opensuse.nano
|
||||
PREFIXEDLABEL org.opencontainers.image.title="Example container"
|
||||
PREFIXEDLABEL org.opencontainers.image.title="Example container."
|
||||
PREFIXEDLABEL org.opencontainers.image.description="This contains nano"
|
||||
PREFIXEDLABEL test.whitespace="Two spaces. One tab."
|
||||
EOF
|
||||
|
||||
export BUILD_DIST=
|
||||
sh "${script}"
|
||||
|
||||
diff -u Dockerfile - <<EOF
|
||||
LABEL org.opensuse.nano.title="Example container"
|
||||
LABEL org.opencontainers.image.title="Example container"
|
||||
LABEL org.opensuse.nano.title="Example container."
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
LABEL org.opensuse.nano.description="This contains nano"
|
||||
LABEL org.opencontainers.image.description="This contains nano"
|
||||
LABEL org.opensuse.nano.whitespace="Two spaces. One tab."
|
||||
LABEL test.whitespace="Two spaces. One tab."
|
||||
EOF
|
||||
|
||||
rm -f Dockerfile
|
||||
@ -29,8 +32,9 @@ rm -f Dockerfile
|
||||
# Test new syntax
|
||||
cat >Dockerfile <<EOF
|
||||
# labelprefix=org.opensuse.nano
|
||||
LABEL org.opencontainers.image.title="Example container"
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
LABEL org.opencontainers.image.description="This contains nano"
|
||||
LABEL test.whitespace="Two spaces. One tab."
|
||||
# endlabelprefix
|
||||
LABEL not.expanded.label="example"
|
||||
EOF
|
||||
@ -39,9 +43,11 @@ export BUILD_DIST=
|
||||
sh "${script}"
|
||||
|
||||
diff -u Dockerfile - <<EOF
|
||||
LABEL org.opensuse.nano.title="Example container"
|
||||
LABEL org.opencontainers.image.title="Example container"
|
||||
LABEL org.opensuse.nano.title="Example container."
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
LABEL org.opensuse.nano.description="This contains nano"
|
||||
LABEL org.opencontainers.image.description="This contains nano"
|
||||
LABEL org.opensuse.nano.whitespace="Two spaces. One tab."
|
||||
LABEL test.whitespace="Two spaces. One tab."
|
||||
LABEL not.expanded.label="example"
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user