mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
imagetools inspect: add --format flag
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@ -14,7 +14,10 @@ import (
|
||||
"github.com/docker/buildx/util/resolver"
|
||||
clitypes "github.com/docker/cli/cli/config/types"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/moby/buildkit/util/contentutil"
|
||||
"github.com/moby/buildkit/util/imageutil"
|
||||
"github.com/moby/buildkit/util/tracing"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -29,14 +32,16 @@ type Opt struct {
|
||||
}
|
||||
|
||||
type Resolver struct {
|
||||
auth docker.Authorizer
|
||||
hosts docker.RegistryHosts
|
||||
auth docker.Authorizer
|
||||
hosts docker.RegistryHosts
|
||||
buffer contentutil.Buffer
|
||||
}
|
||||
|
||||
func New(opt Opt) *Resolver {
|
||||
return &Resolver{
|
||||
auth: docker.NewDockerAuthorizer(docker.WithAuthCreds(toCredentialsFunc(opt.Auth)), docker.WithAuthClient(http.DefaultClient)),
|
||||
hosts: resolver.NewRegistryConfig(opt.RegistryConfig),
|
||||
auth: docker.NewDockerAuthorizer(docker.WithAuthCreds(toCredentialsFunc(opt.Auth)), docker.WithAuthClient(http.DefaultClient)),
|
||||
hosts: resolver.NewRegistryConfig(opt.RegistryConfig),
|
||||
buffer: contentutil.NewBuffer(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,3 +162,11 @@ func RegistryAuthForRef(ref string, a Auth) (string, error) {
|
||||
}
|
||||
return base64.URLEncoding.EncodeToString(buf), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) ImageConfig(ctx context.Context, in string) (digest.Digest, []byte, error) {
|
||||
in, _, err := r.Resolve(ctx, in)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return imageutil.Config(ctx, in, r.resolver(), r.buffer, nil, nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user