podman

package module
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

README

Arcaflow engine deployer podman

This library is an implementation of the arcaflow deployer interface that uses the podman CLI.

Verified Podman CLI Version

Testing has been performed on this Podman version to validate functionality.

❯ podman version
Client:       Podman Engine
Version:      4.5.0
API Version:  4.5.0
Go Version:   go1.19.7
Built:        Fri Apr 14 11:42:56 2023
OS/Arch:      linux/amd64

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema = schema.NewTypedScopeSchema[*Config](
	schema.NewStructMappedObjectSchema[*Config](
		"Config",
		map[string]*schema.PropertySchema{
			"deployment": schema.NewPropertySchema(
				schema.NewRefSchema("Deployment", nil),
				schema.NewDisplayValue(
					schema.PointerTo("Deployment"),
					schema.PointerTo("Deployment configuration for the plugin."),
					nil,
				),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"podman": schema.NewPropertySchema(
				schema.NewRefSchema("Podman", nil),
				schema.NewDisplayValue(
					schema.PointerTo("Podman"),
					schema.PointerTo("Podman CLI configuration"),
					nil,
				),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
		},
	),
	schema.NewStructMappedObjectSchema[Podman](
		"Podman",
		map[string]*schema.PropertySchema{
			"path": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^.*$")),
				schema.NewDisplayValue(schema.PointerTo("Podman path"), schema.PointerTo("Provides the path of podman executable"), nil),
				false,
				nil,
				nil,
				nil,
				schema.PointerTo(util.JSONEncode("podman")),
				nil,
			),
			"containerNamePrefix": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^.*$")),
				schema.NewDisplayValue(
					schema.PointerTo("Container Name Prefix"),
					schema.PointerTo("Constant prefix prepended to the randomized container name string."),
					nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"rngSeed": schema.NewPropertySchema(
				schema.NewIntSchema(nil, nil, nil),
				schema.NewDisplayValue(
					schema.PointerTo("RngSeed"),
					schema.PointerTo("Initial integer that is the starting point for a Random Number Generator's algorithm. Set this value for reproducible randomness."),
					nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"connectionName": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Connection"), schema.PointerTo("Connection name to use for remote podman"), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
		},
	),
	schema.NewStructMappedObjectSchema[Deployment](
		"Deployment",
		map[string]*schema.PropertySchema{
			"container": schema.NewPropertySchema(
				schema.NewRefSchema("ContainerConfig", nil),
				schema.NewDisplayValue(schema.PointerTo("Container configuration"), schema.PointerTo("Provides information about the container for the plugin."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"host": schema.NewPropertySchema(
				schema.NewRefSchema("HostConfig", nil),
				schema.NewDisplayValue(schema.PointerTo("Host configuration"), schema.PointerTo("Provides information about the container host for the plugin."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"imagePullPolicy": schema.NewPropertySchema(
				schema.NewStringEnumSchema(map[string]*schema.DisplayValue{
					string(ImagePullPolicyAlways):       {NameValue: schema.PointerTo("Always")},
					string(ImagePullPolicyIfNotPresent): {NameValue: schema.PointerTo("If not present")},
					string(ImagePullPolicyNever):        {NameValue: schema.PointerTo("Never")},
				}),
				schema.NewDisplayValue(schema.PointerTo("Image pull policy"), schema.PointerTo("When to pull the plugin image."), nil),
				false,
				nil,
				nil,
				nil,
				schema.PointerTo(util.JSONEncode(string(ImagePullPolicyIfNotPresent))),
				nil,
			),
			"imagePlatform": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^.+/.+$")),
				schema.NewDisplayValue(schema.PointerTo("Podman Image OS"), schema.PointerTo("Provides Podman Image Operating System and architecture"), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				[]string{"linux/amd64", "linux/arm64"},
			),
		},
	),
	schema.NewStructMappedObjectSchema[*container.Config](
		"ContainerConfig",
		map[string]*schema.PropertySchema{
			"Hostname": schema.NewPropertySchema(
				schema.NewStringSchema(schema.IntPointer(1), schema.IntPointer(255), regexp.MustCompile("^[a-zA-Z0-9-_.]+$")),
				schema.NewDisplayValue(schema.PointerTo("Hostname"), schema.PointerTo("Hostname for the plugin container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"Domainname": schema.NewPropertySchema(
				schema.NewStringSchema(schema.IntPointer(1), schema.IntPointer(255), regexp.MustCompile("^[a-zA-Z0-9-_.]+$")),
				schema.NewDisplayValue(schema.PointerTo("Domain name"), schema.PointerTo("Domain name for the plugin container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"User": schema.NewPropertySchema(
				schema.NewStringSchema(schema.IntPointer(1), schema.IntPointer(255), regexp.MustCompile("^[a-z_][a-z0-9_-]*[$]?(:[a-z_][a-z0-9_-]*[$]?)$")),
				schema.NewDisplayValue(schema.PointerTo("Username"), schema.PointerTo("User that will run the command inside the container. Optionally, a group can be specified in the user:group format."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"Env": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(schema.IntPointer(1), schema.IntPointer(32760), regexp.MustCompile("^.+=.+$")), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Environment variables"), schema.PointerTo("Environment variables to set on the plugin container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"NetworkDisabled": schema.NewPropertySchema(
				schema.NewBoolSchema(),
				schema.NewDisplayValue(schema.PointerTo("Disable network"), schema.PointerTo("Disable container networking completely."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"MacAddress": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^[a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5}$")),
				schema.NewDisplayValue(schema.PointerTo("MAC address"), schema.PointerTo("Media Access Control address for the container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
		},
	),
	schema.NewStructMappedObjectSchema[*container.HostConfig](
		"HostConfig",
		map[string]*schema.PropertySchema{
			"Binds": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(schema.IntPointer(1), schema.IntPointer(32760), regexp.MustCompile("^.+:.+$")), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Volume Bindings"), schema.PointerTo("Volumes"), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"NetworkMode": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^(none|private|bridge(:.+)?|host|container:[a-zA-Z0-9][a-zA-Z0-9_.-]+|[a-zA-Z0-9][a-zA-Z0-9_.-]+|pasta:.+|slirp4netns:.+|ns:.+)$")),
				schema.NewDisplayValue(schema.PointerTo("Network mode"), schema.PointerTo("Specifies either the network mode, the container network to attach to, or a name of a Docker network to use."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				[]string{
					util.JSONEncode("none"),
					util.JSONEncode("bridge"),
					util.JSONEncode("host"),
					util.JSONEncode("container:container-name"),
					util.JSONEncode("network-name"),
				},
			),
			"PortBindings": schema.NewPropertySchema(
				schema.NewMapSchema(
					schema.NewStringSchema(nil, nil, regexp.MustCompile("^[0-9]+(/[a-zA-Z0-9]+)$")),
					schema.NewListSchema(
						schema.NewRefSchema("PortBinding", nil),
						nil,
						nil,
					),
					nil,
					nil,
				),
				schema.NewDisplayValue(schema.PointerTo("Port bindings"), schema.PointerTo("Ports to expose on the host machine. Ports are specified in the format of portnumber/protocol."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"CapAdd": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Add capabilities"), schema.PointerTo("Add capabilities to the container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"CapDrop": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Drop capabilities"), schema.PointerTo("Drop capabilities from the container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"CgroupnsMode": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("host|private|ns:.+|container:.+")),
				schema.NewDisplayValue(schema.PointerTo("CGroup namespace mode"), schema.PointerTo("CGroup namespace mode to use for the container."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			),
			"Dns": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("DNS servers"), schema.PointerTo("DNS servers to use for lookup."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"DnsOptions": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("DNS options"), schema.PointerTo("DNS options to look for."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"DnsSearch": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("DNS search"), schema.PointerTo("DNS search domain."), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"ExtraHosts": schema.NewPropertySchema(
				schema.NewListSchema(schema.NewStringSchema(nil, nil, nil), nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Extra hosts"), schema.PointerTo("Extra hosts entries to add"), nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"Privileged": schema.NewPropertySchema(
				schema.NewBoolSchema(),
				schema.NewDisplayValue(schema.PointerTo("Privileged"), schema.PointerTo("Execute container process without security features that isolate the container from the host"), nil),
				false,
				nil,
				nil,
				nil,
				schema.PointerTo(util.JSONEncode(false)),
				nil,
			),
		},
	),
	schema.NewStructMappedObjectSchema[*nat.PortBinding](
		"PortBinding",
		map[string]*schema.PropertySchema{
			"HostIP": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, nil),
				schema.NewDisplayValue(schema.PointerTo("Host IP"), nil, nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
			"HostPort": schema.NewPropertySchema(
				schema.NewStringSchema(nil, nil, regexp.MustCompile("^0-9+$")),
				schema.NewDisplayValue(schema.PointerTo("Host port"), nil, nil),
				false,
				nil,
				nil,
				nil,
				nil,
				nil,
			).Disable(notImplemented),
		},
	),
)

Schema describes the deployment options of the Docker deployment mechanism.

Functions

func NewFactory

func NewFactory() deployer.ConnectorFactory[*Config]

NewFactory creates a new factory for the Docker deployer.

Types

type CliPlugin

type CliPlugin struct {
	// contains filtered or unexported fields
}

func (*CliPlugin) Close

func (p *CliPlugin) Close() error

func (*CliPlugin) ID added in v0.3.0

func (p *CliPlugin) ID() string

func (*CliPlugin) Read

func (p *CliPlugin) Read(b []byte) (n int, err error)

func (*CliPlugin) Write

func (p *CliPlugin) Write(b []byte) (n int, err error)

type Config

type Config struct {
	Podman     Podman     `json:"podman"`
	Deployment Deployment `json:"deployment"`
	Timeouts   Timeouts   `json:"timeouts"`
}

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration structure for conformance with the schema.

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func (*Connector) Deploy

func (c *Connector) Deploy(ctx context.Context, image string) (deployer.Plugin, error)

func (*Connector) NextContainerName added in v0.3.0

func (c *Connector) NextContainerName(containerNamePrefix string, randomStrSize int) string

type Deployment

type Deployment struct {
	ContainerConfig *container.Config     `json:"container"`
	HostConfig      *container.HostConfig `json:"host"`
	ImagePullPolicy ImagePullPolicy       `json:"imagePullPolicy"`
	ImagePlatform   *string               `json:"imagePlatform"`
	ConnectionName  *string               `json:"connectionName"`
}

Deployment contains the information about deploying the plugin.

type ImagePullPolicy

type ImagePullPolicy string

ImagePullPolicy drives when an image should be pulled.

const (
	// ImagePullPolicyAlways means that the container image will be pulled for every workflow run.
	ImagePullPolicyAlways ImagePullPolicy = "Always"
	// ImagePullPolicyIfNotPresent means the image will be pulled if the image is not present locally, an empty tag, or
	// the "latest" tag was specified.
	ImagePullPolicyIfNotPresent ImagePullPolicy = "IfNotPresent"
	// ImagePullPolicyNever means that the image will never be pulled, and if the image is not available locally the
	// execution will fail.
	ImagePullPolicyNever ImagePullPolicy = "Never"
)

type Podman

type Podman struct {
	Path string `json:"path"`
	// Constant prefix prepended to the randomized container name string.
	ContainerNamePrefix string `json:"containerNamePrefix"`
	// The initial integer that is the starting point for a
	// Random Number Generator's algorithm.
	RngSeed int64 `json:"rngSeed"`
	// Specify the optional --connection parameter for podman
	ConnectionName *string `json:"connectionName"`
}

type Timeouts

type Timeouts struct {
	HTTP time.Duration `json:"http"`
}

Timeouts drive the timeouts for various interactions in relation to Docker.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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