podman

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Running            Status = "running"
	DefaultMachineName string = "podman-machine-default"
)

Variables

View Source
var (
	ErrPodmanNotFound  = errors.New("podman not found in your system, check requirements at https://dochub.mongodb.org/core/atlas-cli-deploy-local-reqs")
	ErrNetworkNotFound = errors.New("network ip range was not found")
)

Functions

func Installed

func Installed() error

Types

type Client

type Client interface {
	Ready(ctx context.Context) error
	Diagnostics(ctx context.Context) *Diagnostic
	CreateNetwork(ctx context.Context, name string) ([]byte, error)
	CreateVolume(ctx context.Context, name string) ([]byte, error)
	RunContainer(ctx context.Context, opts RunContainerOpts) ([]byte, error)
	CopyFileToContainer(ctx context.Context, localFile string, containerName string, filePathInContainer string) ([]byte, error)
	ContainerInspect(ctx context.Context, names ...string) ([]*InspectContainerData, error)
	StopContainers(ctx context.Context, names ...string) ([]byte, error)
	StartContainers(ctx context.Context, names ...string) ([]byte, error)
	UnpauseContainers(ctx context.Context, names ...string) ([]byte, error)
	RemoveContainers(ctx context.Context, names ...string) ([]byte, error)
	RemoveVolumes(ctx context.Context, names ...string) ([]byte, error)
	RemoveNetworks(ctx context.Context, names ...string) ([]byte, error)
	ListContainers(ctx context.Context, nameFilter string) ([]*Container, error)
	ListImages(ctx context.Context, nameFilter string) ([]*Image, error)
	PullImage(ctx context.Context, name string) ([]byte, error)
	Version(ctx context.Context) (*Version, error)
	Logs(ctx context.Context) (map[string]interface{}, []error)
	ContainerLogs(ctx context.Context, name string) ([]string, error)
	Network(ctx context.Context, names ...string) ([]*Network, error)
	Exec(ctx context.Context, name string, args ...string) error
}

func NewClient

func NewClient() Client

type ConnectionConfig

type ConnectionConfig struct {
	// PodmanSocket is the exported podman service socket
	PodmanSocket *VMFile `json:"PodmanSocket"`
	// PodmanPipe is the exported podman service named pipe (Windows hosts only)
	PodmanPipe *VMFile `json:"PodmanPipe"`
}

ConnectionConfig contains connections like sockets, etc.

type Container

type Container struct {
	ID    string   `json:"ID"`
	Names []string `json:"Names"`
	State string   `json:"State"`
	Image string   `json:"Image"`
	Ports []struct {
		HostPort      int `json:"host_port"`
		ContainerPort int `json:"container_port"`
	} `json:"Ports,omitempty"`
	Labels map[string]string `json:"Labels"`
}

type Diagnostic

type Diagnostic struct {
	Installed       bool
	MachineRequired bool
	MachineFound    bool
	MachineState    string
	MachineInfo     *InspectInfo
	Version         *Version
	Images          []string
	Errors          []string
}

type IPNet

type IPNet struct {
	net.IPNet
}

IPNet is used as custom net.IPNet type to add Marshal/Unmarshal methods.

func ParseCIDR

func ParseCIDR(cidr string) (IPNet, error)

ParseCIDR parse a string to IPNet.

func (*IPNet) MarshalText

func (n *IPNet) MarshalText() ([]byte, error)

func (*IPNet) UnmarshalText

func (n *IPNet) UnmarshalText(text []byte) error

type Image

type Image struct {
	ID          string   `json:"ID"`
	RepoTags    string   `json:"RepoTags"`
	RepoDigests []string `json:"RepoDigests"`
	Created     int      `json:"Created"`
	CreatedAt   string   `json:"CreatedAt"`
	Size        int      `json:"Size"`
	SharedSize  int      `json:"SharedSize"`
	VirtualSize int      `json:"VirtualSize"`
	Labels      struct {
		Architecture string `json:"architecture"`
		BuildDate    string `json:"build-date"`
		Description  string `json:"description"`
		Name         string `json:"name"`
		Version      string `json:"version"`
	} `json:"Labels"`
	Containers int `json:"Containers"`
	Names      []string
}

type ImageConfig

type ImageConfig struct {
	// IgnitionFile is the path to the filesystem where the
	// ignition file was written (if needs one)
	IgnitionFile VMFile `json:"IgnitionFilePath"`
	// ImageStream is the update stream for the image
	ImageStream string
	// ImageFile is the fq path to
	ImagePath VMFile `json:"ImagePath"`
}

ImageConfig describes the bootable image for the VM.

type InspectAdditionalNetwork

type InspectAdditionalNetwork struct {
	InspectBasicNetworkConfig
}

InspectAdditionalNetwork holds information about non-default networks the container has been connected to. As with InspectNetworkSettings, many fields are unused and maintained only for compatibility with Docker.

type InspectBasicNetworkConfig

type InspectBasicNetworkConfig struct {
	// IPAddress is the IP address for this network.
	IPAddress string `json:"IPAddress"`
}

InspectBasicNetworkConfig holds basic configuration information (e.g. IP addresses, MAC address, subnet masks, etc) that are common for all networks (both additional and main).

type InspectContainerConfig

type InspectContainerConfig struct {
	// Container labels
	Labels map[string]string `json:"Labels"`
}

InspectContainerConfig holds further data about how a container was initially configured.

type InspectContainerData

type InspectContainerData struct {
	// Name is the name of the secret
	Name            string                      `json:"Name"`
	Mounts          []InspectMount              `json:"Mounts"`
	NetworkSettings *InspectNetworkSettings     `json:"NetworkSettings"`
	Config          *InspectContainerConfig     `json:"Config"`
	HostConfig      *InspectContainerHostConfig `json:"HostConfig"`
}

InspectContainerData provides a detailed record of a container's configuration and state as viewed by Libpod. Large portions of this structure are defined such that the output is compatible with `docker inspect` JSON, but additional fields have been added as required to share information not in the original output.

type InspectContainerHostConfig

type InspectContainerHostConfig struct {
	// PortBindings contains the container's port bindings.
	// It is formatted as map[string][]InspectHostPort.
	// The string key here is formatted as <integer port number>/<protocol>
	// and represents the container port. A single container port may be
	// bound to multiple host ports (on different IPs).
	PortBindings map[string][]InspectHostPort `json:"PortBindings"`
}

InspectContainerHostConfig holds information used when the container was created. It's very much a Docker-specific struct, retained (mostly) as-is for compatibility. We fill individual fields as best as we can, inferring as much as possible from the spec and container config. Some things cannot be inferred. These will be populated by spec annotations (if available).

type InspectHostPort

type InspectHostPort struct {
	// IP on the host we are bound to. "" if not specified (binding to all
	// IPs).
	HostIP string `json:"HostIp"`
	// Port on the host we are bound to. No special formatting - just an
	// integer stuffed into a string.
	HostPort string `json:"HostPort"`
}

InspectHostPort provides information on a port on the host that a container's port is bound to.

type InspectInfo

type InspectInfo struct {
	ConfigPath         VMFile
	ConnectionInfo     ConnectionConfig
	Created            time.Time
	Image              ImageConfig
	LastUp             time.Time
	Name               string
	Resources          ResourceConfig
	SSHConfig          SSHConfig
	State              Status
	UserModeNetworking bool
	Rootful            bool
}

type InspectMount

type InspectMount struct {
	// The name of the volume. Empty for bind mounts.
	Name string `json:"Name,omitempty"`
}

InspectMount provides a record of a single mount in a container. It contains fields for both named and normal volumes. Only user-specified volumes will be included, and tmpfs volumes are not included even if the user specified them.

type InspectNetworkSettings

type InspectNetworkSettings struct {
	InspectBasicNetworkConfig

	// Networks contains information on non-default networks this
	// container has joined.
	// It is a map of network name to network information.
	Networks map[string]*InspectAdditionalNetwork `json:"Networks,omitempty"`
}

InspectNetworkSettings holds information about the network settings of the container. Many fields are maintained only for compatibility with `docker inspect` and are unused within Libpod.

type LeaseRange

type LeaseRange struct {
	// StartIP first IP in the subnet which should be used to assign ips.
	// swagger:strfmt string
	StartIP net.IP `json:"start_ip,omitempty"`
	// EndIP last IP in the subnet which should be used to assign ips.
	// swagger:strfmt string
	EndIP net.IP `json:"end_ip,omitempty"`
}

LeaseRange contains the range where IP are leased.

type Network

type Network struct {
	// Name of the Network.
	Name string `json:"name"`
	// ID of the Network.
	ID string `json:"id"`
	// Driver for this Network, e.g. bridge, macvlan...
	Driver string `json:"driver"`
	// NetworkInterface is the network interface name on the host.
	NetworkInterface string `json:"network_interface,omitempty"`
	// Created contains the timestamp when this network was created.
	Created time.Time `json:"created,omitempty"`
	// Subnets to use for this network.
	Subnets []Subnet `json:"subnets,omitempty"`
	// Routes to use for this network.
	Routes []Route `json:"routes,omitempty"`
	// IPv6Enabled if set to true an ipv6 subnet should be created for this net.
	IPv6Enabled bool `json:"ipv6_enabled"`
	// Internal is whether the Network should not have external routes
	// to public or other Networks.
	Internal bool `json:"internal"`
	// DNSEnabled is whether name resolution is active for container on
	// this Network. Only supported with the bridge driver.
	DNSEnabled bool `json:"dns_enabled"`
	// List of custom DNS server for podman's DNS resolver at network level,
	// all the containers attached to this network will consider resolvers
	// configured at network level.
	NetworkDNSServers []string `json:"network_dns_servers,omitempty"`
	// Labels is a set of key-value labels that have been applied to the
	// Network.
	Labels map[string]string `json:"labels,omitempty"`
	// Options is a set of key-value options that have been applied to
	// the Network.
	Options map[string]string `json:"options,omitempty"`
	// IPAMOptions contains options used for the ip assignment.
	IPAMOptions map[string]string `json:"ipam_options,omitempty"`
}

Network describes the Network attributes.

type ResourceConfig

type ResourceConfig struct {
	// CPUs to be assigned to the VM
	CPUs uint64
	// Disk size in gigabytes assigned to the vm
	DiskSize uint64
	// Memory in megabytes assigned to the vm
	Memory uint64
}

ResourceConfig describes physical attributes of the machine.

type Route

type Route struct {
	// Destination for this route in CIDR form.
	// swagger:strfmt string
	Destination IPNet `json:"destination"`
	// Gateway IP for this route.
	// swagger:strfmt string
	Gateway net.IP `json:"gateway"`
	// Metric for this route. Optional.
	Metric *uint32 `json:"metric,omitempty"`
}

type RunContainerOpts

type RunContainerOpts struct {
	Detach   bool
	Remove   bool
	Image    string
	Name     string
	Hostname string
	// map[hostVolume, pathInContainer]
	Volumes map[string]string
	// map[hostPort, containerPort]
	Ports      map[int]int
	BindIPAll  bool
	Network    string
	EnvVars    map[string]string
	Args       []string
	Entrypoint string
	Cmd        string
	IP         string
}

type SSHConfig

type SSHConfig struct {
	// IdentityPath is the fq path to the ssh priv key
	IdentityPath string
	// SSH port for user networking
	Port int
	// RemoteUsername of the vm user
	RemoteUsername string
}

SSHConfig contains remote access information for SSH.

type Schema2HealthConfig

type Schema2HealthConfig struct {
	// Test is the test to perform to check that the container is healthy.
	// An empty slice means to inherit the default.
	// The options are:
	// {} : inherit healthcheck
	// {"NONE"} : disable healthcheck
	// {"CMD", args...} : exec arguments directly
	// {"CMD-SHELL", command} : run command with system's default shell
	Test []string `json:",omitempty"`

	// Zero means to inherit. Durations are expressed as integer nanoseconds.
	StartPeriod time.Duration `json:",omitempty"` // StartPeriod is the time to wait after starting before running the first check.
	Interval    time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
	Timeout     time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.

	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
	// Zero means inherit.
	Retries int `json:",omitempty"`
}

Schema2HealthConfig is a HealthConfig, which holds configuration settings for the HEALTHCHECK feature, from docker/docker/api/types/container.

type Status

type Status = string

type Subnet

type Subnet struct {
	// Subnet for this Network in CIDR form.
	// swagger:strfmt string
	Subnet IPNet `json:"subnet"`
	// Gateway IP for this Network.
	// swagger:strfmt string
	Gateway net.IP `json:"gateway,omitempty"`
	// LeaseRange contains the range where IP are leased. Optional.
	LeaseRange *LeaseRange `json:"lease_range,omitempty"`
}

type VMFile

type VMFile struct {
	// Path is the fully qualified path to a file
	Path string
	// Symlink is a shortened version of Path by using
	// a symlink
	Symlink *string `json:"symlink,omitempty"`
}

type Version

type Version struct {
	Client struct {
		APIVersion string `json:"APIVersion"`
		Version    string `json:"Version"`
		GoVersion  string `json:"GoVersion"`
		GitCommit  string `json:"GitCommit"`
		BuiltTime  string `json:"BuiltTime"`
		Built      int    `json:"Built"`
		OsArch     string `json:"OsArch"`
		Os         string `json:"Os"`
	} `json:"Client"`

	Server struct {
		APIVersion string `json:"APIVersion"`
		Version    string `json:"Version"`
		GoVersion  string `json:"GoVersion"`
		GitCommit  string `json:"GitCommit"`
		BuiltTime  string `json:"BuiltTime"`
		Built      int    `json:"Built"`
		OsArch     string `json:"OsArch"`
		Os         string `json:"Os"`
	} `json:"Server"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL