Commit graph

45 commits

Author SHA1 Message Date
Tomáš Hozza
3ac6d405b5 Fix pylint issue E0606: possibly-used-before-assignment
Fix:
assemblers/org.osbuild.qemu:310:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
inputs/org.osbuild.tree:85:15: E0606: Possibly using variable 'path' before assignment (possibly-used-before-assignment)
stages/org.osbuild.sfdisk:58:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
stages/org.osbuild.systemd.unit:23:16: E0606: Possibly using variable 'unit_dropins_dir' before assignment (possibly-used-before-assignment)
test/mod/test_meta.py:219:29: E0606: Possibly using variable 'schema_part' before assignment (possibly-used-before-assignment)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Achilleas Koutsou
07a597481b util: move get_host_storage() to a separate module
Add a new util module called host which is used for functions that are
meant for interactions with the host.  These functions should not be
used in stages.

The containers.get_host_storage() function is renamed to
host.get_container_storage() for clarity, since it is no longer
namespaced under containers.
2024-08-21 19:26:31 +02:00
Michael Vogt
1d4f2dc53b testutil: extract find_one_subclass_in_module() helper
A small refactor to avoid shipping this duplicated code (this
one is easy to extract/reuse).
2024-04-03 11:36:01 +02:00
Michael Vogt
7c0e9cfcf7 inputs: add inputs_service fixture
This new fixture avoids some repetitivness when building tests
for input services.
2024-04-03 11:36:01 +02:00
Michael Vogt
5f31ccf9f2 test: add/use new testutil.make_fake_service_fd()
All inputs/sources tests need a fake service fd to instanciate
their services. Consolidate the creation in a single helper.
2024-04-03 11:36:01 +02:00
Michael Vogt
fd0167f130 test: return container_id in make_container
The current `make_container()` helper is a bit silly (which is
entirely my fault). It requires a container tag as input but all
tests end up creating a random number for this input. So instead
just remove the input and return the container_id from the podman
build in the contextmanager and use that.
2024-03-18 20:36:19 +01:00
Michael Vogt
b0091c0470 inputs: simplify/comment clean of test_containers_local_inputs_integration
Thanks to Ondrej fot the suggestions
2024-02-27 15:07:42 +01:00
Michael Vogt
b5355c46ac inputs: tweak containers-storage implementation
This commit tweaks the excellent work from Gianluca in PR#1550 a
little bit. Now that the container inputs are their own input
type some of the code that used to be part of the original
`inputs/org.osbuild.containers` can be simplified.
2024-02-27 15:07:42 +01:00
Michael Vogt
882c9efbc1 inputs: add integration test for inputs/org.osbuild.containers-storage
Ensure that `ContainersInput.map()` work correctly with local
image store references.
2024-02-27 15:07:42 +01:00
Michael Vogt
2d71935a91 inputs: add new "inputs_module" fixture 2024-02-27 15:07:42 +01:00
Gianluca Zuccarelli
591341dfa6 inputs: new input type org.osbuild.containers-storage
An input that pairs with the org.osbuild.containers-storage source. It
makes the host container storage available to a stage and a container ID
for the stage to use.

Unlike all the other input types, this input does not refer to static
objects in the osbuild sources store but a dynamically mounted container
store that depends on the host storage configuration and the
availability of specific containers in that store.

Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
Co-authored-by: Gianluca Zuccarelli <gzuccare@redhat.com>
2024-02-21 17:55:37 +01:00
Dusty Mabe
7de357f1a9 inputs/ostree: leverage util/ostree library code
Similar to the cleanups in 4e99e80, let's start using the library
code for the calls to ostree here.
2023-10-16 20:26:10 +02:00
Achilleas Koutsou
5f76ec03a7 inputs/containers: change archive format to dir
The format so far was assumed to be `docker-archive` if the container
was coming from a source and `oci-archive` if it was coming from a
pipeline.  The source format will now be changed to `dir` instead of
`docker-archive`.  The pipeline format remains `oci-archive`.

With the new archive format being `dir`, the source can't be linked into
the build root and is bind mounted instead with the use of a MountGuard
created with the instance of the service, and torn down when the service
is stopped.

The _data field is removed from the map functions.  It was unused and
these functions aren't part of the abstract class so they don't need to
have consistent signatures.

Update the skopeo stage with support for the newly supported `dir`
format.
2023-03-31 14:57:26 +02:00
David Rheinsberg
4b09088661 test/isort: apply diff to full tree
Apply the isort modifications to the entire source tree, not just the
selected python files of test-src.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-23 12:08:10 +02:00
David Rheinsberg
8c367dfa6f tree: fix pylint warnings
This fixes pylint warnings on our modules that are currently not part of
CI-pylint. The fixes should all be straightforward.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 16:21:14 +02:00
Christian Kellner
99abc1373d inputs: support array of objects references
This extends the possible ways of passing references to inputs. The
current ways possible are:
 1) "plain references", an array of strings:
    ["ref1", "ref2", ...]
 2) "object references", a mapping of keys to objects:
    {"ref1": { <options> }, "ref2": { <options> }, ...}

This patch adds a new way:
  3) "array of object references":
    [{"id": "ref1", "options": { ... }}, {"id": ... }, ]

While osbuild promises to preserves the order for "object references"
not all JSON serialization libraries preserve the order since the
JSON specification does leave this up to the implementation.

The new "array of object references" thus allows for specifying the
references together with reference specific options and this in a
specific order.

Additionally this paves the way for specifying the same input twice,
e.g. in the case of the `org.osbuild.files` input where a pipeline
could then be specified twice with different files. This needs core
rework though, since internally we use dictionaries right now.
2022-04-21 16:39:58 +02:00
Christian Kellner
0fe7196c7a inputs/ostree: extract per-ref options schema
Extract the schema for the per-reference options, which in this case
confusingly is the single property "ref".
2022-04-21 16:39:58 +02:00
Christian Kellner
c25857020d test/fmt_v2: add simple check for input references
Specifically this test checks that the order given in the manifest is
preserved when loaded, i.e. the internal dict has the keys ordered in
the same way, independently in which way they were specified -- list
or object.
2022-04-21 16:39:58 +02:00
Christian Kellner
df91d8916d inputs/tree: enforce constraints for plain refs
When using "plain refs", that is, when using an array of strings,
we did not enforce the constraints of exactly one reference. This
was done for dictionary references.
2022-04-21 16:39:58 +02:00
Christian Kellner
ae7ab67cfa inputs/ostree: fix typo
Lets put the `a` back in `dictionaries`.
2022-04-21 16:39:58 +02:00
Christian Kellner
bc99cd9c19 inputs/container: prefix unused arguments with _
The `data` argument is not used, prefix it with `_` so that pylint
knows this is intentional.
2022-04-21 16:39:58 +02:00
Christian Kellner
3e1ecf15b6 inputs/containers: remove unneeded input
The `pathlib` is not used, remove it.
2022-04-21 16:39:58 +02:00
Jelle van der Waa
4eb35babed inputs/org.osbuild.tree: fix typo 2022-04-16 15:39:15 +02:00
Alexander Larsson
1152edcf31 inputs/org.osbuild.containers: Drop format and file options
We hardcode oci-archive for now and use the first file in the pipeline
tree as the archive. Long term we may want to get this info from the
metadata of the oci-archive stage instead.
2022-02-10 14:43:17 +01:00
Alexander Larsson
46a228df38 Add support for installing containers in images
This adds a stage called org.osbuild.skopeo that installs docker and
oci archive files into the container storage of the tree being
constructed.

The source can either be a file from another pipeline, for example one
created with the existing org.osbuild.oci-archive stage, or it can
be using the new org.osbuild.skopeo source and org.osbuild.containers
input, which will download an image from a registry and install that.

There is an optional option in the install stage that lets you
configure a custom storage location, which allows the use of the
additionalimagestores option in the container storage.conf
to use a read-only image stores (instead of /var/lib/container).

Note: skopeo fails to start if /etc/containers/policy.json is
not available, so we bind mount it from the build tree to the
buildroot if available.
2022-02-10 14:43:17 +01:00
Christian Kellner
ca3941feb6 inputs/ostree.checkout: don't overwrite refs
The `refs` variable is used as parameter to indicate which commits
to checkout, but it also was used as result variable to store the
ids of the commits that actually got checked out; naturally, it
was initialized to the empty array. This of course meant nothing
was ever actually checked out. Doh.
2021-08-24 01:21:03 +02:00
Christian Kellner
3695e22369 inputs: add org.osbuild.ostree.checkout
New input type that takes a ostree repo and checks out any number
of commits inside that repo to a temporary directory. Each commit
will be checked out to a separate sub-directory. The name of the
dir is the commit id of the corresponding commit.
This input can thus be used to access files and directories of
commits in stages.
2021-08-17 13:53:00 +02:00
Christian Kellner
f4a8770e58 inputs/files: support for pipeline origins
Currently the `org.osbuild.files` input only supports the source origin.
Extend support to mapping files from pipelines, using the recently added
sub-tree reading capability of `ObjectStore.reat_at`. Restructure the
JSON schema to keep is as readable as possible.
2021-06-09 18:37:47 +01:00
Christian Kellner
659c139ed1 inputs/files: extract source options schema
This is mostly to prepare the support for pipeline options will be
different for pipeline origins than source origins.
2021-06-09 18:37:47 +01:00
Christian Kellner
e92b24229d inputs/files: extract origin definition
This is mostly to prepare the support for pipeline origins where
this node will get reused in more than one place.
2021-06-09 18:37:47 +01:00
Christian Kellner
a2c926654c inputs/files: rename refs to files
The `org.osbuild.files` input provides individual files to a stage.
Change the `refs` key in the returned dict to `files` to better
reflect that fact. Also adapt the documentation to indicate that
the keys actually paths and not necessarily checksums. This prepares
for future extension of the `files` input to pipeline origins.
2021-06-09 18:37:47 +01:00
Christian Kellner
a3ea8dc748 inputs/files: use os.link instead of ln binary 2021-06-09 18:37:47 +01:00
Christian Kellner
1ed85dc790 inputs: convert to host service
Create a `InputService` class with an abstract method called `map`,
meant to be implemented by all inputs. An `unmap` method may be
optionally overridden by inputs to cleanup resources.
Instantiate a `host.ServiceManager` in the `Stage.run` section and
pass the to the host side input code so it can be used to spawn the
input services.
Convert all existing inputs to the new service framework.
2021-06-09 18:37:47 +01:00
Christian Kellner
08bc9ab7d8 inputs: pre-defined input paths
Instead of bind-mounting each individual input into the container,
create a temporary directory that is used by all inputs and bind-
mount this to the well known location ("/run/osbuild/inputs"). The
temporary directory is then passed to the input so that it can
make the requested resources available relative to that directory.
This is enforced by the common input handling code.
Additionally, pass the well known input path via a new "paths" key
to the arguments dictionary passed to the stage.
2021-06-09 18:37:47 +01:00
Christian Kellner
2b19e534e6 inputs/files: extract sources definition
Make the main portion of the schema more readable by extracting the
two possible reference definitions.
2021-06-09 18:37:47 +01:00
Christian Kellner
d577a306f9 inputs/files: extract metadata schema
Make the schema more readable by extracting the metadata definition.
2021-06-09 18:37:47 +01:00
Christian Kellner
36c7d08f6e inputs/ostree: use ostree prefix for temp dir
Use `ostree-ouput` instead of `files-output` as prefix for the
temporary directory prefix.
Also fix the description of the "origin" to reflect that
pipeline and source origins are supported.
Additionally remove some dead code.
2021-03-22 14:25:23 +01:00
Christian Kellner
5cd139d53a inputs: add noop input for testing
Add a new "noop" input that does nothing but forward all its
data to the stage. Can be useful for testing.
2021-02-12 15:55:43 +01:00
Christian Kellner
7caa263659 inputs/ostree: support pipeline inputs
In addition to pulling ostree commits via sources, the input
now supports pulling commits that were built via an osbuild
pipeline.
2021-02-12 15:55:43 +01:00
Christian Kellner
c9462bf48c inputs: add "type" property to schema
This was missed when `type` was added to the Inputs class.
2021-02-12 15:55:43 +01:00
Christian Kellner
dd50387bbc inputs/tree: remove trailing whitespace
This one is for David. And pylint, but mostly David.
2021-02-11 23:49:18 +01:00
Christian Kellner
17c6446a7c inputs: add org.osbuild.ostree input
Add a new input that can handle ostree commits. For source origins,
it will pull any number of commits specified via `references`. For
pipeline origins it will use the compose.json to obtain the commit
id and pull that. Either way the data passed onto the stage is a
dictionary of commit ids and commit metadata, such as the `ref`
that is an ostree ref that is optionally created in case the `ref`
option for that reference was specified.
2021-02-06 12:04:30 +01:00
Christian Kellner
1f89d2fd9d inputs: add files input
Create a new input for resources of the `org.osbuild.files` type,
i.e. individual files, addressed in the store via their content
hash.
2021-02-06 12:04:30 +01:00
Christian Kellner
eb1d17d8ac input: add references and origin
Currently all options for inputs are totally opaque to osbuild
itself. This is neat from a seperation of concerns point of view
but has one major downside: osbuild can not verify the integrity
of the pipeline graph, i.e. if all inputs that need pipelines or
sources do indeed exists. Therefore intrdouce two generic fields
for inputs: `origin` and `references`. The former can either be
a source or a pipeline. The latter is an array of identifiers or
a dictionary where the keys are the identifiers and the values
are additional options for that id. The identifiers then refer
to either resources obtained via a source or a pipeline that has
already been built.
2021-02-06 12:04:30 +01:00
Christian Kellner
79b192e736 inputs: add new org.osbuild.tree input
This represents the tree-type input, which is the simplest form
of input a stage can consume. For the stage it is just a file
system tree at a specific location and the contents itself is
mostly opaque. An obvious thing to do with such a content is
carbon copy it to a different location.
Currently this input only supports the pipelines as origins,
which are identified via their id.
2021-01-18 17:44:46 +01:00