mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00

Moving from Go module v4 to v5 prepares us for public releases. Move done using gomove [1] as with the v3 and v4 moves. [1] https://github.com/KSubedi/gomove Signed-off-by: Matt Heon <mheon@redhat.com>
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
//go:build !remote
|
|
|
|
package infra
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/containers/podman/v5/pkg/bindings"
|
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
|
"github.com/containers/podman/v5/pkg/domain/infra/tunnel"
|
|
)
|
|
|
|
// NewContainerEngine factory provides a libpod runtime for container-related operations
|
|
func NewContainerEngine(facts *entities.PodmanConfig) (entities.ContainerEngine, error) {
|
|
switch facts.EngineMode {
|
|
case entities.ABIMode:
|
|
r, err := NewLibpodRuntime(facts.FlagSet, facts)
|
|
return r, err
|
|
case entities.TunnelMode:
|
|
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.Identity, facts.MachineMode)
|
|
return &tunnel.ContainerEngine{ClientCtx: ctx}, err
|
|
}
|
|
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)
|
|
}
|
|
|
|
// NewImageEngine factory provides a libpod runtime for image-related operations
|
|
func NewImageEngine(facts *entities.PodmanConfig) (entities.ImageEngine, error) {
|
|
switch facts.EngineMode {
|
|
case entities.ABIMode:
|
|
r, err := NewLibpodImageRuntime(facts.FlagSet, facts)
|
|
return r, err
|
|
case entities.TunnelMode:
|
|
// TODO: look at me!
|
|
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.Identity, facts.MachineMode)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("%w: %s", err, facts.URI)
|
|
}
|
|
return &tunnel.ImageEngine{ClientCtx: ctx, FarmNode: tunnel.FarmNode{NodeName: facts.FarmNodeName}}, nil
|
|
}
|
|
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)
|
|
}
|