preprocess

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractServiceBuildSpecs added in v0.2.0

func ExtractServiceBuildSpecs(composeData []byte, workingDir, cacheDir, projectName string) (map[string]*ServiceBuildSpec, error)

ExtractServiceBuildSpecs parses raw compose YAML and extracts build metadata for all services that define a build block. It patches Dockerfiles and writes the patched copies to the cache directory.

func ExtractServiceImageSpecs added in v0.1.4

func ExtractServiceImageSpecs(composeData []byte) (map[string]ServiceImageSpec, error)

ExtractServiceImageSpecs parses raw compose YAML and returns per-service image metadata before any preprocessing has been applied. This allows the graft step to populate .image quadlet files while the preprocessor strips pull_policy and platform fields that podlet does not understand.

func IsSELinuxEnabled

func IsSELinuxEnabled() bool

IsSELinuxEnabled returns true if SELinux is detected as enabled on the host.

func PatchDockerfile added in v0.2.0

func PatchDockerfile(content []byte) []byte

func SELinuxMode

func SELinuxMode() string

SELinuxMode returns the detected SELinux mode string. Possible values: "Enforcing", "Permissive", "Disabled", "Unknown".

func SetSELinuxOverrides

func SetSELinuxOverrides(enabled *bool, mode string)

SetSELinuxOverrides overrides the SELinux detection result for testing. Pass nil for enabled to restore filesystem-based detection.

Types

type ComposeFile

type ComposeFile struct {
	Services map[string]map[string]interface{} `yaml:"services"`
	Networks map[string]interface{}            `yaml:"networks,omitempty"`
	Volumes  map[string]map[string]interface{} `yaml:"volumes,omitempty"`
	Secrets  map[string]map[string]interface{} `yaml:"secrets,omitempty"`
	Config   *ProjectConfig                    `yaml:"-"` // Internal use
}

ComposeFile represents the top-level structure of a docker-compose.yaml. Services and Volumes use generic maps to preserve all fields (including unknown ones like depends_on, restart, etc.) through the unmarshal/marshal cycle.

type Engine

type Engine struct {
	ProjectName      string
	WorkingDirectory string
}

Engine handles the pre-processing of Compose files

func NewEngine

func NewEngine(projectName, workingDir string) *Engine

NewEngine creates a new pre-processing engine

func (*Engine) Process

func (e *Engine) Process(input []byte) ([]byte, error)

Process takes a raw YAML input and applies normalization rules.

type ProjectConfig

type ProjectConfig struct {
	ProjectName      string
	WorkingDirectory string
}

ProjectConfig holds metadata injected during pre-processing

type SecretDef added in v0.1.5

type SecretDef struct {
	Name         string // compose key name, e.g. "db_password"
	File         string // absolute path for "file:" secrets
	Environment  string // env var name for "environment:" secrets
	Content      string // resolved value (from env var or .env file), for "environment:" secrets
	External     bool   // true if "external: true"
	ExternalName string // "name:" field for external secrets with alternate lookup
}

SecretDef holds a parsed top-level compose secret definition.

type SecretRef added in v0.1.5

type SecretRef struct {
	Source string // secret name from the top-level secrets section
	Target string // optional custom mount path (defaults to /run/secrets/<source>)
}

SecretRef describes a service's reference to a top-level secret.

type ServiceBuildSpec added in v0.2.0

type ServiceBuildSpec struct {
	ServiceName string
	HasBuild    bool
	ImageTag    string                 // image tag for the build (injected or user-provided)
	Context     string                 // absolute build context path
	Dockerfile  string                 // absolute path to the patched Dockerfile
	Target      string                 // build target stage
	Network     string                 // build network mode
	NoCache     bool                   // --no-cache
	Args        map[string]string      // build args
	Labels      map[string]string      // build labels
	PullPolicy  string                 // build pull policy
	Platform    string                 // platform (e.g. "linux/amd64")
	Extra       map[string]interface{} // other build fields preserved as-is
}

ServiceBuildSpec holds metadata about a service's build configuration.

type ServiceImageSpec added in v0.1.4

type ServiceImageSpec struct {
	ServiceName string // compose service name, e.g. "web"
	Image       string // normalized image, e.g. "docker.io/library/nginx:latest"
	PullPolicy  string // pull_policy value: always, missing, never, if_not_present, etc.
	OS          string // from platform field, e.g. "linux"
	Arch        string // from platform field, e.g. "amd64"
	Variant     string // from platform field, e.g. "v8"
}

ServiceImageSpec holds the compose fields that map to a Podman .image quadlet.

type ServiceSecretRefs added in v0.1.5

type ServiceSecretRefs map[string][]SecretRef

ServiceSecretRefs maps a service name to the list of secrets it references.

func ExtractSecretSpecs added in v0.1.5

func ExtractSecretSpecs(composeData []byte, workingDir string) (map[string]SecretDef, ServiceSecretRefs, error)

ExtractSecretSpecs parses raw compose YAML and extracts secret definitions and per-service secret references before any preprocessing has been applied.

type StringMap

type StringMap map[string]string

StringMap stores key-value pairs and supports both YAML map and list formats during unmarshaling (e.g. `KEY: value` or `- KEY=value`). During marshaling it always outputs as a list, which is the standard Docker Compose format and what downstream tools like podlet expect.

func (StringMap) MarshalYAML

func (sm StringMap) MarshalYAML() (interface{}, error)

func (*StringMap) UnmarshalYAML

func (sm *StringMap) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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