mirror of
https://github.com/containers/podman.git
synced 2025-05-25 19:16:59 +08:00

the compilation demands of having libpod in main is a burden for the remote client compilations. to combat this, we should move the use of libpod structs, vars, constants, and functions into the adapter code where it will only be compiled by the local client. this should result in cleaner code organization and smaller binaries. it should also help if we ever need to compile the remote client on non-Linux operating systems natively (not cross-compiled). Signed-off-by: baude <bbaude@redhat.com>
32 lines
869 B
Go
32 lines
869 B
Go
// +build remoteclient
|
|
|
|
package adapter
|
|
|
|
import (
|
|
iopodman "github.com/containers/libpod/cmd/podman/varlink"
|
|
"github.com/containers/libpod/libpod/define"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// TranslateMapErrors translates the errors a typical podman output struct
|
|
// from varlink errors to libpod errors
|
|
func TranslateMapErrors(failures map[string]error) map[string]error {
|
|
for k, v := range failures {
|
|
failures[k] = TranslateError(v)
|
|
}
|
|
return failures
|
|
}
|
|
|
|
// TranslateError converts a single varlink error to a libpod error
|
|
func TranslateError(err error) error {
|
|
switch err.(type) {
|
|
case *iopodman.ContainerNotFound:
|
|
return errors.Wrap(define.ErrNoSuchCtr, err.Error())
|
|
case *iopodman.ErrCtrStopped:
|
|
return errors.Wrap(define.ErrCtrStopped, err.Error())
|
|
case *iopodman.InvalidState:
|
|
return errors.Wrap(define.ErrCtrStateInvalid, err.Error())
|
|
}
|
|
return err
|
|
}
|