Commit Graph

58 Commits

Author SHA1 Message Date
Brent Baude bd061aa2d5 Add type and annotations to artifact add
podman artifact add now supports two new command line switches.

--type string that describes the type of artifact
--annotation string slice in the form of key=val

These new options allow users to "tag" information in on their artifacts
for any number of purposes down the line

RUN-2446

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-01-31 09:53:03 -06:00
Daniel J Walsh 5181becfde
Add podman manifest rm --ignore
When removing manifests, users should be allowed to ignore
ones that no longer exists.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2025-01-22 11:43:47 -05:00
Paul Holzinger e9fb805522
update golangci/golangci-lint to v1.63.4
Fix new issues found by usetesting, mainly we should use t.TempDir() in
test which makes the code better as this will be removed on test end
automatically so no need for defer or any error checking.
Also fix issues reported by exptostd, these mainly show where we can
switch the imports to the std maps/slices packages instead of the
golang.org/x/exp/... packages.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-07 15:48:53 +01:00
Nalin Dahyabhai 0a4885610d manifest annotate: connect IndexAnnotations
Add the connective logic so that annotating the manifest as a whole will
succeed as intended, and we don't mix up annotations for an entry and
annotations which are meant for the manifest as a whole.  Make
consistent the names which are used when encoding values of certain
fields.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-06 15:43:00 -05:00
Paul Holzinger 942f789a88
set !remote build tags where needed
The new golangci-lint version 1.60.1 has problems with typecheck when
linting remote files. We have certain pakcages that should never be
inlcuded in remote but the typecheck tries to compile all of them but
this never works and it seems to ignore the exclude files we gave it.

To fix this the proper way is to mark all packages we only use locally
with !remote tags. This is a bit ugly but more correct. I also moved the
DecodeChanges() code around as it is called from the client so the
handles package which should only be remote doesn't really fit anyway.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:28 +02:00
Daniel J Walsh a06a7d7ba8
Should not force conversion of manifest type to DockerV2ListMediaType
Fixes: https://github.com/containers/podman/issues/23163

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-08-07 06:07:46 -04:00
Nalin Dahyabhai f168b3c115 podman manifest add: support creating artifact manifest on the fly
Add a --artifact flag to `podman manifest add` which can be used to
create an artifact manifest for one or more files and attach it to a
manifest list.  Corresponding --artifact-type, --artifact-config-type,
--artifact-config, --artifact-layer-type, --artifact-subject, and
--artifact-exclude-titles options can be used to fine-tune the fields in
the artifact manifest that don't refer to the files themselves.

Add a --index option to `podman manifest annotate` that will cause
values passed to the --annotation flag to be applied to the manifest
list as a whole instead of to an entry in the list.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-29 11:47:44 -05: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
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
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
OpenShift Merge Robot 8bda49608f
Merge pull request #19696 from Luap99/api-stream-format
api docs: document stream format
2023-08-28 19:43:24 +02:00
Aditya R 0938ee1899
push, manifest-push: --force-compression must be true with --compression-format
Value of `--force-compression` should be already `true` is
`--compression-format` is selected otherwise let users decide.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-28 16:41:13 +05:30
Paul Holzinger 243f365aa4
create apiutils package
Move SupportedVersion() and IsLibpodRequest() to separate package to
avoid import cycle when using it in libpod.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-24 16:19:50 +02:00
Aditya R 82bd56be74
manifest-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.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-24 13:36:04 +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
Valentin Rothberg a69194b02f manifest inspect: support authentication
Previous tests have worked by pure chance since the client and server
ran on the same host; the server picked up the credentials created by
the client login.

Extend the gating tests and add a new integration test which is further
capable of exercising the remote code.

Note that fixing authentication support requires adding a new
`--authfile` CLi flag to `manifest inspect`.  This will at least allow
for passing an authfile to be bindings.  Username and password are not
yet supported.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-07-10 16:26:19 +02:00
Giuseppe Scrivano bb932cc840
cmd, push: expose --compression-level
This patch adds the --compression-level option to the push command.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-21 14:28:16 +02:00
Toshiki Sonoda a4ba5f449f Add support for podman-remote manifest annotate
Now that podman manifest annotate is supported
in the remote environment.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-11-24 14:11:08 +09:00
Toshiki Sonoda f807b6784f remote: fix manifest add --annotation
* `manifest add --annotation option` adds annotations
  field on remote environment.
* `manifest inspect` prints annotations field
  on remote environment.

Fixes: #15952

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-11-09 13:24:09 +09:00
Daniel J Walsh 274d0f4956
Add --insecure,--tls-verify,--verbose flags to podman manifest inspect
--insecure and --verbose flags for docker compatibility

--tls-verify for syntax compatibility and allow users to inspect
manifests at remote Container Registiries without requiring tls.

Helps fix: https://github.com/containers/podman/issues/14917

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-03 08:00:15 -04:00
Paul Holzinger e2fe9eabac
Revert "remote: fix manifest add --annotation"
This reverts commit 32f54a81ed.

`pkg/bindings` is supported outside of podman and we have to keep it
stable.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-29 14:16:42 +02:00
Toshiki Sonoda 32f54a81ed remote: fix manifest add --annotation
* `manifest add --annotation option` adds annotations
  field on remote environment.
* `manifest inspect` prints annotations field
  on remote environment.

Fixes: #15952

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-09-29 18:14:41 +09:00
Chris Evich d968f3fe09
Replace deprecated ioutil
Package `io/ioutil` was deprecated in golang 1.16, preventing podman from
building under Fedora 37.  Fortunately, functionality identical
replacements are provided by the packages `io` and `os`.  Replace all
usage of all `io/ioutil` symbols with appropriate substitutions
according to the golang docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-09-20 15:34:27 -04:00
Daniel J Walsh 2c63b8439b
Fix stutters
Podman adds an Error: to every error message.  So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-10 07:52:00 -04:00
Vladimir Kochnev e48681e600
Use request Context() in API handlers
Request object has its own context which must be used during a request
lifetime instead of just context.Background()

[NO NEW TESTS NEEDED]

Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
2022-08-18 23:48:43 +03:00
Nalin Dahyabhai 7e7a79b075 podman manifest create: accept --amend and --insecure flags
Accept a --amend flag in `podman manifest create`, and treat
`--insecure` as we would `--tls-verify=false` in `podman manifest`'s
"add", "create", and "push" subcommands.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-08-16 19:45:36 -04:00
Naoto Kobayashi a4efd401cd remote manifest push: show copy progress
`podman-remote manifest push` has shown absolutely no progress at all.
Fix that by doing the same as the remote-push code does.

Like remote-push, `quiet` parameter is true by default for backwards
compatibility.

Signed-off-by: Naoto Kobayashi <naoto.kobayashi4c@gmail.com>
2022-08-11 20:35:13 +09:00
Romain Geissler 24a599fe1d Add flag "--compression-format" to "podman manifest push" both in local/remote mode.
Also Fix usage of flag "--compression-format" for remote "podman image push". Fix usage of flags "--format", "--remove-signatures" in remote "podman manifest push".
Closes #15109.

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
2022-07-30 15:10:41 +00:00
Vladimir Kochnev 52a4642edd
Set TLSVerify=true by default for API endpoints
Option defaults in API must be the same as in CLI.

```
% podman image push --help
% podman image pull --help
% podman manifest push --help
% podman image search --help
```

All of these CLI commands them have --tls-verify=true by default:
```
--tls-verify  require HTTPS and verify certificates when accessing the registry (default true)
```

As for `podman image build`, it doesn't have any means to control
`tlsVerify` parameter but it must be true by default.

Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
2022-07-26 02:07:56 +03:00
Sascha Grunert a46f798831
pkg: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

[NO NEW TESTS NEEDED]

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-08 08:54:47 +02:00
Daniel J Walsh 48cf1d2583
podman-remote push --remove-signatures support
I don't see a reason why we don't support --remove-signatures
from remote push, so adding support.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-06-10 07:14:12 -04:00
Vladimir Kochnev e41d4a2471
Add missing tests for manifests API
Also:
 - It fixes a regression in parsing "images" parameter in
   ManifestAddV3 handler.
 - Refactors 12-imagesMore.at to use start_registry helper.
 - Removes some unsafe "exit 1" statements which skip clean up.

Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
2022-06-07 14:20:46 +03:00
Jhon Honce 5b79cf15a0 Swagger refactor/cleanup
* Remove duplicate or unused types and constants
* Move all documetation-only models and responses into swagger package
* Remove all unecessary names, go-swagger will determine names from
  struct declarations
* Use Libpod suffix to differentiate between compat and libpod models
  and responses. Taken from swagger:operation declarations.
* Models and responses that start with lowercase are for swagger use
  only while uppercase are used "as is" in the code and swagger comments
* Used gofumpt on new code

```release-note

```

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-05-19 15:24:18 -07:00
Paul Holzinger e9599fb1ae
fix manifest modify endpoint to respect tlsverify param
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-27 14:32:36 +02:00
Paul Holzinger 1514d5c933
silence deprecated warnings for manifest functions
There is no reason to mark them directly as deprecated since we still
have to use them as long as we want to support 3.X calls. The
staticcheck linter is complaining about the Deprecated comment but that
doesn't make sense in this context. There is no good way to only exclude
a single check with golangci-lint.

I renamed the function with a V3 suffix to make clear that we only use
this for backwards compat.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:41 +02:00
Paul Holzinger 2a8e435671
enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
OpenShift Merge Robot 56b2937f87
Merge pull request #13653 from jmontleon/fix-manifest-push-header
Resolves #13629 Add RegistryAuthHeader to manifest push
2022-03-27 13:13:42 +02:00
jason 3cc1739373 Resolves #13629 Add RegistryAuthHeader to manifest push
Signed-off-by: Jason Montleon <jmontleo@redhat.com>
2022-03-26 16:39:11 -04:00
Jhon Honce a6504963b3 Fix manifest 4.0 endpoints
[NO NEW TESTS NEEDED]

* Branch forced 4.0 only endpoints, which broke bindings
* Fix lint error, in new code

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-03-23 10:19:36 -07:00
Jakub Guzik 7938f32c53 Remove unused param and clean API handlers
This commit removes error message string from utils.Error in pkg/api.
Param was not used inside a function for quite a long time
[NO NEW TESTS NEEDED]

Signed-off-by: Jakub Guzik <jguzik@redhat.com>
2022-01-22 00:31:18 +01:00
Valentin Rothberg bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
Jhon Honce 8a7e70919f Refactor manifest list operations
* Update method/function signatures use the manifest list name and
  images associated with the operation explicitly, in general

  func f(ctx context.Context, manifestListName string,
         ImageNames []string, options *fOptions)

* Leverage gorilla/mux Subrouters to support API v3.x and v4.x for
  manifests
* Make manifest API endpoints more RESTful
* Add PUT /manifest/{id} to update existing manifests
* Add manifests.Annotate to go bindings, uncommented unit test
* Add DELETE /manifest/{Id} to remove existing manifest list, use
  PUT /manifest/{id} to remove images from a list
* Deprecated POST /manifest/{id}/add and /manifest/{id}/remove, use
  PUT /manifest/{id} instead
* Corrected swagger godoc and updated to cover API changes
* Update podman manifest commands to use registry.Context()
* Expose utils.GetVar() to obtain query parameters by name
* Unexpose server.registerSwaggerHandlers, not sure why this was ever
  exposed.
* Refactored code to use http.Header instead of map[string]string when
  operating on HTTP headers.
* Add API-Version header support in bindings to allow calling explicate
  versions of the API. Header is _NOT_ forwarded to the API service.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-01-14 16:13:35 -07:00
Miloslav Trmač 2aeb690d37 Don't return a header name from auth.GetCredentials
Almost every caller is using it only to wrap an error
in exactly the same way, so move that error context into GetCredentials
and simplify the users.

(The one other caller, build, was even wrapping the error incorrectly
talking about query parameters; so let it use the same text as the others.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:18 +01:00
Jhon Honce deaf969243 Refacter API server emphasis on logging
* To aid in debugging log API request and response bodies at trace
  level. Events can be correlated using the X-Reference-Id.
* Server now echos X-Reference-Id from client if set, otherwise
  generates an unique id.
* Move logic for X-Reference-Id into middleware
* Change uses of Header.Add() to Set() when setting Content-Type
* Log API operations in Apache format using gorilla middleware
* Port server code to use BaseContext and ConnContext

Fixes #10053

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-09-10 15:07:25 -07:00
Valentin Rothberg fb4a0c572e support tag@digest notation
Vendor in the latest HEAd of containers/common to implicitly support the
tag@digest notation for images.  To remain compatible with Docker, the
tag will be stripped off the image reference and is entirely ignored.

Fixes: #6721
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-31 14:38:43 +02:00
Valentin Rothberg 0f7d54b026 migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces
`libpod/image` and a lot of glue code entirely.

Note that I tried to leave bread crumbs for changed tests.

Miscellaneous changes:

 * Some errors yield different messages which required to alter some
   tests.

 * I fixed some pre-existing issues in the code.  Others were marked as
   `//TODO`s to prevent the PR from exploding.

 * The `NamesHistory` of an image is returned as is from the storage.
   Previously, we did some filtering which I think is undesirable.
   Instead we should return the data as stored in the storage.

 * Touched handlers use the ABI interfaces where possible.

 * Local image resolution: previously Podman would match "foo" on
   "myfoo".  This behaviour has been changed and Podman will now
   only match on repository boundaries such that "foo" would match
   "my/foo" but not "myfoo".  I consider the old behaviour to be a
   bug, at the very least an exotic corner case.

 * Futhermore, "foo:none" does *not* resolve to a local image "foo"
   without tag anymore.  It's a hill I am (almost) willing to die on.

 * `image prune` prints the IDs of pruned images.  Previously, in some
   cases, the names were printed instead.  The API clearly states ID,
   so we should stick to it.

 * Compat endpoint image removal with _force_ deletes the entire not
   only the specified tag.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-05 11:30:12 +02:00
Jhon Honce d41c33eb91 Update manifest API endpoints
* Add validation for manifest name
* Always return an array for manifests even if empty
* Add missing return in df handler when returning error. Caused an
  additional null to be written to client crashing python decoder.

When c/image is refactored to include manifests, manifest endpoints should
be revisited.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-04-09 11:00:06 -07:00
Valentin Rothberg 5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01:00
Daniel J Walsh 84f7bdc4db
Switch podman image push handlers to use abi
Change API Handlers to use the same functions that the
local podman uses.

At the same time:

Cleanup and pass proper bindings.  Remove cli options from
podman-remote push.  Cleanup manifest push.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-27 09:27:25 -05:00
Paul Holzinger 6e6a38b416 podman manifest exists
Add podman manifest exists command with remote support.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-01-22 20:19:13 +01:00