Commit Graph

19 Commits

Author SHA1 Message Date
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 5736649eb8
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-21 09:52:12 -05: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č 5bbcfaf4aa Make XRegistryAuthHeader and XRegistryConfigHeader private
... now that they have no public users.

Also remove the HeaderAuthName type, we don't need the type-safety
so much for private constants, and using plain strings results in
less visual noise.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:27 +01:00
Miloslav Trmač 3cfefa1248 Remove the authfile parameter of MakeXRegistryAuthHeader
Having a parameter that modifies the provides types.SystemContext
seems rather unexpected and risky to have around - and the only
user of that is actually a no-op, others only provide a nil
SystemContext; so, remove that option and simplify (well, somewhat;
many callers now have extra &types.SystemContext{AuthFilePath}
boilerplate; at least that's consistent with that code carrying
a TODO to create a larger-scope SystemContext).

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:27 +01:00
Miloslav Trmač f9be326274 Remove the authfile parameter of MakeXRegistryConfigHeader
Having a parameter that modifies the provides types.SystemContext
seems rather unexpected and risky to have around - and the only
user of that is actually a no-op; so, remove that option and simplify.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:26 +01:00
Miloslav Trmač 935dcbb008 Remove no-longer-useful name variables
which used to contain more context, but now are just
a pointless copy.

Should not change (test) behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:25 +01:00
Miloslav Trmač 0e29b89753 Consolidate creation of SystemContext with auth.json into a helper
Should not change (test) behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:25 +01:00
Miloslav Trmač fe1230ef70 Remove pkg/auth.Header
It is no longer used.

Split the existing tests into MakeXRegistryConfigHeader
and MakeXRegistryAuthHeader variants. For now we don't modify
the implementations at all, to make review simpler; cleanups
will follow.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:24 +01:00
Miloslav Trmač 1ecc6ba728 Pass a header value directly to parseSingleAuthHeader and parseMultiAuthHeader
Both have a single caller, so there's no point in looking up
the header value twice.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:19 +01:00
Miloslav Trmač 7674f2f76b Simplify the interface of parseSingleAuthHeader
Don't create a single-element map only for the only caller
to laboriously extract an element of that map; just return
a single entry.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:18 +01: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
Miloslav Trmač 491951d66e Fix normalizeAuthFileKey to use the correct semantics
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:17 +01:00
Miloslav Trmač d29a4a6d17 Add TestHeaderGetCredentialsRoundtrip
... as an end-to-end unit test of the header creation/parsing
code.

Leave the docker.io and docker.io/vendor test cases commented out,
because they are currently failing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:15 +01:00
Miloslav Trmač ad7e5e34f2 Add tests for auth.Header
Just a single function that handles all of Header,
headerConfig and headerAuth; we will split that later.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:16:14 +01:00
Miloslav Trmač 5a5aa6009f Improve TestAuthConfigsToAuthFile
Remove the created temporary file.

Use more appropriate assertion calls.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:09:55 +01:00
Miloslav Trmač ff003928b2 Add unit tests for singleAuthHeader
Also rename it to parseSingleAuthHeader

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:09:55 +01:00
Miloslav Trmač b162d8868c Add unit tests for multiAuthHeader
Also rename it to parseMultiAuthHeader.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-10 18:09:55 +01:00
Sascha Grunert bbdaf837b1
Normalize auth key before calling `SetAuthentication`
Recent changes in c/image caused the `SetAuthentication` API to be more
restrictive in terms of validating the `key` (`server`) input. To ensure
that manually modified or entries in `~/.docker/config.json` still work,
we now strip the leading `http[s]://` prefix.

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

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-09-09 09:17:22 +02:00