Skip to content

Commit

Permalink
Add --no-creds flag to skopeo inspect
Browse files Browse the repository at this point in the history
Follow PR containers#433
Close containers#421

Currently skopeo inspect allows to:
Use the default credentials in $HOME/.docker.config
Explicitly define credentials via de --creds flag

This implements a --no-creds flag which will query docker registries anonymously.

Signed-off-by: Qi Wang <[email protected]>
  • Loading branch information
juanluisvaladas authored and QiWang19 committed May 3, 2019
1 parent 0a2a62a commit 07287b5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cmd/skopeo/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type imageOptions struct {
tlsVerify optionalBool // Require HTTPS and verify certificates (for docker: and docker-daemon:)
sharedBlobDir string // A directory to use for OCI blobs, shared across repositories
dockerDaemonHost string // docker-daemon: host to connect to
noCreds bool // Access the registry anonymously
}

// imageFlags prepares a collection of CLI flags writing into imageOptions, and the managed imageOptions structure.
Expand Down Expand Up @@ -105,6 +106,11 @@ func imageFlags(global *globalOptions, shared *sharedImageOptions, flagPrefix, c
Usage: "use docker daemon host at `HOST` (docker-daemon: only)",
Destination: &opts.dockerDaemonHost,
},
cli.BoolFlag{
Name: flagPrefix + "no-creds",
Usage: "Access the registry anonymously",
Destination: &opts.noCreds,
},
}, &opts
}

Expand Down Expand Up @@ -132,13 +138,19 @@ func (opts *imageOptions) newSystemContext() (*types.SystemContext, error) {
if opts.tlsVerify.present {
ctx.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!opts.tlsVerify.value)
}
if opts.credsOption.present && opts.noCreds {
return nil, errors.New("creds and no-creds cannot be specified at the same time")
}
if opts.credsOption.present {
var err error
ctx.DockerAuthConfig, err = getDockerAuth(opts.credsOption.value)
if err != nil {
return nil, err
}
}
if opts.noCreds {
ctx.DockerAuthConfig = &types.DockerAuthConfig{}
}
return ctx, nil
}

Expand Down
4 changes: 4 additions & 0 deletions completions/bash/skopeo
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ _skopeo_copy() {
local boolean_options="
--dest-compress
--remove-signatures
--src-no-creds
--dest-no-creds
"

local transports="
Expand All @@ -73,6 +75,7 @@ _skopeo_inspect() {
local boolean_options="
--raw
--tls-verify
--no-creds
"

local transports="
Expand Down Expand Up @@ -115,6 +118,7 @@ _skopeo_delete() {
"
local boolean_options="
--tls-verify
--no-creds
"

local transports="
Expand Down
4 changes: 4 additions & 0 deletions docs/skopeo-copy.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec

**--src-cert-dir** _path_ Use certificates at _path_ (*.crt, *.cert, *.key) to connect to the source registry or daemon

**--src-no-creds** _bool-value_ Access the registry anonymously.

**--src-tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container source registry or daemon (defaults to true)

**--dest-cert-dir** _path_ Use certificates at _path_ (*.crt, *.cert, *.key) to connect to the destination registry or daemon

**--dest-no-creds** _bool-value_ Access the registry anonymously.

**--dest-ostree-tmp-dir** _path_ Directory to use for OSTree temporary files.

**--dest-tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container destination registry or daemon (defaults to true)
Expand Down
4 changes: 3 additions & 1 deletion docs/skopeo-delete.1.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% skopeo-delete(1)

## NAME
skopeo\-delete - Mark _image-name_ for deletion.
skopeo\-delete - Mark _image-name_ for deletion.

## SYNOPSIS
**skopeo delete** _image-name_
Expand Down Expand Up @@ -30,6 +30,8 @@ $ docker exec -it registry /usr/bin/registry garbage-collect /etc/docker-distrib

**--tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container registries (defaults to true)

**--no-creds** _bool-value_ Access the registry anonymously.

Additionally, the registry must allow deletions by setting `REGISTRY_STORAGE_DELETE_ENABLED=true` for the registry daemon.

## EXAMPLES
Expand Down
2 changes: 2 additions & 0 deletions docs/skopeo-inspect.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Return low-level information about _image-name_ in a registry

**--tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container registries (defaults to true)

**--no-creds** _bool-value_ Access the registry anonymously.

## EXAMPLES

To review information for the image fedora from the docker.io registry:
Expand Down
3 changes: 3 additions & 0 deletions vendor/github.com/kr/pretty/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/kr/text/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/golang.org/x/text/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 07287b5

Please sign in to comment.