diff --git a/cmd/skopeo/inspect.go b/cmd/skopeo/inspect.go index e17af1e0..9edf8632 100644 --- a/cmd/skopeo/inspect.go +++ b/cmd/skopeo/inspect.go @@ -34,6 +34,7 @@ type inspectOptions struct { global *globalOptions image *imageOptions 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 { @@ -58,9 +59,14 @@ func inspectCmd(global *globalOptions) cli.Command { Flags: append(append([]cli.Flag{ cli.BoolFlag{ Name: "raw", - Usage: "output raw manifest", + Usage: "output raw manifest or configuration", Destination: &opts.raw, }, + cli.BoolFlag{ + Name: "config", + Usage: "output configuration", + Destination: &opts.config, + }, }, sharedFlags...), imageFlags...), Before: needsRexec, Action: commandAction(opts.run), @@ -89,12 +95,32 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error) if err != nil { 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) if err != nil { return fmt.Errorf("Error writing manifest to standard output: %v", err) } 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) if err != nil { diff --git a/completions/bash/skopeo b/completions/bash/skopeo index 6ab32e18..1b9c5c67 100644 --- a/completions/bash/skopeo +++ b/completions/bash/skopeo @@ -73,6 +73,7 @@ _skopeo_inspect() { --cert-dir " local boolean_options=" + --config --raw --tls-verify --no-creds diff --git a/docs/skopeo-inspect.1.md b/docs/skopeo-inspect.1.md index a18e9aaa..c4aedd48 100644 --- a/docs/skopeo-inspect.1.md +++ b/docs/skopeo-inspect.1.md @@ -4,7 +4,7 @@ skopeo\-inspect - Return low-level information about _image-name_ in a registry ## SYNOPSIS -**skopeo inspect** [**--raw**] _image-name_ +**skopeo inspect** [**--raw**] [**--config**] _image-name_ 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 + **--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_ - 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`. **--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)