Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package obs-service-docker_label_helper for 
openSUSE:Factory checked in at 2021-07-23 23:41:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/obs-service-docker_label_helper (Old)
 and      /work/SRC/openSUSE:Factory/.obs-service-docker_label_helper.new.1899 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "obs-service-docker_label_helper"

Fri Jul 23 23:41:15 2021 rev:2 rq:907921 version:0.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/obs-service-docker_label_helper/obs-service-docker_label_helper.changes
  2020-10-02 17:34:46.282648027 +0200
+++ 
/work/SRC/openSUSE:Factory/.obs-service-docker_label_helper.new.1899/obs-service-docker_label_helper.changes
        2021-07-23 23:41:37.261799961 +0200
@@ -1,0 +2,17 @@
+Fri Jul 23 08:50:08 UTC 2021 - Bruno Leon <bruno.l...@suse.com>
+
+- Improve regexp instead of having two as proposed by Fabian Vogt
+
+-------------------------------------------------------------------
+Wed Jul 21 10:38:53 UTC 2021 - Bruno Leon <bruno.l...@suse.com>
+
+- Retain compatibility with old syntax. Update documentation.
+
+-------------------------------------------------------------------
+Tue Jul 20 14:28:28 UTC 2021 - Bruno Leon <bruno.l...@suse.com>
+
+- Use entry/exit point to determine whether labels should be expanded.
+  Doing so makes the Dockerfile compatible with standard
+  docker build command.
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ obs-service-docker_label_helper.spec ++++++
--- /var/tmp/diff_new_pack.6MUZbP/_old  2021-07-23 23:41:37.665799445 +0200
+++ /var/tmp/diff_new_pack.6MUZbP/_new  2021-07-23 23:41:37.669799440 +0200
@@ -1,7 +1,7 @@
 #
 # 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
 # remain the property of their copyright owners, unless otherwise agreed
@@ -33,8 +33,8 @@
 BuildRequires:  diffutils
 
 %description
-This service can be used during buildtime to implement the
-PREFIXEDLABEL instruction useful for building containers.
+This service can be used during buildtime to expand LABEL
+instructions with mandatory openSUSE prefixes.
 
 %prep
 %setup -q -D -T -n .

++++++ README ++++++
--- /var/tmp/diff_new_pack.6MUZbP/_old  2021-07-23 23:41:37.701799399 +0200
+++ /var/tmp/diff_new_pack.6MUZbP/_new  2021-07-23 23:41:37.701799399 +0200
@@ -2,7 +2,44 @@
 ===============================
 
 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:
 

++++++ docker_label_helper ++++++
--- /var/tmp/diff_new_pack.6MUZbP/_old  2021-07-23 23:41:37.713799384 +0200
+++ /var/tmp/diff_new_pack.6MUZbP/_new  2021-07-23 23:41:37.713799384 +0200
@@ -20,6 +20,7 @@
 fi
 
 gawk -i inplace '
-       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" }
-       1' Dockerfile
+    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" }
+    match($0, /^# endlabelprefix/) { labelprefix=""; next }
+    1' Dockerfile

++++++ docker_label_helper.service ++++++
--- /var/tmp/diff_new_pack.6MUZbP/_old  2021-07-23 23:41:37.729799363 +0200
+++ /var/tmp/diff_new_pack.6MUZbP/_new  2021-07-23 23:41:37.729799363 +0200
@@ -1,4 +1,4 @@
 <service name="docker_label_helper">
        <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>

++++++ test.sh ++++++
--- /var/tmp/diff_new_pack.6MUZbP/_old  2021-07-23 23:41:37.745799343 +0200
+++ /var/tmp/diff_new_pack.6MUZbP/_new  2021-07-23 23:41:37.749799338 +0200
@@ -7,6 +7,7 @@
 
 cd $tmpdir
 
+# Test old syntax
 cat >Dockerfile <<EOF
 # labelprefix=org.opensuse.nano
 PREFIXEDLABEL org.opencontainers.image.title="Example container"
@@ -22,3 +23,25 @@
 LABEL org.opensuse.nano.description="This contains nano"
 LABEL org.opencontainers.image.description="This contains nano"
 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

Reply via email to