Merge pull request #647 from nalind/config

inspect: add a --config flag
This commit is contained in:
Miloslav Trmač 2019-05-09 15:37:12 +02:00 committed by GitHub
commit 904b064da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 5 deletions

View File

@ -34,6 +34,7 @@ type inspectOptions struct {
global *globalOptions global *globalOptions
image *imageOptions image *imageOptions
raw bool // Output the raw manifest instead of parsing information about the image raw bool // Output the raw manifest instead of parsing information about the image
config bool // Output the raw config blob instead of parsing information about the image
} }
func inspectCmd(global *globalOptions) cli.Command { func inspectCmd(global *globalOptions) cli.Command {
@ -58,9 +59,14 @@ func inspectCmd(global *globalOptions) cli.Command {
Flags: append(append([]cli.Flag{ Flags: append(append([]cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "raw", Name: "raw",
Usage: "output raw manifest", Usage: "output raw manifest or configuration",
Destination: &opts.raw, Destination: &opts.raw,
}, },
cli.BoolFlag{
Name: "config",
Usage: "output configuration",
Destination: &opts.config,
},
}, sharedFlags...), imageFlags...), }, sharedFlags...), imageFlags...),
Before: needsRexec, Before: needsRexec,
Action: commandAction(opts.run), Action: commandAction(opts.run),
@ -89,12 +95,32 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
if err != nil { if err != nil {
return err return err
} }
if opts.raw { if opts.config && opts.raw {
configBlob, err := img.ConfigBlob(ctx)
if err != nil {
return fmt.Errorf("Error reading configuration blob: %v", err)
}
_, err = stdout.Write(configBlob)
if err != nil {
return fmt.Errorf("Error writing configuration blob to standard output: %v", err)
}
return nil
} else if opts.raw {
_, err := stdout.Write(rawManifest) _, err := stdout.Write(rawManifest)
if err != nil { if err != nil {
return fmt.Errorf("Error writing manifest to standard output: %v", err) return fmt.Errorf("Error writing manifest to standard output: %v", err)
} }
return nil return nil
} else if opts.config {
config, err := img.OCIConfig(ctx)
if err != nil {
return fmt.Errorf("Error reading OCI-formatted configuration data: %v", err)
}
err = json.NewEncoder(stdout).Encode(config)
if err != nil {
return fmt.Errorf("Error writing OCI-formatted configuration data to standard output: %v", err)
}
return nil
} }
imgInspect, err := img.Inspect(ctx) imgInspect, err := img.Inspect(ctx)
if err != nil { if err != nil {

View File

@ -73,6 +73,7 @@ _skopeo_inspect() {
--cert-dir --cert-dir
" "
local boolean_options=" local boolean_options="
--config
--raw --raw
--tls-verify --tls-verify
--no-creds --no-creds

View File

@ -4,7 +4,7 @@
skopeo\-inspect - Return low-level information about _image-name_ in a registry skopeo\-inspect - Return low-level information about _image-name_ in a registry
## SYNOPSIS ## SYNOPSIS
**skopeo inspect** [**--raw**] _image-name_ **skopeo inspect** [**--raw**] [**--config**] _image-name_
Return low-level information about _image-name_ in a registry Return low-level information about _image-name_ in a registry
@ -12,14 +12,22 @@ Return low-level information about _image-name_ in a registry
_image-name_ name of image to retrieve information about _image-name_ name of image to retrieve information about
**--config** output configuration in OCI format, default is to format in JSON
_image-name_ name of image to retrieve configuration for
**--config** **--raw** output configuration in raw format
_image-name_ name of image to retrieve configuration for
**--authfile** _path_ **--authfile** _path_
Path of the authentication file. Default is ${XDG_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`.
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
**--creds** _username[:password]_ for accessing the registry **--creds** _username[:password]_ for accessing the registry
**--cert-dir** _path_ Use certificates at _path_ (*.crt, *.cert, *.key) to connect to the registry **--cert-dir** _path_ Use certificates at _path_ (\*.crt, \*.cert, \*.key) to connect to the registry
**--tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container registries (defaults to true) **--tls-verify** _bool-value_ Require HTTPS and verify certificates when talking to container registries (defaults to true)