github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/pkg/domain/infra/runtime_abi.go (about) 1 // +build ABISupport 2 3 package infra 4 5 import ( 6 "context" 7 "fmt" 8 9 "github.com/containers/libpod/pkg/bindings" 10 "github.com/containers/libpod/pkg/domain/entities" 11 "github.com/containers/libpod/pkg/domain/infra/tunnel" 12 ) 13 14 // NewContainerEngine factory provides a libpod runtime for container-related operations 15 func NewContainerEngine(facts entities.PodmanConfig) (entities.ContainerEngine, error) { 16 switch facts.EngineMode { 17 case entities.ABIMode: 18 r, err := NewLibpodRuntime(facts.FlagSet, facts) 19 return r, err 20 case entities.TunnelMode: 21 ctx, err := bindings.NewConnection(context.Background(), facts.Uri, facts.Identities...) 22 return &tunnel.ContainerEngine{ClientCxt: ctx}, err 23 } 24 return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) 25 } 26 27 // NewContainerEngine factory provides a libpod runtime for image-related operations 28 func NewImageEngine(facts entities.PodmanConfig) (entities.ImageEngine, error) { 29 switch facts.EngineMode { 30 case entities.ABIMode: 31 r, err := NewLibpodImageRuntime(facts.FlagSet, facts) 32 return r, err 33 case entities.TunnelMode: 34 ctx, err := bindings.NewConnection(context.Background(), facts.Uri, facts.Identities...) 35 return &tunnel.ImageEngine{ClientCxt: ctx}, err 36 } 37 return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) 38 }