Commit Graph

616 Commits

Author SHA1 Message Date
Matt Heon 174631f726 Convert SpecGen values to be nullable where possible
SpecGen is our primary container creation abstraction, and is
used to connect our CLI to the Libpod container creation backend.
Because container creation has a million options (I exaggerate
only slightly), the struct is composed of several other structs,
many of which are quite large.

The core problem is that SpecGen is also an API type - it's used
in remote Podman. There, we have a client and a server, and we
want to respect the server's containers.conf. But how do we tell
what parts of SpecGen were set by the client explicitly, and what
parts were not? If we're not using nullable values, an explicit
empty string and a value never being set are identical - and we
can't tell if it's safe to grab a default from the server's
containers.conf.

Fortunately, we only really need to do this for booleans. An
empty string is sufficient to tell us that a string was unset
(even if the user explicitly gave us an empty string for an
option, filling in a default from the config file is acceptable).
This makes things a lot simpler. My initial attempt at this
changed everything, including strings, and it was far larger and
more painful.

Also, begin the first steps of removing all uses of
containers.conf defaults from client-side. Two are gone entirely,
the rest are marked as remove-when-possible.

[NO NEW TESTS NEEDED] This is just a refactor.

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-01-30 10:42:24 -05:00
Daniel J Walsh 8d14d41555
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-01-28 07:30:52 -05:00
Giuseppe Scrivano 93510a299d
bindings: suggest using -tags remote to reduce file size
Closes: https://github.com/containers/podman/issues/12548

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano f18ebad1e6
bindings: pods uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano 668d517af9
bindings: volumes uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano df6cc8550d
bindings: secrets uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano aee733c581
bindings: network uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano c736a8e20a
bindings: manifests uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano 34cc557411
bindings: play uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano 5284149708
bindings: generate uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano 5ddc82f7a2
bindings: images uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:37 +01:00
Giuseppe Scrivano 7aede410da
bindings: containers/update uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 40cc962a5d
bindings: containers/exec uses directly Docker type
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 88fb291a39
bindings: containers/create uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 6c5704a09c
bindings: containers/containers uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 2d8231efe8
bindings: containers/commit uses directly Docker type
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 9f0ea0dc87
bindings: containers/checkpoint uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano b304ac1ea8
bindings: containers/archive uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 9231234203
domain: move system structs to types sub-package
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
Giuseppe Scrivano 48a99c6514
domain: move Event to types sub-package
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:35 +01:00
Philip Dubé 522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
Oleksandr Redko 8bdf77aa20 Refactor: replace StringInSlice with slices.Contains
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 16:25:56 +02:00
Oleksandr Redko 2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
openshift-merge-bot[bot] c47962802a
Merge pull request #20657 from nalind/commit-config
RHEL-14922: accept a config blob alongside the "changes" slice when committing
2023-12-01 21:09:23 +00:00
Nalin Dahyabhai 426db6fcc1 Accept a config blob alongside the "changes" slice when committing
When committing containers to create new images, accept a container
config blob being passed in the body of the API request by adding a
Config field to our API structures.  Populate it from the body of
requests that we receive, and use its contents as the body of requests
that we make.

Make the libpod commit endpoint split changes values at newlines, just
like the compat endpoint does.

Pass both the config blob and the "changes" slice to buildah's Commit()
API, so that it can handle cases where they overlap or conflict.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-11-30 09:00:52 -05:00
Paul Holzinger 86296ff8da
pkg/bindings: add new APIVersionError error type
When a new API call is added to the bindings we should guard it based on
the version and throw a useful error. Right now an old server that does
not implement a given endpoint would throw a "NOT FOUND" error which is
not good for callers.

Instead implement a custom error type to give a usefule error instead.
This allows bindings users to call errors.As() to know if they call and
to old version.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-29 15:31:42 +01:00
Paul Holzinger 93bcd2a25d
fix podman-remote exec regression with v4.8
Commit f48a706abc added a new API endpoint to remove exec session
correctly. And the bindings try to call that endpoint for exec every
time. Now since client and server must not be the same version this
causes a problem if a new 4.8 client calls an older 4.7 server as it has
no idea about such endpoint and throws an ugly error. This is a common
scenario for podman machine setups.

The client does know the server version so it should make sure to not
call such endpoint if the server is older than 4.8.

I added a exec test to the machine tests as this can be reproduced with
podman machine as at the moment at least the VM image does not contain
podman 4.8. And it should at least make sure podman exec keeps working
for podman machine without regressions.

Fixes #20821

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-29 13:22:46 +01:00
Ed Santiago 047da19b5f (Temporary) Emergency CI fix: quay search is broken
Someone please revert this once quay search is fixed.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-11-13 06:52:10 -07:00
Brent Baude 78798cab00 Automatic code cleanups - JetBrains
A bunch of cleanups as suggested by linters/etc in JetBrains IDE.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-07 14:05:15 -06:00
Daniel J Walsh af0ef47f0c
Add status messages to podman --remote commit
Fixes: https://github.com/containers/podman/issues/19947

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-01 14:31:09 -04:00
openshift-ci[bot] 377644640a
Merge pull request #20476 from rhatdan/build
podman build --remote URI Dockerfile should not be treated as file
2023-10-31 07:49:59 +00:00
Daniel J Walsh a1577ec7b0
podman build --remote URI Dockerfile shoud not be treated as file
Podman build --remote is translating https://path as if it was a file
path. This change will leave it as a URL so it can be parsed on the
server side.

Fixed: https://github.com/containers/podman/issues/20475

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 15:10:18 -04:00
Daniel J Walsh 91df369ae6
podman kube play --replace should force removal of pods and containers
Fixes: https://github.com/containers/podman/issues/20025

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 07:29:53 -04:00
Urvashi Mohnani ebe01ca292 Add e2e tests for farm build
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-24 17:32:47 -04:00
Urvashi Mohnani dd8f57a3b4 Add podman farm build command
Add podman farm build command that sends out builds to
nodes defined in the farm, builds the images on the farm
nodes, and pulls them back to the local machine to create
a manifest list.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-24 12:58:39 -04:00
Giuseppe Scrivano f48a706abc
remote: exec: do not leak session IDs on errors
commit fa19e1baa2 partially introduced
the fix, but was merged too quickly and didn't work with remote.

Introduce a new binding to allow removing a session from the remote
client.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-19 11:34:36 +02:00
Daniel J Walsh 9637fed2fd
Fix output of podman --remote top
Allow users to specify

podman-remote top $cid -eo "pid comm"
or
podman-remote top $cid -eo pid,comm

Fixes: https://github.com/containers/podman/issues/19176

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

didid#	new file:   test/system/085-top.bats

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-16 17:25:10 -04:00
Aditya R 5db3b753af
remote,build: wire unsetlabels
Signed-off-by: Aditya R <arajan@redhat.com>
2023-10-16 15:34:02 +05:30
Aleksei Kosyrev 3fdb6ee2df Don't ignore containerfiles outside of build context
[NO NEW TESTS NEEDED]

Signed-off-by: Aleksei Kosyrev <albnnc@gmail.com>
2023-10-06 16:00:13 +03:00
Peter Werner f52b02f406 Fix all ports exposed by kube play
Container ports defined with containerPort were exposed by default
even though kubernetes interprets them as mostly informative.
Closes #17028

Signed-off-by: Peter Werner <wpw.peter@gmail.com>
2023-09-23 19:53:46 +02:00
Daniel J Walsh 73dc72f80d
vendor of containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-20 08:39:49 -04:00
Daniel J Walsh 03dd5f2568
Fix specification of unix:///run
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-17 07:37:14 -04:00
Paul Holzinger 6b7f718b4b
wire in new buildah build options
Add support for --layerLabel.
Support for --cw is only added for the local client. I am not sure how
I would wire this over remote. The current code parse the options in
the frontend which hard codes the Tmpdir field to an incorrect value if
we would json marshal this vie remote API so it would not work in real
remote cases.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-14 11:21:00 +02:00
Miloslav Trmač a3c2d6ad2e Remove a dependency on libimage from pkg/bindings
... by updating for a c/common API change.

[NO NEW TESTS NEEDED]: Only moves unchanged code,
should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-08-29 12:45:55 +02:00
Yiliang Yang f1c24df4f6 Rename parameter in pkg/bindings
In `pkg/bindings/containers/ResizeExecTTY`, `sessionID` is the actual required
parameter, instead of `nameOrId`.

[NO NEW TESTS NEEDED]

Signed-off-by: Yiliang Yang <yangyiliang@gmail.com>
2023-08-28 18:26:59 -04:00
OpenShift Merge Robot dd2ec7c613
Merge pull request #19640 from flouthoc/force-compression
push/manifest-push: add support for `--force-compression` to prevent reusing other blobs
2023-08-28 16:49:31 +02:00
Urvashi Mohnani 52ed7fce2a Add infra-name annotations to kube gen/play
Add io.podman.annotations.infra.name annotation to kube play so
users can set the name of the infra container created.
When a pod is created with --infra-name set, the generated
kube yaml will have an infraName annotation set that will
be used when playing the generated yaml with podman.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-24 11:29:56 -04:00
Aditya R 469ace0910
push: add support for --force-compression
Adds support for --force-compression which allows end-users to force
push blobs with the selected compresison in --compression option, in
order to make sure that blobs of other compression on registry are not
reused.

Is equivalent to: force-compression here: https://docs.docker.com/build/exporters/#compression

Closes: https://github.com/containers/podman/issues/18660

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-24 13:35:58 +05:30
Aditya R 346f9cb4ed
manifest/push: add support for --add-compression
Adds support for --add-compression which accepts multiple compression
formats and when used it will add all instances in a manifest list with
requested compression formats.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-03 14:20:38 +05:30
Romain Geissler 4ee31dc37f
Don't log EOF error when using podman --remote build with an empty context directory.
Closes #15921.

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
2023-07-31 12:00:01 +00:00