Looks like it picked up new deprecated matches so we need some more
nolint to silence them where we still need them for backwards compat in
the API.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Existing KillContainer handling uses HTTP status code 409 when the request cannot be performed because of the current container state. HTTP status code 404 is also used when the target container does not exist.
In contrast, errors from the stats handler are not reflected in the HTTP status code. The HTTP status code is always 200, and the errors are recorded only as generic errors in the server log.
To maintain compatibility with both streaming enabled and disabled, this change treats obtaining at least one complete unit of response content as the response contract. It then keeps the response content consistent with the HTTP status code.
Signed-off-by: Hiroaki KAWAI <hiroaki.kawai@gmail.com>
Since I use go 1.26 the go fix does not have all the rules built in,
there are newer ones in modernize so run the explicitly to fix more code
for go 1.26.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Docker API v1.44 now includes status properties
in Runtimes for the GET /info endpoint.
Read output of {oci_runtime_cmd} features command
lazily and expose the JSON
output as-is (with removed new lines and
whitespace) as the status field in GET
/info for v1.44+.
Add status to libpod GET /info in ociRuntime.features
and `podman info` (shared).
Add API tests for both endpoints.
Fixes: https://redhat.atlassian.net/browse/RUN-3319
Signed-off-by: Marek Simek <msimek@redhat.com>
RestartContainer was always setting options.Timeout with values
from query, without checking if the caller had specified them or if
they were simply zero values. Copy logic from StopContainer to check
for caller-specified values, leaving Timeout nil if not specified.
fixes: https://github.com/podman-container-tools/podman/issues/29276
Signed-off-by: Garry Lawrence <InvalidInterrupt@users.noreply.github.com>
Two commands can set a subject on a manifest list, podman manifest annotate --index --subject and podman manifest add --artifact-subject. Both work locally, but they do nothing at all when podman runs with --remote.
The value never leaves the client. Before sending the request the remote client copies everything into manifests.ModifyOptions and manifests.AddArtifactOptions, and neither struct had a field to hold the subject, so it was quietly thrown away. The server had a second problem of its own, ManifestModify rebuilds ManifestAddArtifactOptions by hand and left out the embedded ManifestAnnotateOptions, so --os, --arch and --annotation were being dropped there as well.
Add the missing field to both structs, fill it in from the tunnel ImageEngine, and let the handler pass the annotate options along. Also add two system tests that run both flags for real so the remote path stays covered.
Signed-off-by: Anisha Khairnar <anishakhairnar284@gmail.com>
When pushing a manifest list, --platform=OS[/Arch[/Variant]] selects and pushes a single platform-specific manifest instead of the entire list.
Also, update compat POST /images/{name}/push to support the platform param (Compat v1.46)
Signed-off-by: Ashley Cui <acui@redhat.com>
The `until` filter was missing from the documentation.
Document it for both GET /libpod/images/json and the
compat GET /images/json.
Add tests for the until filter exercising both endpoints.
Fixes: https://redhat.atlassian.net/browse/RUN-3316
Signed-off-by: Marek Simek <msimek@redhat.com>
When a container has --memory-reservation set without --memory-limit,
resources.Memory is non-nil but resources.Memory.Limit is nil. The
compat stats handler dereferences the nil Limit pointer, causing a
panic that returns a 500 to the client.
Fix: add resources.Memory.Limit != nil guard before the dereference.
Regression test added in test/apiv2/19-stats.at.
Fixes#29627
Signed-off-by: Mehrdad Biukian Naeini <mehrdadbiukian@gmail.com>
filepath.Walk makes an expensive os.Stat system call on every file. filepath.WalkDir uses os.ReadDir under the hood to bypass this overhead, making directory scanning much faster.
Fixes: #29562
Signed-off-by: Vishnu Kothakapu <vishnukothakapu27@gmail.com>
The Docker-compat secret inspect endpoint was incorrectly honoring
the showsecret query parameter, which could expose plaintext secret
data to clients using the Docker-compatible API.
This restricts showsecret to libpod-only requests. Docker-compat
clients always receive redacted secret data, matching Docker's own
behavior.
Add APIv2 tests covering the showsecret behavior on both the
Docker-compat and libpod endpoints, confirming secret data is never
returned from the compat endpoint while libpod continues to honor
the flag.
Fixes: #29570
Signed-off-by: Davoud Azari <davidmotral@gmail.com>
The manifest push and create endpoints accept query parameters that
were never documented, so API users can't discover them.
Push was missing compressionFormat, compressionLevel, format and
removeSignatures. Create was missing annotation and annotations.
The wording matches the same parameters on the image push endpoint.
The deprecated v3 push and add endpoints are left alone.
Signed-off-by: Anisha Khairnar <anishakhairnar284@gmail.com>
POST /containers/create now takes Options as part of HostConfig.Mounts.TmpfsOptions to set options for tmpfs mounts.
Signed-off-by: Ashley Cui <acui@redhat.com>
ignore warn and strict modes for unknown yaml fields and kinds
ignore is the default and skips them warn reports them strict fails
warnings are returned in the play report so they show up in the cli and over the api for tools like podman desktop
Closes#18332
Signed-off-by: ROKUMATE <rohitkumawat0110@gmail.com>
The Docker API deprecates Container and ContainerConfig fields in
the GET /images/{name}/json response are deprecated and
they will no longer be included in API v1.45.
Fixes: https://redhat.atlassian.net/browse/RUN-3323
Signed-off-by: Marek Simek <msimek@redhat.com>
The Docker API 1.44 deprecates the fields HairpinMode, LinkLocalIPv6Address,
LinkLocalIPv6PrefixLen, SecondaryIPAddresses, SecondaryIPv6Addresses available in
NetworkSettings when calling GET /containers/{id}/json and will be removed in a future release.
You should instead look for the default network in NetworkSettings.Networks.
The fields are removed in 1.52. Version gate SecondaryIPAddresses, SecondaryIPv6Addresses
in the handler and update test. HairpinMode, LinkLocalIPv6Address, LinkLocalIPv6PrefixLen
are not returned by the compat endpoint as the response is serialized
to the moby/moby/api structure missing these fields.
Fixes: https://redhat.atlassian.net/browse/RUN-3323
Signed-off-by: Marek Simek <msimek@redhat.com>
The Docker API in version 1.44 deprecates the is_automated field for
the GET /images/search endpoint. The is_automated field has been deprecated
by Docker Hub's search API. Consequently, searching for is-automated=true
will yield no results.
The Docker API in version 1.44 deprecates the is_automated field
in the GET /images/search response and will always be set to false in the
future because Docker Hub is deprecating the is_automated field in its search API.
Return struct moby/api for the compat endpoint that matches the Docker
API response format and deprecates is_automated.
Update test_v2_0_0_image.py::ImageTestCase::test_search_compat
to verify returned format and fix subtests not being asserted (remove mp).
Fixes: https://redhat.atlassian.net/browse/RUN-3323
Signed-off-by: Marek Simek <msimek@redhat.com>
We currently only pass parsed excludes from the ignore file to buildah
and not the ignorefile path. This causes buildah to ignore
`--ignorefile` if the specified file is empty resulting in an empty
exludes. Forward ignoreFile to the server and allow overriding default
ignore files.
Signed-off-by: Danish Prakash <contact@danishpraka.sh>
The libpod manifest-create endpoint takes an "images" query parameter that
fills the new list at creation time, but 15-manifest.at never tested it.
Add cases that create a list with images= on both the v4
(/manifests/{name}, 201) and v3 (/manifests/create, 200) endpoints and
check the image ends up in the list.
Also drop the stale "required: true" from the images query parameter in the
swagger docs - the handler treats it as optional, and the existing create
tests (which omit it) already show that.
Fixes: #22258
Signed-off-by: Grzegorz Szczepanczyk <g.szczepanczyk@getprintbox.com>
The compat logs handler uses the tail query parameter both to select how
many log lines should be returned and as the capacity of the internal log
channel.
Only the former is part of the API semantics. The channel capacity should
not depend on a user-controlled value: negative values can produce an
invalid channel size, while very large values can cause excessive
allocation before any logs are read.
Use a small fixed-size buffer instead.
Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko00@bk.ru>