From b7f7fa11eb801ce5def4f44bfcb3aa7d1815efc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Mon, 9 Jan 2017 10:52:41 +0100 Subject: [PATCH] Update schema for container setup In preparation to support creation of native docker containers the way docker likes it, the kiwi schema has to be adapted. So far there was no way to specify additional metadata information for containers. With this commit a new section called is provided. containerconfig is a subsection of the type and only allowed for the docker image type. This constraint is checked via a schematron rule. In addition an xslt stylesheet moves the currently existing container attribute, which was used to set a name for the container, into the new containerconfig section as name attribute --- doc/source/schema.rst | 18 +++++- kiwi/schema/kiwi.rnc | 64 ++++++++++++++++++--- kiwi/schema/kiwi.rng | 65 +++++++++++++++++----- kiwi/xml_parse.py | 111 ++++++++++++++++++++++++++++++++----- kiwi/xsl/convert64to65.xsl | 55 ++++++++++++++++++ kiwi/xsl/master.xsl | 7 ++- 6 files changed, 282 insertions(+), 38 deletions(-) create mode 100644 kiwi/xsl/convert64to65.xsl diff --git a/doc/source/schema.rst b/doc/source/schema.rst index d3dc35f2..9be5a92d 100644 --- a/doc/source/schema.rst +++ b/doc/source/schema.rst @@ -271,7 +271,7 @@ Parents: These elements contain ``type``: :ref:`k.image.preferences` Children: - The following elements occur in ``type``: :ref:`machine ` `[?]`_, :ref:`oemconfig ` `[?]`_, :ref:`pxedeploy ` `[?]`_, :ref:`size ` `[?]`_, :ref:`systemdisk ` `[?]`_, :ref:`vagrantconfig ` `[*]`_ + The following elements occur in ``type``: :ref:`containerconfig ` `[?]`_, :ref:`machine ` `[?]`_, :ref:`oemconfig ` `[?]`_, :ref:`pxedeploy ` `[?]`_, :ref:`size ` `[?]`_, :ref:`systemdisk ` `[?]`_, :ref:`vagrantconfig ` `[*]`_ List of attributes for ``type``: @@ -290,7 +290,6 @@ List of attributes for ``type``: * ``btrfs_root_is_readonly_snapshot`` `[?]`_: Tell kiwi to set the btrfs root filesystem snapshot read-only Once all data has been placed to the root filesystem snapshot it will be turned into read-only mode if this option is set to true. The option is only effective if btrfs_root_is_snapshot is also set to true. By default the root filesystem snapshot is writable * ``checkprebuilt`` `[?]`_: Activates whether KIWI should search for a prebuild boot image or not. Obsolete attribute since KIWI v8 * ``compressed`` `[?]`_: Specifies whether the image output file should be compressed or not. This makes only sense for filesystem only images respectively for the pxe or cpio type -* ``container`` `[?]`_: Specifies a name for the container * ``devicepersistency`` `[?]`_: Specifies which method to use in order to get persistent storage device names. By default by-uuid is used. * ``editbootconfig`` `[?]`_: Specifies the path to a script which is called right before the bootloader is installed. The script runs relative to the directory which contains the image structure * ``editbootinstall`` `[?]`_: Specifies the path to a script which is called right after the bootloader is installed. The script runs relative to the directory which contains the image structure @@ -328,6 +327,21 @@ List of attributes for ``type``: * ``volid`` `[?]`_: for the iso type only: Specifies the volume ID (volume name or label) to be written into the master block. There is space for 32 characters. * ``wwid_wait_timeout`` `[?]`_: Specifies the wait period in seconds after launching the multipath daemon to wait until all presented devices are available on the host. Default timeout is 3 seconds +.. _k.image.preferences.type.containerconfig: + +containerconfig +,,,,,,,,,,,,,,, + +Provides metadata information for containers + +Parents: + These elements contain ``containerconfig``: :ref:`k.image.preferences.type` + +List of attributes for ``containerconfig``: + +* ``name`` : Specifies a name for the container. This is usually the the tag name of the container as read if the container image is imported via the docker load command +* ``entry_command`` `[?]`_: Specifies the default command to run if the container is called via the docker run command. + .. _k.image.preferences.type.machine: machine diff --git a/kiwi/schema/kiwi.rnc b/kiwi/schema/kiwi.rnc index 10621a47..6fc4b888 100644 --- a/kiwi/schema/kiwi.rnc +++ b/kiwi/schema/kiwi.rnc @@ -64,7 +64,7 @@ div { attribute xsi:schemaLocation { xsd:anyURI } k.image.schemaversion.attribute = ## The allowed Schema version (fixed value) - attribute schemaversion { "6.4" } + attribute schemaversion { "6.5" } k.image.kiwirevision.attribute = ## A kiwi git revision number which is known to build ## a working image from this description. If the kiwi git @@ -1745,13 +1745,6 @@ div { sch:param [ name = "attr" value = "compressed" ] sch:param [ name = "types" value = "pxe" ] ] - k.type.container.attribute = - ## Specifies a name for the container - attribute container { text } - >> sch:pattern [ id = "container" is-a = "image_type" - sch:param [ name = "attr" value = "container" ] - sch:param [ name = "types" value = "docker" ] - ] k.type.devicepersistency.attribute = ## Specifies which method to use in order to get persistent ## storage device names. By default by-uuid is used. @@ -2085,7 +2078,6 @@ div { k.type.btrfs_root_is_readonly_snapshot? & k.type.checkprebuilt.attribute? & k.type.compressed.attribute? & - k.type.container.attribute? & k.type.devicepersistency.attribute? & k.type.editbootconfig.attribute? & k.type.editbootinstall.attribute? & @@ -2126,6 +2118,7 @@ div { ## The Image Type of the Logical Extend element type { k.type.attlist & + k.containerconfig? & k.machine? & k.oemconfig? & k.pxedeploy? & @@ -2804,6 +2797,59 @@ div { } } +#========================================== +# main block: +# +div { + sch:pattern [ + abstract = "true" + id = "container_type" + sch:rule [ + context = "containerconfig" + sch:assert [ + test = "contains('$types', ../@image)" + "containerconfig($attr) is only available for the following "~ + "image types: $types" + ] + ] + ] + k.containerconfig.name.attribute = + ## Specifies a name for the container. This is usually the + ## the tag name of the container as read if the container + ## image is imported via the docker load command + attribute name { text } + >> sch:pattern [ id = "name" is-a = "container_type" + sch:param [ name = "attr" value = "name" ] + sch:param [ name = "types" value = "docker" ] + ] + k.containerconfig.entry_command.attribute = + ## Specifies the default command to run if the container is + ## called via the docker run command. + attribute entry_command { text } + >> sch:pattern [ id = "entry_command" is-a = "container_type" + sch:param [ name = "attr" value = "entry_command" ] + sch:param [ name = "types" value = "docker" ] + ] + k.containerconfig.attlist = + k.containerconfig.name.attribute & + k.containerconfig.entry_command.attribute? + + k.containerconfig = + ## Provides metadata information for containers + [ + db:para [ + "The containerconfig element provides metadata information" + "to setup a container in order to be prepared for use with" + "the container engine tool chain. container specific data" + "should be provided in an additional subsection whereas this" + "section provides globally useful container information" + ] + ] + element containerconfig { + k.containerconfig.attlist + } +} + #========================================== # main block: # diff --git a/kiwi/schema/kiwi.rng b/kiwi/schema/kiwi.rng index ec90df02..cc7815de 100644 --- a/kiwi/schema/kiwi.rng +++ b/kiwi/schema/kiwi.rng @@ -101,7 +101,7 @@ second the location of the XSD Schema The allowed Schema version (fixed value) - 6.4 + 6.5 @@ -2286,15 +2286,6 @@ only images respectively for the pxe or cpio type - - - Specifies a name for the container - - - - - - Specifies which method to use in order to get persistent @@ -2806,9 +2797,6 @@ are available on the host. Default timeout is 3 seconds - - - @@ -2922,6 +2910,9 @@ are available on the host. Default timeout is 3 seconds The Image Type of the Logical Extend + + + @@ -3906,6 +3897,54 @@ drivers on system installation with YaST. + +
+ + + containerconfig($attr) is only available for the following image types: $types + + + + + Specifies a name for the container. This is usually the +the tag name of the container as read if the container +image is imported via the docker load command + + + + + + + + + Specifies the default command to run if the container is +called via the docker run command. + + + + + + + + + + + + + + + + + Provides metadata information for containers + The containerconfig element provides metadata informationto setup a container in order to be prepared for use withthe container engine tool chain. container specific datashould be provided in an additional subsection whereas thissection provides globally useful container information + + + +
+ + + + + + + + + + + Changed attribute schemaversion + to schemaversion from + 6.4 to 6.5. + + + + + + + + + + + + + + + + + + + Move container attribute from type to containerconfig + + + + + + + + + + + + + + + + + diff --git a/kiwi/xsl/master.xsl b/kiwi/xsl/master.xsl index 135ccfe5..719702b0 100644 --- a/kiwi/xsl/master.xsl +++ b/kiwi/xsl/master.xsl @@ -35,6 +35,7 @@ + @@ -161,8 +162,12 @@ + + + +