Accepting request 907921 from openSUSE:Tools
OBS-URL: https://build.opensuse.org/request/show/907921 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-docker_label_helper?expand=0&rev=2
This commit is contained in:
commit
4f4565a449
39
README
39
README
@ -2,7 +2,44 @@ obs-service-docker_label_helper
|
|||||||
===============================
|
===============================
|
||||||
|
|
||||||
This service can be enabled to run during buildtime, when it will edit the
|
This service can be enabled to run during buildtime, when it will edit the
|
||||||
Dockerfile to expand the PREFIXEDLABEL instruction.
|
Dockerfile to expand the LABEL instruction.
|
||||||
|
|
||||||
|
A new syntax using entry/exit flags has been introduced to provide
|
||||||
|
compatibility with stock docker build command while allowing OBS
|
||||||
|
to add its prefix to existing LABEL instructions values.
|
||||||
|
|
||||||
|
Both new and old syntax are supported, but you should not mix both in the
|
||||||
|
same Dockerfile.
|
||||||
|
|
||||||
|
1 - New syntax using entry/exit flags
|
||||||
|
|
||||||
|
Only LABEL between # labelprefix and # endlabelprefix will be considered
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
FROM opensuse/tumbleweed
|
||||||
|
# labelprefix=org.opensuse.nano
|
||||||
|
LABEL org.opencontainers.image.title="Example container"
|
||||||
|
LABEL org.opencontainers.image.description="This contains nano"
|
||||||
|
# endlabelprefix
|
||||||
|
LABEL not.expanded.label="example
|
||||||
|
```
|
||||||
|
|
||||||
|
expands to
|
||||||
|
|
||||||
|
```
|
||||||
|
FROM opensuse/tumbleweed
|
||||||
|
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 not.expanded.label="example"
|
||||||
|
```
|
||||||
|
|
||||||
|
2 - Old syntax
|
||||||
|
|
||||||
|
Expand the PREFIXEDLABEL instruction.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -21,5 +21,6 @@ fi
|
|||||||
|
|
||||||
gawk -i inplace '
|
gawk -i inplace '
|
||||||
match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
|
match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
|
||||||
labelprefix != "" && match($0, /^PREFIXEDLABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[1], m[2]; $1 = "LABEL" }
|
labelprefix != "" && match($0, /^(PREFIXED)?LABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[2], m[3]; $1 = "LABEL" }
|
||||||
|
match($0, /^# endlabelprefix/) { labelprefix=""; next }
|
||||||
1' Dockerfile
|
1' Dockerfile
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<service name="docker_label_helper">
|
<service name="docker_label_helper">
|
||||||
<summary>Allows automatic duplication of labels with a custom prefix.</summary>
|
<summary>Allows automatic duplication of labels with a custom prefix.</summary>
|
||||||
<description>Implements the PREFIXEDLABEL pseudo command for Dockerfile.</description>
|
<description>Expand LABEL instructions with mandatory openSUSE prefixes for Dockerfile.</description>
|
||||||
</service>
|
</service>
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jul 23 08:50:08 UTC 2021 - Bruno Leon <bruno.leon@suse.com>
|
||||||
|
|
||||||
|
- Improve regexp instead of having two as proposed by Fabian Vogt
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jul 21 10:38:53 UTC 2021 - Bruno Leon <bruno.leon@suse.com>
|
||||||
|
|
||||||
|
- Retain compatibility with old syntax. Update documentation.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 20 14:28:28 UTC 2021 - Bruno Leon <bruno.leon@suse.com>
|
||||||
|
|
||||||
|
- Use entry/exit point to determine whether labels should be expanded.
|
||||||
|
Doing so makes the Dockerfile compatible with standard
|
||||||
|
docker build command.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Sep 11 10:07:44 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
Fri Sep 11 10:07:44 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package obs-service-docker_label_helper
|
# spec file for package obs-service-docker_label_helper
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2021 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -33,8 +33,8 @@ BuildArch: noarch
|
|||||||
BuildRequires: diffutils
|
BuildRequires: diffutils
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This service can be used during buildtime to implement the
|
This service can be used during buildtime to expand LABEL
|
||||||
PREFIXEDLABEL instruction useful for building containers.
|
instructions with mandatory openSUSE prefixes.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -D -T -n .
|
%setup -q -D -T -n .
|
||||||
|
23
test.sh
23
test.sh
@ -7,6 +7,7 @@ script="$(realpath "$(dirname $0)")/docker_label_helper"
|
|||||||
|
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
|
|
||||||
|
# Test old syntax
|
||||||
cat >Dockerfile <<EOF
|
cat >Dockerfile <<EOF
|
||||||
# labelprefix=org.opensuse.nano
|
# labelprefix=org.opensuse.nano
|
||||||
PREFIXEDLABEL org.opencontainers.image.title="Example container"
|
PREFIXEDLABEL org.opencontainers.image.title="Example container"
|
||||||
@ -22,3 +23,25 @@ LABEL org.opencontainers.image.title="Example container"
|
|||||||
LABEL org.opensuse.nano.description="This contains nano"
|
LABEL org.opensuse.nano.description="This contains nano"
|
||||||
LABEL org.opencontainers.image.description="This contains nano"
|
LABEL org.opencontainers.image.description="This contains nano"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
rm -f Dockerfile
|
||||||
|
|
||||||
|
# Test new syntax
|
||||||
|
cat >Dockerfile <<EOF
|
||||||
|
# labelprefix=org.opensuse.nano
|
||||||
|
LABEL org.opencontainers.image.title="Example container"
|
||||||
|
LABEL org.opencontainers.image.description="This contains nano"
|
||||||
|
# endlabelprefix
|
||||||
|
LABEL not.expanded.label="example"
|
||||||
|
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.description="This contains nano"
|
||||||
|
LABEL org.opencontainers.image.description="This contains nano"
|
||||||
|
LABEL not.expanded.label="example"
|
||||||
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user