mirror of
https://github.com/containers/podman.git
synced 2025-10-10 07:45:08 +08:00

This commit implements automatic artifact fallback for the podman inspect command as requested in GitHub issue #27075. Changes made: - Add ArtifactType constant to cmd/podman/common/inspect.go - Update AutocompleteInspectType to include artifact type in completions - Add artifact case to main inspect switch statement for explicit --type artifact - Implement artifact fallback in inspectAll function for automatic detection - Update shell completion to recognize artifacts in getEntityType function - Update command help text, usage, and examples to include artifacts - Update podman-inspect.1.md man page with artifact documentation - Add comprehensive e2e tests for artifact inspect functionality The inspect command now automatically falls back to artifact inspection when no container, image, volume, network, or pod matches the specified name. Users can also explicitly use --type artifact for direct artifact inspection. This maintains backward compatibility while extending functionality to support the artifact object type seamlessly. Examples: podman inspect myartifact # Auto-detects artifact podman inspect --type artifact myartifact # Explicit artifact type podman inspect --format '{{.Name}}' myartifact # Format support Fixes: https://github.com/containers/podman/issues/27075 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/containers/podman/v5/cmd/podman/common"
|
|
"github.com/containers/podman/v5/cmd/podman/inspect"
|
|
"github.com/containers/podman/v5/cmd/podman/registry"
|
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
inspectDescription = `Displays the low-level information on an object identified by name or ID.
|
|
For more inspection options, see:
|
|
|
|
podman artifact inspect
|
|
podman container inspect
|
|
podman image inspect
|
|
podman network inspect
|
|
podman pod inspect
|
|
podman volume inspect`
|
|
|
|
// Command: podman _inspect_ Object_ID
|
|
inspectCmd = &cobra.Command{
|
|
Use: "inspect [options] {ARTIFACT|CONTAINER|IMAGE|POD|NETWORK|VOLUME} [...]",
|
|
Short: "Display the configuration of object denoted by ID",
|
|
RunE: inspectExec,
|
|
Long: inspectDescription,
|
|
TraverseChildren: true,
|
|
ValidArgsFunction: common.AutocompleteInspect,
|
|
Example: `podman inspect fedora
|
|
podman inspect --type image fedora
|
|
podman inspect --type artifact quay.io/myimage/myartifact:latest
|
|
podman inspect CtrID ImgID
|
|
podman inspect --format "imageId: {{.Id}} size: {{.Size}}" fedora`,
|
|
}
|
|
inspectOpts *entities.InspectOptions
|
|
)
|
|
|
|
func init() {
|
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
|
Command: inspectCmd,
|
|
})
|
|
inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
|
|
}
|
|
|
|
func inspectExec(_ *cobra.Command, args []string) error {
|
|
return inspect.Inspect(args, *inspectOpts)
|
|
}
|