Commit Graph

39 Commits

Author SHA1 Message Date
benniekiss 3c52ef43f5 Expand drop-in search paths
* top-level (pod.d)
* truncated (unit-.container.d)

Signed-off-by: Bennie Milburn-Town <63211101+benniekiss@users.noreply.github.com>
2024-07-17 17:43:02 -04:00
Johannes Maibaum 9f823ecb25 Quadlet: Add support for .build files
.build files allow to build an image via Quadlet. The keys from a .build
file are translated to arguments of a `podman build` command by Quadlet.

Minimal keys for .build files are `ImageTag=` and a context directory,
see `SetWorkingDirectory=`, or a `File=` pointing to a Containerfile.

After sorting .build files into the Quadlet dependency order, there
remains a possible dependency cycle issue between .volume and .build
files: A .volume can have `Image=some.build`, and a .build can have
`Volume=some.volume:/some/volume`.

We solve this dependency cycle by prefilling resourceNames with all
image names from .build files before converting all the unit files.

This results in an issue for the test suite though: For .volume's
depending on *.image or *.build, we need to copy these additional
dependencies to the test's quadletDir, otherwise the test will fail.
This is necessary, because `handleImageSource()` actually needs to know
the image name defined in the referenced *.{build,image} file. It cannot
fall back on the default names, as it is done for networks or volumes,
for example.

Signed-off-by: Johannes Maibaum <jmaibaum@gmail.com>
2024-05-27 16:59:39 +02:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Alexander Larsson 01dccba50c quadlet: When loading dropin files for foo@instance, also load those for foo@.
This is how systemd works for templates, and it allows us lots of
flexibilities.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2024-01-26 13:57:39 +01:00
Alexander Larsson bb6dec46ff quadlet: Support [Install] for templated units
For a base template like `foo@.container` the WantedBy and RequiredBy
keys does nothing. However, if a DefaultInstance= key is specified
that is used by default.

However, even if the DefaultInstance= is not given, the Install
section is still useful, because you can instantiate the generic
template by making a symlink for it, and that symlink will then
pick up the instance id.

So, for example, this foo@.container will not enable anything
on boot.
```
[Container]
Image=foo
Exec=sleep 100

[Install]
WantedBy=other.container
```

But if you have a symlink 'foo@instance.container` -> `foo@.container'
then the `foo@instance` service will be marked as wanted by `other`.

In addition, even if the main template doesn't have an Install
section, you can instantiate it with a symlink like above, and then
enabling it using a dropin file like
foo@instance.container.d/install.conf containing:
```
[Install]
WantedBy=other.container
```

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2024-01-26 13:57:39 +01:00
Daniel J Walsh f0319d5b7a
Error messages not being reported unless more then one error present
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-01-04 14:23:04 -05:00
Ygal Blum 212b4c9e93 Quadlet .pod - add support for the Network Key
Add e2e tests
Update documentation

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-12-03 10:22:33 +02:00
openshift-merge-bot[bot] 572a7692e3
Merge pull request #20828 from alexlarsson/quadlet-snippets
quadlet: Support systemd style dropin files
2023-11-29 23:24:33 +00:00
Alexander Larsson 8ee2622028 quadlet: Support systemd style dropin files
For a source file like `foo.container`, look for drop in named
`foo.container.d/*.conf` and merged them into the main file.  The
dropins are applied in alphabetical order, and files in earlier
diretories override later files with same name.

This is similar to how systemd dropins work, see:
https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html

Also adds some tests for these

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2023-11-29 13:46:52 +01:00
Ygal Blum 6b2f48129e Quadlet - Add support for .pod units
Add support for .pod unit files with only PodmanArgs, GlobalArgs, ContainersConfModule and PodName
Add support for linking .container units with .pod ones
Add e2e and system tests
Add to man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-11-28 14:31:53 +02:00
Ygal Blum dc709e4d76 Quadlet - Allow using symlink on the base search paths
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-11-15 09:58:28 +02:00
Daniel J Walsh cb53bcf23f
Run codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-12 12:45:44 -04:00
Ygal Blum 55ca571e55 Quadlet - add support for .image units
main
----
Use order number to order the units processing
Process .image file
Usage of .image file should not log Ambiguous Name warning
Use AmbiguousName for .volume and .image units

Quadlet
-------
Convert .image files
Add driver and Image keys to .volume files
Handle usage of .image as Image

Man Page
--------
Add comments for new keys in .volume file
Add comment about using .image files as images
Add section about .image units

Tests
-----
Add integration tests
Add system test

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
Co-authored-by: Tom Sweeney <tsweeney@redhat.com>
2023-09-18 16:26:18 +03:00
Daniel J Walsh 64873e322c
Codespell fixups
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-31 09:38:46 -04:00
Daniel J Walsh d6a32a3da3
If quadlets have same name, only use first
If a user puts a quadlet file in his homedirectory with
the same name as one in /etc/containers/systemd/user or
/etc/containers/systemd/user/$UID, then only use the one in
homedir and ignore the others.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-26 17:17:09 -04:00
Hari Kannan 413552e10e quadlet recursively scan for unit files
Signed-off-by: Hari Kannan <harikannan512@gmail.com>
2023-07-20 23:10:28 +01:00
Alex Palaistras 932fae4028 Allow setting volume and network names in Quadlet
This commit extends `Volume` and `Network` unit definitions with two
additional parameters, `VolumeName` and `NetworkName`, which will,
respectively, set a user-defined name for the corresponding volume and
network. This is similar to how the `ContainerName` directive currently
works, and should allow for smoother transitions to Quadlet-managed
resources.

Closes: #19003
Signed-off-by: Alex Palaistras <alex@deuill.org>
2023-07-10 20:33:19 +01:00
Valentin Rothberg 60a5a59475 make lint: enable mirror
Helpful reports to avoid unnecessary allocations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 14:11:12 +02:00
Daniel J Walsh bfe61af6d7
quadlet should exit non zero on failures
Fixes: #18778

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-06-15 19:12:17 -04:00
Erik Sjölund 685c736185 source code comments and docs: fix typos, language, Markdown layout
- fix a/an before noun
- fix loose -> lose
- fix "the the"
- fix lets -> let's
- fix Markdown layout
- fix a few typos
- remove unnecessary text in troubleshooting.md

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-05-22 07:52:16 +02:00
Petr Lautrbach bdb3ed7950 Fix preference of user quadlets directories
If there's a container defined in multiple directories use the following
precedence:

$XDG_CONFIG_HOME/containers/systemd/ or ~/.config/containers/systemd/
takes precedence over /etc/containers/systemd/users/$(UID) and this
takes precedence over /etc/containers/systemd/users/

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2023-05-09 12:06:38 +02:00
Daniel J Walsh 73d3487cce
Allow user quadlets to be stored under /etc
I would like to allow admin to control quadlet containers
in users homedirs.

If an admin sets a quadlet in
/etc/containers/systemd/users, then all users will run these
quadlet services when they login.

If an admin places a quadlet in /etc/containers/systemd/users/$(USERNAME)
then only the USERNAME will execute this quadlet service when
they login.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-05-04 10:06:41 -04:00
Valentin Rothberg 243ca7c280 add `quadlet -version` flag
I recently wanted to check which version of Quadlet I was using and
found a `-version` flag to be missing.  Since Quadlet and Podman are
bundled together, it seems reasonable to me for them to share the same
version.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-04-04 11:32:47 +02:00
Valentin Rothberg 53b16ccd26 quadlet: use `Flag` suffix for variables
Purely cosmetic change for consistency.

[NO NEW TESTS NEEDED]  as it doesn't change functionality.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-04-04 09:55:14 +02:00
Erik Sjölund a5ca732256 Fix typos
Software version used
https://github.com/crate-ci/typos/releases/tag/v1.13.10

The binary was downloaded from
https://github.com/crate-ci/typos/releases/download/v1.13.10/typos-v1.13.10-x86_64-unknown-linux-musl.tar.gz

Command that was run:

typos --write-changes docs cmd cni contrib dependencies docs hack libpod pkg utils

False positives were manually removed.
A few marshaling/existant typos were manually fixed.

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-02-11 18:23:24 +01:00
Valentin Rothberg f1352521ff Quadlet: exit 0 when there are no files to process
Quadlet should not exit with failure if no files to process have been
found.  Otherwise, even simple operations such as reloading systemd
will fail as it retriggers generators.

Fixes: #17374
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-02-07 10:48:31 +01:00
Leonardo Rossetti cd3492304e
adding -dryrun flag
Signed-off-by: Leonardo Rossetti <lrossett@redhat.com>
2023-01-03 09:19:48 -03:00
OpenShift Merge Robot b0acb59ccb
Merge pull request #16688 from ygalblum/quadlet_network_file
Quadlet: add network support
2022-12-19 14:16:53 -05:00
Ygal Blum d974a79e27 Quadlet: add network support
Support .network file to create a systemd service that runs podman network create
Support networks with .network suffix in Container and Kube to link with Quadlet created networks
Add E2E Tests
Add man doc

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-18 11:25:20 +02:00
Alexander Larsson 20b10574d7 quadlet: Add --user option
Normally quadlet picks up whether to behave like a user or system
instance based on the binary name, but for the tests we want the
ability to pass `--user` to modify this using a single binary.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-16 14:55:40 +01:00
Valentin Rothberg dcbf7b4481 bump golangci-lint to v1.50.1
Also fix a number of duplicate words.  Yet disable the new `dupword`
linter as it displays too many false positives.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-12-15 13:39:56 +01:00
Ygal Blum 1ea00ebda1 Quadlet Kube: Add support for userns flag
Move the handling of userns keys from ConvertContainer to a separate method
Adjust the method according to the different supported values
Use the new method in both ConvertContainer and ConvertKube
Pass isUser to ConvertKube as well
Add tests

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-05 21:26:23 +02:00
Daniel J Walsh f17479c711
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-28 15:13:43 -05:00
Ygal Blum 3084ed4686 Quadlet: Add support for .kube files
Get the path to the yaml file and call podman kube play
Add tests

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-11-22 16:58:01 +02:00
Alexander Larsson 7ec743fe74 quadlet: Warn in generator if using short names
These are both slow (trigger loading alias files) and risky (its not
clear which image you mean).

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-11-02 11:55:08 +01:00
Alexander Larsson 33eb45c475 quadlet tests: Disable kmsg logging while testing
Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-25 13:09:51 +02:00
Alexander Larsson af67f15bc7 quadlet: Embed the correct binary name in the generated comment
The binary name is not the same as in the old quadlet, and can anyway
differ in system and user runs, so use os.Args[0] to get the right name
in the comment.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-25 13:08:58 +02:00
Valentin Rothberg b4374f2bd9 move quadlet packages into pkg/systemd
Reduce the number of top-level packages in ./pkg by moving quadlet
packages under ./pkg/systemd.

[NO NEW TESTS NEEDED] - no functional change.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-19 13:38:27 +02:00
Alexander Larsson 62bb59d3b0 Initial quadlet version integrated in golang
Based on the initial port in https://github.com/containers/quadlet/pull/41

This contains the unit tests and the testcases from the C code as well
as modification to the podman spec file based on what the quadlet
spec file looks like, producing a podman-quadlet subpackage.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-17 15:56:03 +02:00