Documentation
¶
Index ¶
- Constants
- Variables
- func DropinDirectories(quadlet string) []string
- func IsBuildReference(ref string) bool
- func IsImageReference(image string) bool
- func IsQuadletFile(quadlet string) bool
- func IsQuadletReference(ref, expected string) bool
- func IsVolumeReference(ref string) bool
- func IsWorkload(quadlet string) bool
- func MountImage(mount string) (string, error)
- func MountParts(mount string) ([]string, error)
- func MountType(mount string) (string, error)
- func MountVolume(mount string) (string, error)
- func NamespaceResource(id string, resource string) string
- func VolumeName(volumeName *string, filename string) string
- type Unit
- func (u *Unit) Add(section string, key string, value string) *Unit
- func (u *Unit) HasSection(section string) bool
- func (u *Unit) Lookup(section string, key string) (string, error)
- func (u *Unit) LookupAll(section string, key string) ([]string, error)
- func (u *Unit) Merge(o *Unit)
- func (u *Unit) Transform(section, key string, transformFn UnitEntryTransformFn) error
- func (u *Unit) TransformAll(section string, transformFn UnitEntryTransformAllFn) error
- func (u *Unit) Write() ([]byte, error)
- type UnitEntryTransformAllFn
- type UnitEntryTransformFn
Constants ¶
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 ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is returned when a requested key is not found in a unit section.
var ErrSectionNotFound = errors.New("section not found")
ErrSectionNotFound is returned when a requested section is not found in a unit file.
var Extensions = map[string]string{ ContainerExtension: ContainerGroup, VolumeExtension: VolumeGroup, NetworkExtension: NetworkGroup, PodExtension: PodGroup, ImageExtension: ImageGroup, KubeExtension: KubeGroup, ArtifactExtension: ArtifactGroup, BuildExtension: BuildGroup, }
Extensions maps quadlet file extensions to their corresponding section names.
var Sections = map[string]string{ ContainerGroup: ContainerExtension, VolumeGroup: VolumeExtension, ImageGroup: ImageExtension, PodGroup: PodExtension, BuildGroup: BuildExtension, ArtifactGroup: ArtifactExtension, KubeGroup: KubeExtension, NetworkGroup: NetworkExtension, }
Sections maps quadlet section names to their corresponding file extensions.
Functions ¶
func DropinDirectories ¶
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 ¶
IsBuildReference returns true if the given string ends with the build quadlet extension.
func IsImageReference ¶
IsImageReference returns true if the given string ends with the image quadlet extension.
func IsQuadletFile ¶
IsQuadletFile returns true if the given file path has a recognized quadlet extension.
func IsQuadletReference ¶
IsQuadletReference returns true if the given reference matches the expected quadlet extension
func IsVolumeReference ¶
IsVolumeReference returns true if the given string ends with the volume quadlet extension.
func IsWorkload ¶
IsWorkload returns true if a quadlet file is considered to be a workload
func MountImage ¶
MountImage parses the Image from a mount if it exists
func MountParts ¶
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 ¶
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 ¶
MountVolume parses the Volume from a mount if it exists
func NamespaceResource ¶
NamespaceResource namespaces the supplied quadlet resource
func VolumeName ¶
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 ¶
NewUnit creates a new Unit by deserializing systemd unit file data from a byte slice.
func NewUnitFromReader ¶
NewUnitFromReader creates a new Unit by deserializing systemd unit file data from a reader.
func (*Unit) Add ¶
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 ¶
HasSection returns true if the Unit contains the specified section.
func (*Unit) Lookup ¶
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 ¶
LookupAll finds all values for a given key in the specified section. Returns ErrSectionNotFound if the section doesn't exist.
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