diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-09-08 16:36:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 16:36:08 +0200 |
commit | eb758c5f583aff06accb1eef08f1b62509ca813c (patch) | |
tree | a23a23de3b603b237262bd8586f2ecbf386e9081 /pkg/domain/infra/tunnel/pods.go | |
parent | 95eff1aa402c3d159c8ad25d8140b879d5feccf2 (diff) | |
parent | d10e77e1bcd25306ab8afd4ce7da16eed3c67840 (diff) | |
download | podman-eb758c5f583aff06accb1eef08f1b62509ca813c.tar.gz podman-eb758c5f583aff06accb1eef08f1b62509ca813c.tar.bz2 podman-eb758c5f583aff06accb1eef08f1b62509ca813c.zip |
Merge pull request #15675 from Luap99/pod-inspect
fix podman pod inspect to support multiple pods
Diffstat (limited to 'pkg/domain/infra/tunnel/pods.go')
-rw-r--r-- | pkg/domain/infra/tunnel/pods.go | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/pkg/domain/infra/tunnel/pods.go b/pkg/domain/infra/tunnel/pods.go index bcbd32d1b..f9314dcfe 100644 --- a/pkg/domain/infra/tunnel/pods.go +++ b/pkg/domain/infra/tunnel/pods.go @@ -3,10 +3,12 @@ package tunnel import ( "context" "errors" + "fmt" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/bindings/pods" "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/errorhandling" "github.com/containers/podman/v4/pkg/util" ) @@ -223,14 +225,25 @@ func (ic *ContainerEngine) PodPs(ctx context.Context, opts entities.PodPSOptions return pods.List(ic.ClientCtx, options) } -func (ic *ContainerEngine) PodInspect(ctx context.Context, options entities.PodInspectOptions) (*entities.PodInspectReport, error) { - switch { - case options.Latest: - return nil, errors.New("latest is not supported") - case options.NameOrID == "": - return nil, errors.New("NameOrID must be specified") +func (ic *ContainerEngine) PodInspect(ctx context.Context, namesOrIDs []string, options entities.InspectOptions) ([]*entities.PodInspectReport, []error, error) { + var errs []error + podReport := make([]*entities.PodInspectReport, 0, len(namesOrIDs)) + for _, name := range namesOrIDs { + inspect, err := pods.Inspect(ic.ClientCtx, name, nil) + if err != nil { + errModel, ok := err.(*errorhandling.ErrorModel) + if !ok { + return nil, nil, err + } + if errModel.ResponseCode == 404 { + errs = append(errs, fmt.Errorf("no such pod %q", name)) + continue + } + return nil, nil, err + } + podReport = append(podReport, inspect) } - return pods.Inspect(ic.ClientCtx, options.NameOrID, nil) + return podReport, errs, nil } func (ic *ContainerEngine) PodStats(ctx context.Context, namesOrIds []string, opts entities.PodStatsOptions) ([]*entities.PodStatsReport, error) { |