quadlet

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerExtension is the file extension for container quadlet files.
	ContainerExtension = ".container"
	// VolumeExtension is the file extension for volume quadlet files.
	VolumeExtension = ".volume"
	// NetworkExtension is the file extension for network quadlet files.
	NetworkExtension = ".network"
	// ImageExtension is the file extension for image quadlet files.
	ImageExtension = ".image"
	// PodExtension is the file extension for pod quadlet files.
	PodExtension = ".pod"
	// BuildExtension is the file extension for build quadlet files.
	BuildExtension = ".build"
	// ArtifactExtension is the file extension for artifact quadlet files.
	ArtifactExtension = ".artifact"
	// KubeExtension is the file extension for kube quadlet files.
	KubeExtension = ".kube"

	// ContainerGroup is the section name for container specifications in quadlet files.
	ContainerGroup = "Container"
	// VolumeGroup is the section name for volume specifications in quadlet files.
	VolumeGroup = "Volume"
	// NetworkGroup is the section name for network specifications in quadlet files.
	NetworkGroup = "Network"
	// ImageGroup is the section name for image specifications in quadlet files.
	ImageGroup = "Image"
	// PodGroup is the section name for pod specifications in quadlet files.
	PodGroup = "Pod"
	// BuildGroup is the section name for build specifications in quadlet files.
	BuildGroup = "Build"
	// ArtifactGroup is the section name for artifact specifications in quadlet files.
	ArtifactGroup = "Artifact"
	// KubeGroup is the section name for kube specifications in quadlet files.
	KubeGroup = "Kube"

	// ImageKey is the key name for image references in quadlet unit sections.
	ImageKey = "Image"
	// MountKey is the key name for mount specifications in quadlet unit sections.
	MountKey = "Mount"
	// LabelKey is the key name for label specifications in quadlet unit sections.
	LabelKey = "Label"
	// VolumeKey is the key name for volume references in quadlet unit sections.
	VolumeKey = "Volume"
	// EnvironmentFileKey is the key name for environment file references in quadlet unit sections.
	EnvironmentFileKey = "EnvironmentFile"
	// NetworkKey is the key name for network references in quadlet unit sections.
	NetworkKey = "Network"
	// PodKey is the key name for pod references in quadlet unit sections.
	PodKey = "Pod"
	// ContainerNameKey is the key name for specifying a custom container name in the [Container] section.
	ContainerNameKey = "ContainerName"
	// VolumeNameKey is the key name for specifying a custom volume name in the [Volume] section.
	VolumeNameKey = "VolumeName"
	// PodNameKey is the key name for specifying a custom pod name in the [Pod] section.
	PodNameKey = "PodName"
	// NetworkNameKey is the key name for specifying a custom network name in the [Network] section.
	NetworkNameKey = "NetworkName"
	// PodmanArgsKey is the key name for specifying arbitrary arguments to podman
	PodmanArgsKey = "PodmanArgs"
	// ServiceNameKey is the key name for overriding the default service name
	ServiceNameKey = "ServiceName"
	// PublishPortKey is the key name for exposing ports from a container
	PublishPortKey = "PublishPort"
	// DriverKey is the key name for specifying a Volume driver
	DriverKey = "Driver"
)

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is returned when a requested key is not found in a unit section.

View Source
var ErrSectionNotFound = errors.New("section not found")

ErrSectionNotFound is returned when a requested section is not found in a unit file.

Extensions maps quadlet file extensions to their corresponding section names.

Sections maps quadlet section names to their corresponding file extensions.

Functions

func DropinDirectories

func DropinDirectories(quadlet string) []string

DropinDirectories returns the paths in which to search for drop-in conf files for the specified file in order of most specific path to least. see https://github.com/containers/podman/blob/main/pkg/systemd/parser/unitfile.go#L952

func IsBuildReference

func IsBuildReference(ref string) bool

IsBuildReference returns true if the given string ends with the build quadlet extension.

func IsImageReference

func IsImageReference(image string) bool

IsImageReference returns true if the given string ends with the image quadlet extension.

func IsQuadletFile

func IsQuadletFile(quadlet string) bool

IsQuadletFile returns true if the given file path has a recognized quadlet extension.

func IsQuadletReference

func IsQuadletReference(ref, expected string) bool

IsQuadletReference returns true if the given reference matches the expected quadlet extension

func IsVolumeReference

func IsVolumeReference(ref string) bool

IsVolumeReference returns true if the given string ends with the volume quadlet extension.

func IsWorkload

func IsWorkload(quadlet string) bool

IsWorkload returns true if a quadlet file is considered to be a workload

func MountImage

func MountImage(mount string) (string, error)

MountImage parses the Image from a mount if it exists

func MountParts

func MountParts(mount string) ([]string, error)

MountParts parses a CSV-formatted mount specification into individual parts. Mount specifications are comma-separated key=value pairs (e.g., "type=image,source=myapp.image,destination=/data"). Returns an error if the mount string is not valid CSV format or does not contain exactly one record.

func MountType

func MountType(mount string) (string, error)

MountType returns the type (volume, image, .etc) associated with the mount see https://github.com/containers/podman/blob/main/pkg/specgenutilexternal/mount.go

func MountVolume

func MountVolume(mount string) (string, error)

MountVolume parses the Volume from a mount if it exists

func NamespaceResource

func NamespaceResource(id string, resource string) string

NamespaceResource namespaces the supplied quadlet resource

func VolumeName

func VolumeName(volumeName *string, filename string) string

VolumeName returns the volume name to use for a quadlet volume file. If volumeName is provided (non-nil), it returns the custom name. Otherwise, it generates a default name in the format "systemd-<basename>" where basename is the filename without its extension. For example, "data.volume" becomes "systemd-data".

Types

type Unit

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

Unit represents a systemd unit file with sections and key-value entries.

func NewEmptyUnit

func NewEmptyUnit() *Unit

func NewUnit

func NewUnit(b []byte) (*Unit, error)

NewUnit creates a new Unit by deserializing systemd unit file data from a byte slice.

func NewUnitFromReader

func NewUnitFromReader(reader io.Reader) (*Unit, error)

NewUnitFromReader creates a new Unit by deserializing systemd unit file data from a reader.

func (*Unit) Add

func (u *Unit) Add(section string, key string, value string) *Unit

Add adds the specified key value pair to the section. If the section doesn't exist a new section is created. The Unit is returned to allow chaining Add calls

func (*Unit) HasSection

func (u *Unit) HasSection(section string) bool

HasSection returns true if the Unit contains the specified section.

func (*Unit) Lookup

func (u *Unit) Lookup(section string, key string) (string, error)

Lookup finds the last value for a given key in the specified section. Returns ErrSectionNotFound if the section doesn't exist, or ErrKeyNotFound if the key doesn't exist.

func (*Unit) LookupAll

func (u *Unit) LookupAll(section string, key string) ([]string, error)

LookupAll finds all values for a given key in the specified section. Returns ErrSectionNotFound if the section doesn't exist.

func (*Unit) Merge

func (u *Unit) Merge(o *Unit)

Merge merges another Unit into this Unit, combining sections and entries.

func (*Unit) Transform

func (u *Unit) Transform(section, key string, transformFn UnitEntryTransformFn) error

Transform applies the specified UnitEntryTransformFn to all entries in the specified section for the supplied key. The returned value from transform is set as the new value

func (*Unit) TransformAll

func (u *Unit) TransformAll(section string, transformFn UnitEntryTransformAllFn) error

TransformAll applies the specified UnitEntryTransformAllFn to all entries in specified section. The returned value is set as the new value

func (*Unit) Write

func (u *Unit) Write() ([]byte, error)

Write serializes the Unit back to systemd unit file format and returns the byte representation.

type UnitEntryTransformAllFn

type UnitEntryTransformAllFn func(key, value string) (string, error)

type UnitEntryTransformFn

type UnitEntryTransformFn func(value string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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