mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
client/distribution_inspect: Wrap options and result
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -99,7 +99,7 @@ type ExecAPIClient interface {
|
||||
|
||||
// DistributionAPIClient defines API client methods for the registry
|
||||
type DistributionAPIClient interface {
|
||||
DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
|
||||
DistributionInspect(ctx context.Context, image string, options DistributionInspectOptions) (DistributionInspectResult, error)
|
||||
}
|
||||
|
||||
// ImageAPIClient defines API client methods for the images
|
||||
|
||||
@@ -9,16 +9,26 @@ import (
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
)
|
||||
|
||||
// DistributionInspectResult holds the result of the DistributionInspect operation.
|
||||
type DistributionInspectResult struct {
|
||||
registry.DistributionInspect
|
||||
}
|
||||
|
||||
// DistributionInspectOptions holds options for the DistributionInspect operation.
|
||||
type DistributionInspectOptions struct {
|
||||
EncodedRegistryAuth string
|
||||
}
|
||||
|
||||
// DistributionInspect returns the image digest with the full manifest.
|
||||
func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error) {
|
||||
func (cli *Client) DistributionInspect(ctx context.Context, imageRef string, options DistributionInspectOptions) (DistributionInspectResult, error) {
|
||||
if imageRef == "" {
|
||||
return registry.DistributionInspect{}, objectNotFoundError{object: "distribution", id: imageRef}
|
||||
return DistributionInspectResult{}, objectNotFoundError{object: "distribution", id: imageRef}
|
||||
}
|
||||
|
||||
var headers http.Header
|
||||
if encodedRegistryAuth != "" {
|
||||
if options.EncodedRegistryAuth != "" {
|
||||
headers = http.Header{
|
||||
registry.AuthHeader: {encodedRegistryAuth},
|
||||
registry.AuthHeader: {options.EncodedRegistryAuth},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +36,10 @@ func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedReg
|
||||
resp, err := cli.get(ctx, "/distribution/"+imageRef+"/json", url.Values{}, headers)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
return registry.DistributionInspect{}, err
|
||||
return DistributionInspectResult{}, err
|
||||
}
|
||||
|
||||
var distributionInspect registry.DistributionInspect
|
||||
err = json.NewDecoder(resp.Body).Decode(&distributionInspect)
|
||||
return distributionInspect, err
|
||||
return DistributionInspectResult{DistributionInspect: distributionInspect}, err
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ func TestDistributionInspectWithEmptyID(t *testing.T) {
|
||||
return nil, errors.New("should not make request")
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
_, err = client.DistributionInspect(context.Background(), "", "")
|
||||
_, err = client.DistributionInspect(context.Background(), "", DistributionInspectOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
}
|
||||
|
||||
@@ -123,7 +123,9 @@ func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, tas
|
||||
}
|
||||
|
||||
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
||||
distributionInspect, err := cli.DistributionInspect(ctx, image, encodedAuth)
|
||||
distributionInspect, err := cli.DistributionInspect(ctx, image, DistributionInspectOptions{
|
||||
EncodedRegistryAuth: encodedAuth,
|
||||
})
|
||||
var platforms []swarm.Platform
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
|
||||
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -99,7 +99,7 @@ type ExecAPIClient interface {
|
||||
|
||||
// DistributionAPIClient defines API client methods for the registry
|
||||
type DistributionAPIClient interface {
|
||||
DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
|
||||
DistributionInspect(ctx context.Context, image string, options DistributionInspectOptions) (DistributionInspectResult, error)
|
||||
}
|
||||
|
||||
// ImageAPIClient defines API client methods for the images
|
||||
|
||||
22
vendor/github.com/moby/moby/client/distribution_inspect.go
generated
vendored
22
vendor/github.com/moby/moby/client/distribution_inspect.go
generated
vendored
@@ -9,16 +9,26 @@ import (
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
)
|
||||
|
||||
// DistributionInspectResult holds the result of the DistributionInspect operation.
|
||||
type DistributionInspectResult struct {
|
||||
registry.DistributionInspect
|
||||
}
|
||||
|
||||
// DistributionInspectOptions holds options for the DistributionInspect operation.
|
||||
type DistributionInspectOptions struct {
|
||||
EncodedRegistryAuth string
|
||||
}
|
||||
|
||||
// DistributionInspect returns the image digest with the full manifest.
|
||||
func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error) {
|
||||
func (cli *Client) DistributionInspect(ctx context.Context, imageRef string, options DistributionInspectOptions) (DistributionInspectResult, error) {
|
||||
if imageRef == "" {
|
||||
return registry.DistributionInspect{}, objectNotFoundError{object: "distribution", id: imageRef}
|
||||
return DistributionInspectResult{}, objectNotFoundError{object: "distribution", id: imageRef}
|
||||
}
|
||||
|
||||
var headers http.Header
|
||||
if encodedRegistryAuth != "" {
|
||||
if options.EncodedRegistryAuth != "" {
|
||||
headers = http.Header{
|
||||
registry.AuthHeader: {encodedRegistryAuth},
|
||||
registry.AuthHeader: {options.EncodedRegistryAuth},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +36,10 @@ func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedReg
|
||||
resp, err := cli.get(ctx, "/distribution/"+imageRef+"/json", url.Values{}, headers)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
return registry.DistributionInspect{}, err
|
||||
return DistributionInspectResult{}, err
|
||||
}
|
||||
|
||||
var distributionInspect registry.DistributionInspect
|
||||
err = json.NewDecoder(resp.Body).Decode(&distributionInspect)
|
||||
return distributionInspect, err
|
||||
return DistributionInspectResult{DistributionInspect: distributionInspect}, err
|
||||
}
|
||||
|
||||
4
vendor/github.com/moby/moby/client/service_create.go
generated
vendored
4
vendor/github.com/moby/moby/client/service_create.go
generated
vendored
@@ -123,7 +123,9 @@ func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, tas
|
||||
}
|
||||
|
||||
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
||||
distributionInspect, err := cli.DistributionInspect(ctx, image, encodedAuth)
|
||||
distributionInspect, err := cli.DistributionInspect(ctx, image, DistributionInspectOptions{
|
||||
EncodedRegistryAuth: encodedAuth,
|
||||
})
|
||||
var platforms []swarm.Platform
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
|
||||
Reference in New Issue
Block a user