Commit Graph

28 Commits

Author SHA1 Message Date
Alexandre Detiste
fb69627ad3
Use unittest.mock from core python everywhere
mock was an independent module that has been merged into the Python standard library.
2024-02-18 22:15:30 +01:00
Marcus Schäfer
cd052c0558
Move OCI to context manager
Change the OCI Factory to be a context manager.
All code using OCI was updated to the following
with statement:

    with OCI(...).new as oci:
        oci.some_member()

This is related to Issue #2412
2024-02-13 22:35:52 +01:00
Marcus Schäfer
b56a4caa78
Fix linter check, whitespace after : 2023-07-31 17:39:04 +02:00
Marcus Schäfer
28982ccb02
Fixed handling of container archive compression
In kiwi we support handling of the container archive compression
via a runtime configuration setting of the following form, eg
in /etc/kiwi.yml

```yaml
container:
  # Specify compression for container images
  # Possible values are true, false, xz or none.
  - compress: true
```

However, this setting was only taken into account in the kiwi
bundler. Meaning if the user calls 'kiwi result bundle ...'
after the container image has been created the result bundler
will take the compression setting into account. From my perspective
this behavior is misleading and also prevents users from
creating compressed container archives without a subsequent
result bundler call. Therefore this commit moves the place to
handle the compression setting into the container classes.
The bundler code for containers will no longer operate on it
and just takes what it gets, which can be either compressed
or not. The default setting was "No compression" and this
was not changed. This Fixes #2217
2022-12-13 23:13:08 +01:00
Igor Raits
1f547d6bb9
Stop copying /dev files statically into the OCI container
In containers (nspawn) where part of the /dev filesystem is bind-mounted
from outside system, kiwi fails to do the rsync (in creation of the
nodes).

There is no reason to actually copy whole tree inside so let's just
not do it (as it does not seem to be needed at all).
2022-10-22 08:09:46 +02:00
David Cassany
332d60f777
Support additional names for docker containers
Docker containers used to support the attribute `additionaltags` which
was used to provide multiple tags for the same image. Since only tags
were supported this commit renames the attribute to `additionalnames`
and now supports tags and names witht he following syntax:

* '<name>:<tag>' -> adds a full docker image reference including name
  and tag
* ':<tag>'       -> adds an additional tag while reusing the former name
* '<name>'       -> adds an additional name while reusing the former tag

Fixes #2045

Signed-off-by: David Cassany <dcassany@suse.com>
2022-03-09 18:19:31 +01:00
Marcus Schäfer
9c9250ebc4
Support nose and xunit style tests
The modifications in this commit allows the unit tests
to run on both, pytest 6.x (nose test layout) and the new
pytest 7.x (xunit test layout). This Fixes #2072 in a
much nicer way. Thanks much to @smarlowucf
2022-02-26 20:26:18 +01:00
Marcus Schäfer
1f869e7ca8
Revert "Unit test adaptions to pytest v7"
This reverts commit 0dc2e803e0.
The pytest interface from version v6 to v7 has received
changes which requires the tests to be adapted to work for
either the old or the new interface. As there are still many
distributions which uses v6 as the standard we decided to
revert back the adaptions done to support v7 and create
a version requirement to v6 in .virtualenv.dev-requirements.txt
This Fixes #2072
2022-02-26 20:19:42 +01:00
Marcus Schäfer
04e879f722
Update unit test to work in obs
Some unit tests fails if they run in an obs environment.
This is because the implementation checks the runtime
envoironment and behaves differently if the system is
an obs worker. The unit tests has to explicitly set this
condition right for the test
2022-02-26 17:20:03 +01:00
David Cassany
75a49dc887
Make use of container name in OCI images
Fixes #2050

Signed-off-by: David Cassany <dcassany@suse.com>
2022-02-08 10:44:03 +01:00
Marcus Schäfer
0dc2e803e0
Fixed unit tests
The pytest interface setup() method call has changed
in a way that an additional parameter is passed to
the method which leads to a python error at invocation
time if the setup method does not define it.
2022-02-07 21:27:39 +01:00
David Cassany
f58b8998fd
Compress container images in builder class
This commit changes the stage at which container images are compressed
to match the criteria applied to other image types. Instead of
compressing the image in OCI devoted classes now it is happening
in builder class by setting Result instance properties.

Fixes #1996

Signed-off-by: David Cassany <dcassany@suse.com>
2021-12-01 13:28:18 +01:00
Marcus Schäfer
fc2446dfea
Moving temp data handling to its own namespace
Moving use of mkdtemp, NamedTemporaryFile and TemporaryDirectory
into its own class called Temporary: By default all temporary
data is created below /var/tmp but can be changed via the
global commandline option --temp-dir. This Fixes #1870
2021-07-22 13:31:44 +02:00
David Cassany
0242006e5b
Upgrade tests accoring to #1805
This commit is a follow up of #1805 which missed to update the related
unit test.
2021-04-30 14:39:10 +02:00
David Cassany
e2cf8cc4e6
Do not apply default subcommand for derivate containers
This commit does not apply the default subcommand for derivate
containers.

Fixes bsc#1184823
2021-04-16 15:48:33 +02:00
Marcus Schäfer
7bea6c9203
Add support for a custom exclude file
The new optional metadata file image/exclude_files.yaml can
be placed inside of the local image root tree. At creation time of
the image binary the file contents are used to extend the default
exclude list with additional information. The structure of the
file must be as follows:

```yaml
exclude:
  - exclude-name-used-in-rsync
```
2021-04-16 10:23:33 +02:00
Marcus Schäfer
ce9b1ccc08
Added option to set the image target architecture
The option --target-arch allows to set the architecture
used to build the image. By default this is the host
architecture. Please note, if the specified architecture
name does not match the host architecture and is therefore
requesting a cross architecture image build, it's important
to understand that for this process to work a preparatory
step to support the image architecture and binary format
on the building host is required and is not considered a
responsibility of kiwi. There will be a followup effort
on providing a plugin for kiwi which should be used to
manage the needed binfmt settings for cross arch image
builds
2021-04-14 12:53:28 +02:00
David Cassany
596841e78c
Exclude /run and /tmp to be synched into the image
This commit makes sure the contents of /run and /tmp are ignored when
synchronizing the generated root tree into the image.

Fixes #1744
2021-03-11 14:47:36 +01:00
Marcus Schäfer
7a5ab282b6
Refactor RuntimeConfig class
The former implementation read the runtime config file every
time a new RuntimeConfig instance was created. The runtime
config is however static during the runtime of an image build
process and not supposed to change. Therefore the file should
be read in once and any new instance of RuntimConfig should
just use what has been read in at the first invocation. This
commit refactors the RuntimeConfig class to hold an application
global RUNTIME_CONFIG variable and allows to reread the
config on explicit request.
2021-02-08 12:41:20 +01:00
David Cassany
99be52baec
Refactor container factory classes
This commit refactors the container related classes to turn them into
proper factory classes and also includes type hints to facilitate
it's use from an API POV. Related to #1498
2020-12-15 20:19:10 +01:00
David Cassany
44c0029ce5
Do not exclude filesystem folders in OCI images
This commit does not exclude filesystem folders during the rsync call
in OCI images. It has been noted that including an empty /dev folder does
not hurt and it can eventually help to work around some limitations of
container related tools such as buildah.

Fixes bsc#1176129
2020-11-03 12:03:38 +01:00
David Cassany
ac7bed3221
Get default maintainer and author from image description
This commit sets the maintainer and author metadata from the description
section of the image in they are not explicitly specified in
container-config section.

In addition it sets the default container name to `system-container`
instead of `systemContainer` as uppercase letters are not valid for
docker container references.

Fixes #1419
2020-09-21 10:24:31 +02:00
Marcus Schäfer
44a1d78e96
Added new image type: wsl
Support for building appx container images for
Windows Subsystem Linux (WSL). This Fixes #1235
2020-03-26 19:42:25 +01:00
Marcus Schäfer
a62cbd5edb
Cleanup fstab handling for containers
When building container images an extra create_fstab method
exists that created an empty fstab file. The reasons for this
are historical and also related to appx support from obs.
The obs based support for appx containers was based on the
creation of a kiwi docker image that got modified and turned
into an appx container. Now with native appx support by kiwi
this special fstab handling is no longer needed and should
be deleted. This Fixes #1329
2020-03-18 14:12:54 +01:00
David Cassany
487c75017a
Fix a regression for container builds in OBS
This commit fixes a regression introduced in 12d84be2. We need to ensure
that `labels` item exist in oci image configuration dict before updating
it and creating it in case it doesn't exist.
2020-03-04 15:47:41 +01:00
David Cassany
12d84be2fb
Fix container labels setup in OBS
This commits fixes the containers label setup in OBS, ensuring that
adding the 'org.openbuildservice.disturl' label does not clear any
other label.

Fixes #1338
2020-02-28 15:34:39 +01:00
Marcus Schäfer
bdb7123fa1
Refactor use of logging facility
Use getLogger method instead of a global log object
Also use caplog fixture to capture log messages in
unit tests. This Fixes #1244
2019-10-23 17:54:27 +02:00
David Cassany
4b3a105026
Re-structure unit tests folders
This commit relocates unit tests to a folder structure that matches
the source code structure.

Fixes #1128
2019-10-21 14:00:05 +02:00