Documentation
¶
Overview ¶
quadlet.go — the POD config-WRITE mechanism, relocated out of charly core (P11a). GenerateQuadlet + its pure closure render a systemd quadlet .container file from a QuadletConfig; the compiled-in candy/plugin-deploy-pod builds the QuadletConfig from the host config-resolve seam and calls this. A PURE render mechanism (M under the kernel/plugin boundary law): no host I/O, no globals — byte-identical to the former core generateQuadlet (S4 parity spike). VolumeMount is a resolved runtime type owned in this package (deploy_volume.go); the tunnel wire types are spec.TunnelConfig/TunnelPort (CUE-sourced, P11 wire-mandate repair); SecurityConfig is vmshared's; ResolvedSidecar is the host-adapted deploykit runtime type (defined below), not spec's wire ResolvedSidecar.
quadlet_pod.go — the pod + sidecar quadlet content generators, relocated from charly core (P11 config-write move); a compiled-in deploy:pod plugin calls them to write the .pod + sidecar .container files.
Package deploykit holds the InstallPlan step VOCABULARY — the 13 concrete InstallStep implementations + their field-structs + the pure classification helpers — that any deploy front-end (charly's host engine, an out-of-tree deploy plugin) imports. Each concrete step implements spec.InstallStep (homed in sdk/spec with the IR enums + the InstallPlan container). deploykit imports spec; the aliases below let the moved code read unchanged.
Index ¶
- Constants
- Variables
- func AbsoluteCandySequence(boxName string, boxes map[string]*buildkit.ResolvedBox, ...) []string
- func AcceptedEnvSet(accepts, requires []spec.EnvDependency) map[string]bool
- func AddTransitiveDeps(candyName string, layers map[string]CandyModel, needed map[string]bool, ...)
- func AppendOrReplaceEnv(envs []string, entry string) []string
- func AppendShellPathLines(body string, paths []string, shell, home string) string
- func ArgHasImageTag(arg string) bool
- func BareRef(ref string) string
- func BedCheckLiveRefs(name string, children map[string]*BundleNode) []string
- func BoxDirectDeps(name string, img *buildkit.ResolvedBox, boxes map[string]*buildkit.ResolvedBox, ...) []string
- func BoxNeedsBuilder(img *buildkit.ResolvedBox, boxes map[string]*buildkit.ResolvedBox, ...) bool
- func BuildArchExports() string
- func BuildServiceRenderContext(entry *spec.ServiceEntry, ctx spec.ServiceRenderContext) spec.ServiceRenderContext
- func BuildStartArgs(engine, imageRef string, uid, gid int, ports []string, name string, ...) []string
- func BuilderCtxKey(candy, builder string) string
- func BuilderResolveInputFrom(candyName, builderName string, builderDef *buildkit.BuilderDef, ...) spec.BuilderResolveInput
- func BundleWalkPostOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error
- func BundleWalkPreOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error
- func CandyMapKey(layer CandyModel) string
- func CandyNeedsBuilderStep(layer CandyModel, bDef *BuilderDef) bool
- func CandyProvidedByBox(boxName string, boxes map[string]*buildkit.ResolvedBox, ...) (map[string]bool, error)
- func CandyStageDirName(layer CandyModel) string
- func CanonicalizeDeployArg(arg, instance string) (box, inst string)
- func CascadeTagChain(img *ResolvedBox) []string
- func ClassifyTarget(node *BundleNode) string
- func CleanDeployEntry(boxName, instance string, ...)
- func CollectAllBoxCandies(boxName string, boxes map[string]*buildkit.ResolvedBox, ...) []string
- func CollectSubtreeBoxes(node *TrieNode) []string
- func ComputeDeployID(box string, layers, addCandies []string) string
- func ComputeEffectiveVersions(boxes map[string]*buildkit.ResolvedBox, candies map[string]CandyModel) error
- func ComputeOwnCandies(parentName string, pathCandies []string, ...) []string
- func DeployKey(boxName, instance string) string
- func DeployStorageDir(deployKey, instance string) string
- func DeployVolumePrefix(deployKey, instance string) string
- func DescribePlan(p *InstallPlan) string
- func DescriptionInfo(d string) string
- func DetectExternalizedBuilders(order []string, candies map[string]CandyModel, externalized map[string]bool, ...) []string
- func DropMappingKey(m *yaml.Node, key string)
- func EmitCmd(b *strings.Builder, t vmshared.Op, layerStage string, ...)
- func EmitCopy(b *strings.Builder, t vmshared.Op, layerStage string, ...)
- func EmitDownload(b *strings.Builder, t vmshared.Op, img *buildkit.ResolvedBox) error
- func EmitLinkBatch(b *strings.Builder, tasks []vmshared.Op, img *buildkit.ResolvedBox)
- func EmitMkdirBatch(b *strings.Builder, tasks []vmshared.Op, img *buildkit.ResolvedBox)
- func EmitSetcapBatch(b *strings.Builder, tasks []vmshared.Op, img *buildkit.ResolvedBox)
- func EmitVarsEnv(b *strings.Builder, vars map[string]string)
- func EmitWrite(b *strings.Builder, t vmshared.Op, srcPath string, img *buildkit.ResolvedBox)
- func EncryptedCipherDir(storagePath, boxName, name string) string
- func EncryptedPlainDir(storagePath, boxName, name string) string
- func EncryptedVolumeName(boxName, name string) string
- func EnsureServiceSuffix(unit string) string
- func EnvKey(entry string) string
- func ExpandCandy(requested []string, layers map[string]CandyModel) ([]string, error)
- func ExtractStringSlice(m map[string]any, key string) []string
- func FilterOwnProvides[T Named](entries []T, boxName string) []T
- func FindPodSidecarQuadlets(qdir, podName, mainContainerFile string) ([]string, error)
- func FlattenedEnvMap(base map[string]string, overrides *spec.CandyServiceOverrides) map[string]string
- func FormatCPUQuota(cpus string) string
- func GateEnabled(g Gate, opts EmitOpts) bool
- func GeneratePodQuadlet(cfg QuadletConfig) string
- func GenerateQuadlet(cfg QuadletConfig) string
- func GenerateSidecarQuadlet(sc ResolvedSidecar, podName string) string
- func GenerateTunnelUnit(cfg QuadletConfig, cfgPath string) string
- func GlobalCandyOrder(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([]string, error)
- func GraphReaches(graph map[string][]string, from, to string) bool
- func HasTailscaleSidecar(sidecars map[string]json.RawMessage) bool
- func InitHasRelayTemplate(def *spec.ResolvedInit) bool
- func InitRenderAssemblyTemplate(def *spec.ResolvedInit) (string, error)
- func InitRenderPostAssemblyTemplate(def *spec.ResolvedInit) (string, error)
- func InitRenderRelayTemplate(def *spec.ResolvedInit, port int, candyName string, index int) (string, error)
- func InitRenderStageFragmentCopy(def *spec.ResolvedInit, boxName, fileName string) (string, error)
- func InitRenderSystemEnableTemplate(def *spec.ResolvedInit, units []string) (string, error)
- func IntersectPlatforms(parent, defaults []string) []string
- func IpcModeBlocksShmSize(ipcMode string) bool
- func IsAutoVmDeployEntry(entry BundleNode) bool
- func IsExternalStepKind(k StepKind) bool
- func IsRemoteCandyRef(ref string) bool
- func IsSameBaseBox(source, boxName string) bool
- func IsTCPFamily(scheme string) bool
- func LocalizePort(mapping string, bindAddr string) string
- func MapToKeyValueSlice(m map[string]string) []spec.KeyValue
- func MarshalBundleNode(node *spec.Deploy) (*yaml.Node, error)
- func MergeDeployOntoMetadata(meta *spec.BoxMetadata, dc *BundleConfig, deployName, instance string)
- func MergeEnvVars(existing, newVars map[string]string) map[string]string
- func NewSpecResolvedBox(v spec.ResolvedBoxView, distro map[string]*spec.ResolvedDistro, ...) *buildkit.ResolvedBox
- func NormalizeCgroupSize(s string) string
- func ParentDirForDest(dest string) string
- func ParseDeployKey(key string) (boxName, instance string)
- func PathIsSystemScoped(p string) bool
- func PixiBoundCandies(layers map[string]CandyModel) map[string]bool
- func PlanFromView(v spec.InstallPlanView) (*spec.InstallPlan, error)
- func PortMapFromMappings(mappings []string) map[int]int
- func PreemptEffectiveRestore(p *PreemptibleConfig) string
- func PreemptEffectiveStop(p *PreemptibleConfig) string
- func PrimaryDistroTag(img *ResolvedBox, hostCtx HostContext) string
- func ProvisionData(engine string, imageRef string, meta *spec.BoxMetadata, ...) (int, error)
- func QuadletDir() (string, error)
- func QuadletExists(boxName string) (bool, error)
- func QuadletExistsInstance(boxName, instance string) (bool, error)
- func QuadletFilename(boxName string) string
- func QuadletFilenameInstance(boxName, instance string) string
- func RegisterDeployStateHost(h *StateHostMechanisms)
- func RejectImageRefAsDeployName(box string) error
- func RelativeCandySequence(boxName string, parentProvided map[string]bool, ...) []string
- func RemoveBoxDeploy(dc *BundleConfig, boxName string)
- func RemoveByExactSource[T Named](entries []T, source string) ([]T, bool)
- func RemoveBySource[T Named](entries []T, boxName string) ([]T, bool)
- func RenderDnfConfWrite(d *spec.Dnf) string
- func ResolveBoxEngineForDeploy(boxName, instance, globalEngine string) string
- func ResolveBoxEngineFromMeta(meta *spec.BoxMetadata, globalEngine string) string
- func ResolveBoxLevels(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([][]string, error)
- func ResolveBoxOrder(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([]string, error)
- func ResolveCandyOrder(requested []string, layers map[string]CandyModel, ...) ([]string, error)
- func ResolveCascadePackages(layer CandyModel, img *ResolvedBox) (pkgs []string, raw map[string]any, matched bool)
- func ResolveContainer(box, instance string) (engine, name string, err error)
- func ResolveDeployBoxName(key, instance string, rp *spec.ResolvedProject) string
- func ResolveDeployChain(roots map[string]BundleNode, dotted string, root DeployExecutor) (*BundleNode, DeployExecutor, error)
- func ResolveHome(p *spec.InstallPlan, home string)
- func ResolveNodePath(roots map[string]BundleNode, path string) (*BundleNode, []*BundleNode, error)
- func ResolveSidecarContainer(box, instance, sidecar string) (engine, name string, err error)
- func ResolveTemplate(tmpl, containerName string, portMap map[int]int) string
- func ResolveUserSpec(userField string, img *buildkit.ResolvedBox) (directive, chown string)
- func ResolveVolumeBacking(boxName, instance string, labelVolumes []VolumeMount, ...) ([]VolumeMount, []ResolvedBindMount)
- func ResolveWorkingDir(volumes []VolumeMount, bindMounts []ResolvedBindMount, ...) string
- func ResourceCapArgs(sec spec.SecurityConfig) []string
- func SaveBundleConfig(dc *BundleConfig, ...) error
- func SaveDeployState(boxName, instance string, input SaveDeployStateInput, ...)
- func SchemeTarget(scheme string, port int) string
- func ScopeVolumesToDeployKey(meta *spec.BoxMetadata, deployName, instance string)
- func SecretDeclaredOnBox(meta *spec.BoxMetadata) map[string]bool
- func SecretDepNames(meta *spec.BoxMetadata) []string
- func SecretKeyForDep(dep spec.EnvDependency) (service, key string)
- func SecurityArgs(sec spec.SecurityConfig) []string
- func ServiceEntryAppliesToDistro(entry *ServiceEntry, distros []string) bool
- func ServiceName(boxName string) string
- func ServiceNameInstance(boxName, instance string) string
- func ServiceRenderDistros(img *ResolvedBox, hostCtx HostContext) []string
- func SidecarTemplatesOf(dc *BundleConfig) map[string]json.RawMessage
- func SortByPopularity(s []string, popularity map[string]int)
- func SortedEnvList(env map[string]string) []spec.KeyValue
- func SortedKeys(m map[string]*TrieNode) []string
- func SortedNestedKeys(children map[string]*BundleNode) []string
- func SplitDottedPath(path string) []string
- func StageInlineContent(buildDir, contextRelPrefix, candyName, content string) (string, error)
- func StepToView(step InstallStep) spec.InstallStepView
- func StepsToView(steps []InstallStep) []spec.InstallStepView
- func StringSliceFromYAML(v any) ([]string, bool)
- func StripSecretEnvNames(env map[string]string, blocked []string) map[string]string
- func StripVersion(ref string) (string, string)
- func SystemdUserDir() (string, error)
- func TailscaleFlag(scheme string) string
- func TaskCacheMounts(t vmshared.Op, img *buildkit.ResolvedBox) []string
- func TaskCoalescesWith(current, next vmshared.Op, currentVerb string) bool
- func TaskKnownNames(vars map[string]string) map[string]bool
- func TaskSubstAutoExports(s string, img *buildkit.ResolvedBox) string
- func TaskSubstPath(p string, img *buildkit.ResolvedBox) string
- func TaskUnresolvedRefs(s string, known map[string]bool) []string
- func TopoSortByPopularity(graph map[string][]string, popularity map[string]int) ([]string, error)
- func TunnelServiceFilename(boxName string) string
- func UpdateBoxBase(imgName, parentName string, result map[string]*buildkit.ResolvedBox)
- func ValidateProvidesTemplate(tmpl string) bool
- func WalkDeploymentTree(rootPath string, root *BundleNode, parentExec DeployExecutor, ...) error
- func WireView(p *spec.InstallPlan) spec.InstallPlanView
- type AliasYAML
- type ApkInstallStep
- type ApkPackageSpec
- type ArtifactRef
- type BuilderDef
- type BuilderPreresolved
- type BuilderRunOpts
- type BuilderStep
- type BundleConfig
- func ExportAllBox(rp *spec.ResolvedProject) *BundleConfig
- func LoadBundleConfig() (*BundleConfig, error)
- func LoadDeployConfigForRead(context string) *BundleConfig
- func LoadDeployConfigForWrite(context string) (*BundleConfig, error)
- func LoadDeployFile(path string) (*BundleConfig, error)
- func MergeDeployConfigs(configs ...*BundleConfig) *BundleConfig
- func (dc *BundleConfig) DeployedContainerNames() []string
- func (dc *BundleConfig) GlobalEnvForImage(consumerKey, ctrName string, acceptedEnv map[string]bool) []string
- func (dc *BundleConfig) Lookup(deployName, instance string) (BundleNode, bool)
- func (dc *BundleConfig) LookupKey(key string) (BundleNode, bool)
- func (dc *BundleConfig) OccupiedHostPorts(excludeKey string) map[int]bool
- type BundleNode
- type CacheMountDef
- type CacheMountSpec
- type CandyArtifact
- type CandyCapabilities
- type CandyModel
- type CandyPluginDecl
- type CandyRef
- type CandyYAML
- type CollectedSecret
- type CycleError
- type DataProvisionMode
- type DataYAML
- type DeployExecutor
- func AppendHopForFlatPath(chain DeployExecutor, node *BundleNode, flatPath, leaf string) (DeployExecutor, error)
- func CheckBoxContainerChain(engine, imageRef string) (DeployExecutor, func(), error)
- func ContainerChain(engine, containerName string) DeployExecutor
- func RootExecutorForDeployNode(node *BundleNode) (DeployExecutor, error)
- func VmChildExecutor(parentExec DeployExecutor, deployName string) (DeployExecutor, error)
- type DeployTarget
- type DeployTreePhase
- type DeployTreeVisitor
- type EmitOpts
- type EmitPluginOpParams
- type EmitPluginOpResult
- type EnsureBuildersParams
- type EnvConfig
- type EnvDependency
- type EnvProvideEntry
- type ExternalPluginStep
- type ExternalStep
- type ExtractYAML
- type FileStep
- type Gate
- type Generator
- func (g *Generator) BuildStageContext(layer CandyModel, builderName string, builderDef *buildkit.BuilderDef, ...) *spec.BuildStageContext
- func (g *Generator) BuilderRefForFormat(boxName, format string) string
- func (g *Generator) CandyCopySource(candyRef string) string
- func (g *Generator) CandyNeedsBuilder(img *buildkit.ResolvedBox, layer CandyModel, builderDef *buildkit.BuilderDef) bool
- func (g *Generator) CollectBuilderRuntimeEnv(candyOrder []string, img *buildkit.ResolvedBox) []*kit.EnvConfig
- func (g *Generator) EmitBaseBootstrap(b *strings.Builder, boxName string, img *buildkit.ResolvedBox)
- func (g *Generator) EmitBuilderArtifacts(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string)
- func (g *Generator) EmitBuilderStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, ...) error
- func (g *Generator) EmitExternalBuilderArtifacts(b *strings.Builder, candyOrder []string)
- func (g *Generator) EmitExternalBuilderStages(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string) error
- func (g *Generator) EmitExtractStages(b *strings.Builder, candyOrder []string)
- func (g *Generator) EmitExtractedFiles(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string)
- func (g *Generator) EmitInitAssembly(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string, ...) error
- func (g *Generator) EmitInitFragmentStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, ...) (map[string]bool, error)
- func (g *Generator) EmitPreMainCandyStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, ...) error
- func (g *Generator) EmitScratchStages(b *strings.Builder, candyOrder []string)
- func (g *Generator) EmitTasks(b *strings.Builder, layer CandyModel, img *buildkit.ResolvedBox, ...) (string, error)
- func (g *Generator) EmitTraefikRouteStage(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, ...) (hasRoutes, hasTraefik bool, err error)
- func (g *Generator) Generate(order []string) error
- func (g *Generator) GenerateInitFragments(boxName, initName string, def *spec.ResolvedInit, candyOrder []string) error
- func (g *Generator) GenerateTraefikRoutes(boxName string, candyOrder []string, _ *buildkit.ResolvedBox) error
- func (g *Generator) GlobalOrderForBox(imageCandies []string, parentCandies map[string]bool) ([]string, error)
- func (g *Generator) ResolveBaseImage(img *buildkit.ResolvedBox) string
- func (g *Generator) WriteBootstrap(b *strings.Builder, img *buildkit.ResolvedBox)
- func (g *Generator) WriteCandyEnv(b *strings.Builder, candyOrder []string, img *buildkit.ResolvedBox)
- func (g *Generator) WriteCandySteps(b *strings.Builder, candyName string, img *buildkit.ResolvedBox, ...) (bool, error)
- func (g *Generator) WriteDataStaging(b *strings.Builder, candyOrder []string, img *buildkit.ResolvedBox)
- func (g *Generator) WriteExpose(b *strings.Builder, boxName string)
- func (g *Generator) WriteLabels(b *strings.Builder, meta *spec.BakedLabelSet, boxName string)
- type HooksConfig
- type HostContext
- type InlineBuilderParams
- type InlineBuilderResult
- type InstallOptsConfig
- type InstallPlan
- type InstallStep
- func CompileApkStep(layer CandyModel) InstallStep
- func CompileLocalPkgStep(layer CandyModel, img *ResolvedBox, _ HostContext) InstallStep
- func CompileOpSteps(layer CandyModel, img *ResolvedBox) []InstallStep
- func CompileShellSnippetSteps(layer CandyModel, img *ResolvedBox, hostCtx HostContext) []InstallStep
- func CompileSystemPackageSteps(layer CandyModel, img *ResolvedBox, _ HostContext) []InstallStep
- func StepFromView(v spec.InstallStepView) (InstallStep, error)
- type JumpKind
- type LocalPkgDef
- type LocalPkgInstallStep
- type LocalPkgParams
- type LocalPkgResult
- type MCPProvideEntry
- type MCPServerYAML
- type Named
- type NestedExecutor
- type NestedJump
- type OCIEmitStepParams
- type OCITarget
- type Op
- type OpStep
- type PackageItem
- type PackageSection
- type Phase
- type PortSpec
- type PreemptibleConfig
- type ProvidesConfig
- type QuadletConfig
- type RebootStep
- type RelayContext
- type RepoChangeStep
- type RepoSpec
- type ResolvedBindMount
- type ResolvedBox
- type ResolvedSidecar
- type ReverseOp
- type ReverseOpKind
- type RouteConfig
- type SSHExecutor
- type SaveDeployStateInput
- type Scope
- type SecretYAML
- type SecurityConfig
- type ServiceCustomStep
- type ServiceEntry
- type ServicePackagedStep
- type ShellConfig
- type ShellExecutor
- type ShellHookStep
- type ShellSnippetStep
- type ShellSpec
- type SiblingKey
- type StageFragmentContext
- type StateHostMechanisms
- type Step
- type StepBatch
- type StepKind
- type SystemEnableContext
- type SystemPackagesStep
- type TagPkgConfig
- type TrieNode
- type Venue
- type VolumeMount
- type VolumeYAML
Constants ¶
const ( VenueLocal = kit.VenueLocal JumpPodmanExec = kit.JumpPodmanExec JumpDockerExec = kit.JumpDockerExec JumpSSH = kit.JumpSSH JumpVirshConsole = kit.JumpVirshConsole )
const ( RenderSeamInlineBuilder = "inline-builder" RenderSeamLocalPkg = "local-pkg" RenderSeamEnsureBuilders = "ensure-builders" RenderSeamEmitPluginOp = "emit-plugin-op" )
RenderSeam method discriminators (the RenderSeamRequest.Method values).
const ( PreemptStopShutdown = spec.PreemptStopShutdown PreemptRestoreAlways = spec.PreemptRestoreAlways )
const ( ScopeSystem = spec.ScopeSystem ScopeUser = spec.ScopeUser ScopeUserProfile = spec.ScopeUserProfile PhasePrepare = spec.PhasePrepare PhaseInstall = spec.PhaseInstall PhaseCleanup = spec.PhaseCleanup VenueHostNative = spec.VenueHostNative VenueContainerBuilder = spec.VenueContainerBuilder VenueSkip = spec.VenueSkip GateNone = spec.GateNone GateAllowRepoChanges = spec.GateAllowRepoChanges GateAllowRootTasks = spec.GateAllowRootTasks GateWithServices = spec.GateWithServices StepKindSystemPackages = spec.StepKindSystemPackages StepKindBuilder = spec.StepKindBuilder StepKindOp = spec.StepKindOp StepKindFile = spec.StepKindFile StepKindServicePackaged = spec.StepKindServicePackaged StepKindServiceCustom = spec.StepKindServiceCustom StepKindShellHook = spec.StepKindShellHook StepKindShellSnippet = spec.StepKindShellSnippet StepKindRepoChange = spec.StepKindRepoChange StepKindApkInstall = spec.StepKindApkInstall StepKindLocalPkgInstall = spec.StepKindLocalPkgInstall StepKindReboot = spec.StepKindReboot StepKindExternalPlugin = spec.StepKindExternalPlugin ReverseOpCoprDisable = spec.ReverseOpCoprDisable ReverseOpPackageRemove = spec.ReverseOpPackageRemove ReverseOpRemoveDropin = spec.ReverseOpRemoveDropin ReverseOpRemoveEnvdFile = spec.ReverseOpRemoveEnvdFile ReverseOpRemoveManaged = spec.ReverseOpRemoveManaged ReverseOpRemoveRepoFile = spec.ReverseOpRemoveRepoFile ReverseOpRestoreEnabled = spec.ReverseOpRestoreEnabled ReverseOpRmFileSystem = spec.ReverseOpRmFileSystem ReverseOpRmFileUser = spec.ReverseOpRmFileUser ReverseOpServiceDisable = spec.ReverseOpServiceDisable ReverseOpServiceRemove = spec.ReverseOpServiceRemove )
const ExternalStepKindPrefix = "external:"
ExternalStepKindPrefix marks a StepKind string as an external (plugin-contributed) kind.
const HomeToken = "{{.Home}}"
HomeToken is the deferred-home placeholder resolved by ResolveHome at emit time.
const SeederHelperImage = "docker.io/library/busybox:stable"
SeederHelperImage is a small runnable image used to copy data from a FROM-scratch data image into a named volume. Pulled lazily on first use. busybox:stable has cp + sh and is ~2MB.
Variables ¶
var ( ExpandPath = kit.ExpandPath KwRun = kit.KwRun )
var AllStepKinds = []StepKind{ StepKindSystemPackages, StepKindBuilder, StepKindOp, StepKindFile, StepKindServicePackaged, StepKindServiceCustom, StepKindShellHook, StepKindShellSnippet, StepKindRepoChange, StepKindApkInstall, StepKindLocalPkgInstall, StepKindReboot, StepKindExternalPlugin, }
AllStepKinds is the fixed InstallStep IR vocabulary — the 13 compiled-in concrete step kinds (external:<word> kinds are dynamic and not listed).
var CompileActOp func(op *Op, layer CandyModel, img *ResolvedBox) InstallStep
CompileActOp lowers a `run:` act op (install verb or `plugin:` verb) into an InstallStep. Provider-coupled (kernel provider registry), so charly owns it and injects it; the compiler calls the seam.
var CompileServiceSteps func(layer CandyModel, img *ResolvedBox, hostCtx HostContext) []InstallStep
CompileServiceSteps lowers a candy's service: list into install steps. Loader- and service-render-coupled (LoadBuildConfigForBox + RenderService live in charly), so charly owns it and injects it.
var OpInContext func(op *Op, ctx spec.ExecContext) bool
OpInContext reports whether an op runs in the given exec context. Its fallback consults the kernel VerbCatalog (charly), so charly injects the impl at init. ExecContext (+ Ctx consts) is spec.ExecContext — a plain shared vocabulary type (K3, #39).
var ShellAllowlist = map[string]bool{"bash": true, "zsh": true, "fish": true, "sh": true}
ShellAllowlist enumerates valid per-shell sub-block keys inside `shell:`.
var TaskAutoExports = map[string]bool{ "USER": true, "UID": true, "GID": true, "HOME": true, "ARCH": true, "BUILD_ARCH": true, }
TaskAutoExports are the auto-exported variable names reserved for the generator; `vars:` entries may not shadow these, and every `${VAR}` reference resolves against (auto-exports ∪ candy.Vars).
var TaskVarRefPattern = regexp.MustCompile(`\$\{([A-Z_][A-Z0-9_]*)\}`)
TaskVarRefPattern matches ${NAME} references in task fields.
var VmSshAlias = kit.VmSshAlias
Functions ¶
func AbsoluteCandySequence ¶ added in v0.2026193.1801
func AbsoluteCandySequence(boxName string, boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel, globalOrder []string) []string
AbsoluteCandySequence returns an image's complete candy set (own + entire base chain) as a subsequence of the global order.
func AcceptedEnvSet ¶ added in v0.2026198.358
func AcceptedEnvSet(accepts, requires []spec.EnvDependency) map[string]bool
AcceptedEnvSet builds a set of env var names from env_accepts and env_requires declarations. Used to filter which env_provides vars get injected into a consumer.
func AddTransitiveDeps ¶ added in v0.2026193.1801
func AddTransitiveDeps(candyName string, layers map[string]CandyModel, needed map[string]bool, excluded map[string]bool)
AddTransitiveDeps adds all transitive dependencies of a candy to the needed set.
func AppendOrReplaceEnv ¶ added in v0.2026190.848
AppendOrReplaceEnv adds or replaces an env var entry (KEY=VALUE) in a slice. If the key already exists, the value is replaced in-place.
func AppendShellPathLines ¶ added in v0.2026190.848
AppendShellPathLines appends path_append entries to the snippet body using shell-appropriate syntax. bash/zsh/sh use POSIX `PATH=$PATH:X` exports; fish uses `fish_add_path X`. Idempotent: if body already ends with a newline, no extra blank line is inserted.
func ArgHasImageTag ¶ added in v0.2026190.848
ArgHasImageTag reports whether arg's trailing path segment carries a ":tag" — the marker of a registry IMAGE ref (ghcr.io/org/image:tag), as opposed to a github REPO ref (which pins with @version) or a dotted-path deploy address. Shared by CanonicalizeDeployArg + the deploy-name guard (R3).
func BareRef ¶ added in v0.2026190.848
BareRef returns the map-key form of a ref (no @ prefix, no :version).
func BedCheckLiveRefs ¶ added in v0.2026190.848
func BedCheckLiveRefs(name string, children map[string]*BundleNode) []string
SortedNestedKeys returns the keys of a children map in deterministic order so traversal produces stable output across runs. BedCheckLiveRefs returns the ordered `charly check live` targets for a bed: the substrate itself first, then each nested child as a sorted dotted path. This is the pure list `charly check run` walks so a nested pod's BAKED candy/box check (e.g. the selkies candy's encoder + frame checks on a nested selkies-kde pod) is exercised against its real venue through the chain — not just the parent substrate. Without the nested entries, `charly check run` deploys nested children but never evaluates them. Pure + unit-tested.
func BoxDirectDeps ¶ added in v0.2026192.1709
func BoxDirectDeps(name string, img *buildkit.ResolvedBox, boxes map[string]*buildkit.ResolvedBox, includeFormatBuilders bool) []string
BoxDirectDeps returns the direct box-build dependencies of img:
- Base (when not an external OCI ref)
- Builder.AllBuilder() format-builder boxes (only when includeFormatBuilders)
- BootstrapBuilderImage (the `from: builder:pacstrap` / debootstrap source)
Self-refs and refs to boxes not in the map (for builder + bootstrap builder) are filtered out. Base is appended only when it names an internal box; builder-backed images legitimately have no base.
One helper, three callers (ResolveBoxOrder, ResolveBoxLevels, filterBox in build.go) so adding a future edge kind lands in one place.
func BoxNeedsBuilder ¶ added in v0.2026192.1709
func BoxNeedsBuilder(img *buildkit.ResolvedBox, boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) bool
BoxNeedsBuilder returns true if any of the box's own resolved candies (excluding parent-provided) have pixi.toml, package.json, or Cargo.toml. When candies is nil, falls back to unconditional builder dependency.
func BuildArchExports ¶ added in v0.2026192.1709
func BuildArchExports() string
BuildArchExports emits the shell prelude that maps `uname -m` to a Go-style ARCH (amd64/arm64/arm) for download/build steps.
func BuildServiceRenderContext ¶ added in v0.2026198.254
func BuildServiceRenderContext(entry *spec.ServiceEntry, ctx spec.ServiceRenderContext) spec.ServiceRenderContext
BuildServiceRenderContext fills the entry-derived, home-expanded render context (a pure spec.ServiceEntry projection — no init-system knowledge). The plugin renders its templates against this; the packaged/drop-in branch decisions are precomputed here (PackagedUnit, RenderDropin) so the plugin renders from the ctx alone.
func BuildStartArgs ¶ added in v0.2026198.345
func BuildStartArgs(engine, imageRef string, uid, gid int, ports []string, name string, volumes []spec.VolumeMount, bindMounts []ResolvedBindMount, gpu bool, bindAddr string, envVars []string, security spec.SecurityConfig, entrypoint []string, workingDir string, network ...string) []string
BuildStartArgs constructs the container run argument list for a detached service. entrypoint is the init system command (e.g., ["supervisord", "-n", "-c", "/etc/supervisord.conf"]) or the fallback (e.g., ["sleep", "infinity"]).
func BuilderCtxKey ¶ added in v0.2026190.848
BuilderCtxKey keys the per-(candy,builder) pre-resolved builder context.
func BuilderResolveInputFrom ¶ added in v0.2026194.1727
func BuilderResolveInputFrom(candyName, builderName string, builderDef *buildkit.BuilderDef, ctx *spec.BuildStageContext) spec.BuilderResolveInput
BuilderResolveInputFrom builds the serializable spec.BuilderResolveInput a builder plugin's OpResolve leg needs, from the host-computed BuildStageContext. Cache mounts are PRE-RENDERED to flag strings here (buildkit.RenderCacheMounts) with the SAME separator/trailing the former cacheMountsOwned/cacheMountsAuto template funcs used, so the plugin's rendered stage is byte-identical to the former embedded-vocabulary render. Shared by the box-build path (resolveDetectionBuilderReply) AND the pod-overlay build-emit (charly stepEmitBuilder) + the inline-builder seam (charly resolveInlineBuilderSeam), R3 — hence exported.
func BundleWalkPostOrder ¶ added in v0.2026190.848
func BundleWalkPostOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error
WalkPostOrder invokes fn on every child (recursively, post-order) before invoking fn on this node. Post-order is the delete-order semantic: a child must be torn down while its parent environment is still alive, so the caller reverses leaves first.
func BundleWalkPreOrder ¶ added in v0.2026190.848
func BundleWalkPreOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error
WalkPreOrder invokes fn on this node, then recurses into every child in sorted key order. Pre-order is the add-order semantic: a parent's environment must exist before its children can run inside it, so the caller applies deploys root-first.
fn receives the full dotted path to each node (e.g. "stack.web.db"). The root path argument is prepended; callers pass the node's own key as `path`.
When fn returns a non-nil error, traversal stops immediately and the error propagates.
func CandyMapKey ¶ added in v0.2026192.1709
func CandyMapKey(layer CandyModel) string
CandyMapKey returns the candy's map key: the full @github ref for a remote candy (RepoPath/SubPathPrefix+Name), else the bare Name. Relocated from charly (P8).
func CandyNeedsBuilderStep ¶ added in v0.2026190.848
func CandyNeedsBuilderStep(layer CandyModel, bDef *BuilderDef) bool
CandyNeedsBuilderStep mirrors Generator.candyNeedsBuilder without requiring a Generator receiver — the compiler doesn't have one.
func CandyProvidedByBox ¶ added in v0.2026192.1709
func CandyProvidedByBox(boxName string, boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) (map[string]bool, error)
CandyProvidedByBox returns the set of candies installed by a box (including those inherited from parent boxes via base chain)
func CandyStageDirName ¶ added in v0.2026192.1709
func CandyStageDirName(layer CandyModel) string
CandyStageDirName returns the content-addressed staging dir name for a remote candy's copied tree (name.version). Relocated from charly (P8); byte-identical.
func CanonicalizeDeployArg ¶ added in v0.2026190.848
CanonicalizeDeployArg splits Pattern A "<base>/<instance>" CLI positional args into their component (image, instance) pair. Idempotent: if the input is already split (instance != "") or contains no slash, returns as-is. Pattern B (FQ ref containing "/") is identified by presence of "@" or ":" suffix on the leftmost segment OR a registry-host pattern (contains "." before the first "/") and passed through untouched.
MUST be called at the top of every CLI verb that takes a positional deploy-arg (`charly config`, `charly start`, `charly stop`, `charly shell`, `charly logs`, `charly update`, `charly status`, `charly remove`) — before any downstream code reads c.Image or c.Instance. Without this, Pattern A instance deploys leak past the canonicalization boundary and downstream code conflates the deploy key with the image short-name (see Bug 2/3 RCA notes — MergeDeployOntoMetadata composes wrong key, port/env overlays drop).
func CascadeTagChain ¶ added in v0.2026190.848
func CascadeTagChain(img *ResolvedBox) []string
ResolveCascadePackages is THE single distro-specificity cascade resolver, shared by EVERY package-emitting path — the deploy compiler (CompileSystemPackageSteps) AND the image-build Containerfile emitter (generate.go writeCandySteps). There is exactly one resolution so build and deploy can never diverge.
It computes the primary-format package set for a candy on an image: the candy's top-level `package:` BASE, UNION every matching distro tag section walked most-specific-first over img.Distro (deduped), with the Raw extras repo/copr/options/exclude/module resolved MOST-SPECIFIC-WINS. Returns the package list, the rendered Raw install context (including the unioned `package` list), and whether any tag section matched. CascadeTagChain returns the full per-candy cascade tag chain MOST-SPECIFIC FIRST: the image's distro chain (e.g. [debian:13, debian]) followed by the package-format FAMILY tag (img.Pkg = deb/pac/rpm) as the LEAST-specific level. A `distro: deb:` candy block therefore applies to EVERY deb-format distro (debian + ubuntu + their versions), `pac:` to arch + cachyos, `rpm:` to fedora — the family-generic level of the YAML-configured deb/pac/rpm → distro → version hierarchy. img.Pkg is the primary package format declared by the embedded vocabulary (charly/charly.yml), so the hierarchy lives entirely in YAML.
Distro INHERITANCE is the complementary YAML mechanism: img.Distro is already expanded (at resolve time, ExpandPackageInheritance) to include any `inherit_packages: true` ancestor, so a cachyos image/VM carries [cachyos, …, arch] and a `distro: arch:` block DOES reach cachyos — while ubuntu (no flag) stays isolated from debian. Both knobs live entirely in the embedded vocabulary (charly/charly.yml).
func ClassifyTarget ¶ added in v0.2026190.848
func ClassifyTarget(node *BundleNode) string
ClassifyTarget normalizes the Target field for dispatch. Empty Target falls back to "pod" (the default for named deploys); otherwise Target is the canonical source of truth (pod|vm|k8s|local|android — set from the node-form kind by bundleTargetForDisc; no name-prefix heuristic).
func CleanDeployEntry ¶ added in v0.2026196.928
func CleanDeployEntry(boxName, instance string, marshalNode func(name string, node *BundleNode) (*yaml.Node, error))
CleanDeployEntry removes an image's entry from charly.yml (best-effort). Also removes global service env vars injected by this image. If charly.yml becomes empty after removal, the file is deleted. Relocated from charly/deploy.go (K5-Unit-1); the flock is a kind-blind kit primitive (kit.AcquireFileLock) and the loader reaches core through the DeployStateHost seam. marshalNode is the deploy-kind-specific node-form serializer the caller supplies.
func CollectAllBoxCandies ¶ added in v0.2026192.1709
func CollectAllBoxCandies(boxName string, boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) []string
CollectAllBoxCandies returns an image's complete candy set (its own resolved candies plus every candy inherited through the full base chain), in first-seen order. Relocated from charly core (P8); byte-identical to the former charly/intermediates.go collectAllBoxCandies.
walked is an IMAGE-visited guard for the base-chain recursion: a base edge may form a cycle (A.base=B, B.base=A) — caught + reported by ResolveBoxOrder, but without this guard the walk recurses a cyclic chain until the stack overflows. Re-visiting a base also can't add new candies, so skipping it is correct for the acyclic case too.
func CollectSubtreeBoxes ¶ added in v0.2026193.1801
CollectSubtreeBoxes returns every terminal user image in the subtree rooted at node — the images terminating at node plus all images in descendant nodes. These are exactly the images that will base, directly or transitively, on an auto-intermediate created at this node, so they define the union of build formats / distro tags the intermediate must carry (see createIntermediate).
func ComputeDeployID ¶ added in v0.2026190.848
ComputeDeployID returns a deterministic hex hash that identifies a specific deploy (image + ordered candy set + add_candy). Used as the ledger key so re-deploys of the same config are recognizable and candy-refcount bookkeeping is stable.
func ComputeEffectiveVersions ¶ added in v0.2026192.1709
func ComputeEffectiveVersions(boxes map[string]*buildkit.ResolvedBox, candies map[string]CandyModel) error
ComputeEffectiveVersions assigns ResolvedBox.EffectiveVersion for every image in the build graph. EffectiveVersion is the content-derived identity emitted as the ai.opencharly.version OCI label. Relocated from charly core (P8); byte-identical.
- the image's dedicated `version:` (img.Version) if set; else
- the highest candy `version:` across its full candy set (CollectAllBoxCandies spans the entire base chain); else
- the internal base image's EffectiveVersion (recurse); else
- a HARD ERROR — there is NO build-timestamp fallback.
Run AFTER ComputeIntermediates + GlobalCandyOrder so the base chain and the auto-intermediate images are fully materialized in boxes.
func ComputeOwnCandies ¶ added in v0.2026193.1801
func ComputeOwnCandies(parentName string, pathCandies []string, result map[string]*buildkit.ResolvedBox, layers map[string]CandyModel, globalOrder []string, pixiBound map[string]bool) []string
ComputeOwnCandies determines which candies an intermediate needs to install (pathCandies minus what the parent already provides).
func DeployKey ¶ added in v0.2026190.848
DeployKey returns the charly.yml map key for an image, optionally qualified by instance. Base images use just the image name; instances use "image/instance".
func DeployStorageDir ¶ added in v0.2026193.1222
DeployStorageDir is the per-deploy directory component for bind-auto paths and encrypted-volume directories. Like DeployVolumePrefix it is unique per deploy (base vs instance vs Pattern-B vs bed). For a base deploy with no instance it is just the deploy key; an instance appends "-<instance>".
func DeployVolumePrefix ¶ added in v0.2026193.1222
DeployVolumePrefix is the named-volume prefix for a deploy: the deploy's container name plus a dash, so EVERY distinctly-named deploy (base, Pattern-B, instance, or kind:check bed) gets its own volume namespace. Two deploys never share a named volume unless they share a container name (which they can't). Single source of truth for volume naming — ResolveVolumeBacking, removeVolumes, and scopeVolumesToDeployKey all key off it.
func DescribePlan ¶ added in v0.2026190.848
func DescribePlan(p *InstallPlan) string
DescribePlan returns a short human-readable summary of a plan. Used by --dry-run table output and by TestDescribePlan for golden comparison.
func DescriptionInfo ¶ added in v0.2026196.928
DescriptionInfo returns the human-facing summary: the FIRST line of the plain-string description (multi-line prose lives in the rest of the string). Relocated from charly/generate.go so MergeDeployOntoMetadata (deploy_file.go) reads it without a core dep.
func DetectExternalizedBuilders ¶ added in v0.2026194.1727
func DetectExternalizedBuilders(order []string, candies map[string]CandyModel, externalized map[string]bool, img *buildkit.ResolvedBox) []string
DetectExternalizedBuilders returns the externalized builder words an image triggers, so a caller can connect exactly those plugins on-demand. A config-only detection (aur) runs a distro-specific install_template, so it is only needed when the image's build formats include that format (the DetectConfig gate — a multi-distro candy's aur: section must NOT pull arch tooling onto a fedora build); a detect-files builder is needed by any candy carrying the file. Uses the img-less CandyNeedsBuilderStep (the DetectConfig BuildFormats gate is applied here, not in the step check). The SINGLE detection impl shared (R3) by the box-build RENDER (EmitBuilderStages, over the Generator's Candies + ExternalizedBuilders) AND the charly deploy build PRE-PASS (over its candy map + externalizedBuilders registry set).
func DropMappingKey ¶ added in v0.2026190.848
DropMappingKey removes a key (and its value) from a YAML mapping node in place.
func EmitCmd ¶ added in v0.2026192.1709
func EmitCmd(b *strings.Builder, t vmshared.Op, layerStage string, img *buildkit.ResolvedBox, userIsRoot bool)
EmitCmd emits a single RUN for a cmd task, with the layer-stage /ctx bind mount plus cache mounts appropriate to the user (distro format caches for root, npm cache for non-root). Shell is bash via a single-quoted heredoc so authors' $(cmd) / ${VAR} stay intact for bash; BUILD_ARCH is injected as a shell var.
func EmitCopy ¶ added in v0.2026192.1709
EmitCopy emits a COPY --from=<layer-stage> for an existing file in the candy dir.
func EmitDownload ¶ added in v0.2026192.1709
EmitDownload emits one RUN per download task: fetch to a content-addressed /tmp/downloads cache, then extract. Honors candy-declared `cache:` mounts.
func EmitLinkBatch ¶ added in v0.2026192.1709
EmitLinkBatch emits a single RUN with chained ln -sf for a batch of adjacent same-user link tasks.
func EmitMkdirBatch ¶ added in v0.2026192.1709
EmitMkdirBatch emits a single RUN mkdir -p for a batch of adjacent same-user mkdir tasks, splitting per-mode chmod at the tail when modes differ.
func EmitSetcapBatch ¶ added in v0.2026192.1709
EmitSetcapBatch emits a single RUN setcap … for a batch of adjacent setcap tasks (strip via -r for empty caps, set otherwise), chained with &&.
func EmitVarsEnv ¶ added in v0.2026192.1709
EmitVarsEnv writes ENV directives for candy.Vars and the build-arg-sourced ARCH auto-export. Sorts vars by key for deterministic output; emitted once per candy.
func EmitWrite ¶ added in v0.2026192.1709
EmitWrite emits a COPY from the staged inline-content dir to the destination.
func EncryptedCipherDir ¶ added in v0.2026194.615
EncryptedCipherDir returns the cipher (encrypted-blob) directory for an encrypted bind mount: <storagePath>/<EncryptedVolumeName>/cipher.
func EncryptedPlainDir ¶ added in v0.2026194.615
EncryptedPlainDir returns the plain (FUSE mount-point) directory for an encrypted bind mount: <storagePath>/<EncryptedVolumeName>/plain.
func EncryptedVolumeName ¶ added in v0.2026194.615
EncryptedVolumeName returns the directory name for an encrypted volume: charly-<box>-<name>.
func EnsureServiceSuffix ¶ added in v0.2026190.848
EnsureServiceSuffix adds `.service` if missing. Distinguishes unit types: if the caller already included a suffix (e.g. "foo.timer", "foo.socket"), leave it alone.
func ExpandCandy ¶ added in v0.2026192.1709
func ExpandCandy(requested []string, layers map[string]CandyModel) ([]string, error)
ExpandCandy expands candy composition references (candy: field in the candy manifest). For each candy that has IncludedCandies, recursively inserts them into the result. Candies without content (no install files, no env/ports/etc.) are omitted. Returns a flat, deduplicated candy list.
func ExtractStringSlice ¶ added in v0.2026190.848
ExtractStringSlice returns m[key] as []string or nil if absent. Accepts []string and []interface{} (as produced by yaml.v3) inputs.
func FilterOwnProvides ¶ added in v0.2026198.358
FilterOwnProvides removes entries injected by the given image (self-exclusion). Kept for RemoveBySource and other callers that need strict exclusion.
func FindPodSidecarQuadlets ¶ added in v0.2026198.358
FindPodSidecarQuadlets returns the .container quadlets in qdir that belong to the pod podName, identified by the load-bearing `Pod=<podName>.pod` directive inside the quadlet's [Container] section. Filename-prefix matching is NOT used because it collides with sibling instances of the same image (e.g. charly-versa-ecovoyage.container is an instance of versa, NOT a sidecar of pod charly-versa.pod). Only true pod members carry the Pod= directive — sibling instances and standalone container deploys do not. mainContainerFile (typically the main pod container's quadlet filename) is excluded from the returned list because its lifecycle is owned by the caller's main systemctl disable, not by the sidecar sweep.
func FlattenedEnvMap ¶ added in v0.2026198.254
func FlattenedEnvMap(base map[string]string, overrides *spec.CandyServiceOverrides) map[string]string
FlattenedEnvMap merges an entry's base env with its overrides' env (overrides win).
func FormatCPUQuota ¶ added in v0.2026194.615
FormatCPUQuota converts a podman --cpus value ("2.5") to systemd's CPUQuota percentage form ("250%"); empty/unparseable → "" (skip the directive).
func GateEnabled ¶ added in v0.2026190.848
GateEnabled returns whether the given gate is permitted under opts. GateNone is always enabled; named gates require the corresponding opt-in flag.
func GeneratePodQuadlet ¶ added in v0.2026194.615
func GeneratePodQuadlet(cfg QuadletConfig) string
GeneratePodQuadlet produces the contents of a quadlet .pod file. The pod owns the shared network namespace: ports, network, and Tailscale tun interface.
Dual networking: the pod stays on the "charly" bridge (reachable by other containers) while the Tailscale sidecar adds a tun interface for exit node routing. --exit-node-allow-lan-access exempts bridge subnets from the tunnel.
func GenerateQuadlet ¶ added in v0.2026194.615
func GenerateQuadlet(cfg QuadletConfig) string
GenerateQuadlet produces the contents of a quadlet .container file. Pure.
func GenerateSidecarQuadlet ¶ added in v0.2026194.615
func GenerateSidecarQuadlet(sc ResolvedSidecar, podName string) string
GenerateSidecarQuadlet produces the contents of a sidecar .container file.
func GenerateTunnelUnit ¶ added in v0.2026194.615
func GenerateTunnelUnit(cfg QuadletConfig, cfgPath string) string
GenerateTunnelUnit produces the companion systemd .service unit for a cloudflare tunnel. Relocated from charly core with the P11 config-write move (the deploy:pod plugin writes it); cfgPath (the cloudflared config path) is passed in by the host — the resolution helper tunnelConfigPath stays core, so this generator is pure. Returns "" for a non-cloudflare (or nil) tunnel. Byte-identical to the former core generateTunnelUnit given the same cfgPath.
func GlobalCandyOrder ¶ added in v0.2026193.1801
func GlobalCandyOrder(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([]string, error)
GlobalCandyOrder computes a global topological order of all candies across all enabled images, using popularity (number of images needing each candy) as the primary tie-breaker and lexicographic as secondary.
func GraphReaches ¶ added in v0.2026193.1801
GraphReaches reports whether `to` is reachable from `from` by following dependency edges (graph[x] lists the candies x depends on). Used to keep authored-list-order edge insertion cycle-safe in GlobalCandyOrder.
func HasTailscaleSidecar ¶ added in v0.2026198.358
func HasTailscaleSidecar(sidecars map[string]json.RawMessage) bool
HasTailscaleSidecar reports whether a name-keyed sidecar map (opaque bodies) attaches the tailscale sidecar — a pure key-existence check.
func InitHasRelayTemplate ¶ added in v0.2026192.1709
func InitHasRelayTemplate(def *spec.ResolvedInit) bool
InitHasRelayTemplate reports whether this init definition has a relay template. Relocated from charly (P8).
func InitRenderAssemblyTemplate ¶ added in v0.2026192.1709
func InitRenderAssemblyTemplate(def *spec.ResolvedInit) (string, error)
InitRenderAssemblyTemplate renders an init system's assembly_template (the step that assembles contributed unit fragments). Relocated from charly (P8).
func InitRenderPostAssemblyTemplate ¶ added in v0.2026192.1709
func InitRenderPostAssemblyTemplate(def *spec.ResolvedInit) (string, error)
InitRenderPostAssemblyTemplate renders the post_assembly_template (e.g. bootc container lint). Relocated from charly (P8).
func InitRenderRelayTemplate ¶ added in v0.2026192.1709
func InitRenderRelayTemplate(def *spec.ResolvedInit, port int, candyName string, index int) (string, error)
InitRenderRelayTemplate renders the relay_template for a port relay. Relocated from charly (P8).
func InitRenderStageFragmentCopy ¶ added in v0.2026192.1709
func InitRenderStageFragmentCopy(def *spec.ResolvedInit, boxName, fileName string) (string, error)
InitRenderStageFragmentCopy renders the stage_fragment_copy template. Relocated from charly (P8).
func InitRenderSystemEnableTemplate ¶ added in v0.2026192.1709
func InitRenderSystemEnableTemplate(def *spec.ResolvedInit, units []string) (string, error)
InitRenderSystemEnableTemplate renders the system_enable_template for the given distro-shipped units. Relocated from charly (P8).
func IntersectPlatforms ¶ added in v0.2026193.1801
IntersectPlatforms returns platforms present in both slices. If the intersection is empty, returns parent (the more restrictive set).
func IpcModeBlocksShmSize ¶ added in v0.2026194.615
IpcModeBlocksShmSize reports whether an IPC mode makes podman reject ShmSize.
func IsAutoVmDeployEntry ¶ added in v0.2026190.848
func IsAutoVmDeployEntry(entry BundleNode) bool
IsAutoVmDeployEntry reports whether a VM deploy entry carries NOTHING beyond the fields saveVmDeployState auto-sets — target: vm, vm:, and vm_state. Such an entry is a pure runtime-state record (e.g. a disposable check-bed VM) that `charly vm destroy` should delete so it doesn't accumulate. Any OTHER non-zero field means operator-authored per-host config (preemptible, env, tunnel, port, security, …) that MUST survive a destroy→create cycle. Compares against the zero node after blanking the three auto-set fields, so a newly-added per-host field is covered automatically (no remembered append — same drift-proof discipline as MergeBundleNode).
func IsExternalStepKind ¶ added in v0.2026190.848
IsExternalStepKind reports whether k is an external (plugin-contributed) step kind.
func IsRemoteCandyRef ¶ added in v0.2026190.848
IsRemoteCandyRef reports whether a ref is an @-prefixed remote ref.
func IsSameBaseBox ¶ added in v0.2026196.928
IsSameBaseBox returns true if source is the same base image (with or without instance). Relocated from charly/deploy.go (used by RemoveBySource).
func IsTCPFamily ¶ added in v0.2026194.615
IsTCPFamily reports whether a scheme uses TCP-style forwarding.
func LocalizePort ¶ added in v0.2026194.615
LocalizePort applies a host bind address to a port mapping.
func MapToKeyValueSlice ¶ added in v0.2026192.1709
MapToKeyValueSlice deterministically sorts a map into []spec.KeyValue for template iteration. Matches the ServiceRenderContext contract. Relocated (P8).
func MarshalBundleNode ¶ added in v0.2026198.345
MarshalBundleNode emits a BundleNode as the compact name-first node-form the per-host overlay loader accepts: the kind discriminator carries the FULL body inline (scalars, collections, the resugared plan: step list), and nested/peer members become child nodes (recursive; discriminator inferred by bundleDiscForEntity). The loader-derived target / descent are dropped (target → the discriminator; descent → never persisted, a stored descent trips #DeployValue's descent?: _|_ on reload). Comment-preserving (yaml.v3 node API).
func MergeDeployOntoMetadata ¶ added in v0.2026196.928
func MergeDeployOntoMetadata(meta *spec.BoxMetadata, dc *BundleConfig, deployName, instance string)
MergeDeployOntoMetadata applies a per-host charly.yml entry's overrides (ports, env, security, tunnel, secrets, …) onto label-derived image metadata. Field-level replace semantics. Relocated from charly/deploy.go (K5-Unit-1).
The overlay entry is keyed by deployName — the charly.yml key base the caller is operating on (the bed / instance / Pattern-B name), NOT meta.Image (the baked ai.opencharly.box short-name). For a plain deploy the two coincide, but a kind:check bed or a Pattern-B deploy carries a key distinct from its image, so the caller MUST pass its own deploy key (typically c.Image). Keying off meta.Image would read whichever sibling deploy merely shares the image and clobber this entry's explicit port:/env:/security:.
func MergeEnvVars ¶ added in v0.2026190.848
MergeEnvVars merges new env vars into existing ones (upsert by key). New vars override existing vars with the same key.
func NewSpecResolvedBox ¶ added in v0.2026195.1912
func NewSpecResolvedBox(v spec.ResolvedBoxView, distro map[string]*spec.ResolvedDistro, builder map[string]*spec.Builder) *buildkit.ResolvedBox
NewSpecResolvedBox rebuilds a *buildkit.ResolvedBox from its resolved-project envelope view + the project vocab maps (ResolvedProject.Distro / .Builder). It mirrors the host projectResolvedBox projection IN REVERSE (scalars) and re-attaches exactly the vocab pointers the deploykit render reads: DistroConfig / DistroDef / BuilderConfig (~35 img.DistroDef/DistroConfig/BuilderConfig read-sites). InitSystem/InitDef/CandyCaps are NOT re-attached — the render threads init via the activeInits param and reads no img.CandyCaps (build-mode caps are a host bootstrap concern, not a deploykit-render one).
func NormalizeCgroupSize ¶ added in v0.2026194.615
NormalizeCgroupSize converts a podman-style size ("6g") to systemd's required uppercase suffix ("6G"); systemd silently rejects lowercase on Memory* caps.
func ParentDirForDest ¶ added in v0.2026192.1709
ParentDirForDest returns the parent directory of a copy/write destination, or "" when it is the root or current dir (no auto-mkdir needed).
func ParseDeployKey ¶ added in v0.2026190.848
ParseDeployKey splits a charly.yml map key back into image name and instance. "selkies-desktop" → ("selkies-desktop", "") "selkies-desktop/foo" → ("selkies-desktop", "foo")
func PathIsSystemScoped ¶
PathIsSystemScoped returns true for paths under /etc, /usr, /var, /opt, /root, /boot and similar system locations. Used to classify FileStep scope when the compiler hasn't explicitly tagged it.
func PixiBoundCandies ¶ added in v0.2026193.1801
func PixiBoundCandies(layers map[string]CandyModel) map[string]bool
PixiBoundCandies identifies candies that have install files (user.yml/root.yml) but depend on a pixi environment from their including parent meta-candy. These candies must NOT be extracted into auto-intermediates because the intermediate won't have the pixi environment they need.
A candy is pixi-bound if: 1. It has install files (user.yml or root.yml) 2. It does NOT have its own pixi manifest (pixi.toml/pyproject.toml/environment.yml) 3. It is included via candy: by another candy that DOES have a pixi manifest
func PlanFromView ¶ added in v0.2026196.208
func PlanFromView(v spec.InstallPlanView) (*spec.InstallPlan, error)
PlanFromView re-materializes the rich in-core *spec.InstallPlan from its JSON-roundtrippable spec.InstallPlanView wire form — the REVERSE of WireView, used by the host to reconstruct []*InstallPlan from the command:bundle plugin's OpCompile reply (K4-B). Steps round-trip through the SINGLE stepsFromView converter (step_view.go), already proven round-trip-faithful by TestStepView_RoundTrip. The host re-materialized plan is byte-equivalent to the former in-proc compile output (the K4-B parity golden proves it via DeepEqual against the OLD host-compile path).
func PortMapFromMappings ¶ added in v0.2026198.358
PortMapFromMappings builds a {containerPort -> hostPort} lookup table from the resolved port mapping list. Mappings that don't parse are silently skipped (the loud-skip warning lives in kit.CheckPortAvailability).
func PreemptEffectiveRestore ¶ added in v0.2026190.848
func PreemptEffectiveRestore(p *PreemptibleConfig) string
EffectiveRestore returns the configured restore policy with the default.
func PreemptEffectiveStop ¶ added in v0.2026190.848
func PreemptEffectiveStop(p *PreemptibleConfig) string
EffectiveStop returns the configured stop mechanism with the default.
func PrimaryDistroTag ¶ added in v0.2026190.848
func PrimaryDistroTag(img *ResolvedBox, hostCtx HostContext) string
PrimaryDistroTag picks the distro tag this plan is materialized against. img.Distro is the AUTHORITATIVE deploy-target distro chain and always wins: syntheticHostBox sets the operator host's tags, syntheticVmBox the GUEST's, and ResolveBox the image's — so a vm deploy resolves the guest distro, a host deploy the operator's, a pod/image deploy the image's. For a host deploy img.Distro[0] == hostCtx.Distro (both from DetectHostDistro; PrimaryTag() == Tags[0]), so this is byte-identical to the old host path while fixing vm deploys (whose hostCtx.Distro is the OPERATOR's distro, NOT the guest's — the detectHostContext default). hostCtx.Distro is only a fallback when img carries no distro. (Package resolution already uses img via CompileSystemPackageSteps, so making the plan's distro img-authoritative also removes a latent inconsistency, never introduces one.)
func ProvisionData ¶ added in v0.2026198.345
func ProvisionData(engine string, imageRef string, meta *spec.BoxMetadata, bindMounts []ResolvedBindMount, namedVolumes []spec.VolumeMount, deployName, instance string, mode DataProvisionMode) (int, error)
ProvisionData copies data from image staging (/data/) into the runtime volumes — both bind-mounted host directories AND podman named volumes. It matches data entries from image metadata against the resolved volume list by bare volume name.
Volume kind determines the seeding command: bind mounts use the host path as the -v source with --userns=keep-id, named volumes use the full volume name as the -v source WITHOUT keep-id (the rootless subuid mapping handles ownership for named volumes).
For data images (FROM scratch, no shell), named-volume targets use podman's --mount type=image to expose the staging filesystem and a lightweight helper image (busybox) to run cp. Bind-mount targets use the simpler podman create + podman cp path.
func QuadletDir ¶ added in v0.2026198.345
QuadletDir returns the user-level quadlet directory.
func QuadletExists ¶ added in v0.2026198.345
QuadletExists checks whether a .container file exists for the given image.
func QuadletExistsInstance ¶ added in v0.2026198.345
QuadletExistsInstance checks whether a .container file exists for the given image/instance.
func QuadletFilename ¶ added in v0.2026198.345
QuadletFilename returns the quadlet filename for an image.
func QuadletFilenameInstance ¶ added in v0.2026198.345
QuadletFilenameInstance returns the quadlet filename for an image with optional instance.
func RegisterDeployStateHost ¶ added in v0.2026196.928
func RegisterDeployStateHost(h *StateHostMechanisms)
RegisterDeployStateHost is the charly init hook (called once from package main at startup).
func RejectImageRefAsDeployName ¶ added in v0.2026190.848
RejectImageRefAsDeployName fails a deploy-CREATION command (config setup / start) whose positional is a tagged registry image ref used AS the deploy NAME. The ref's registry-host dots make an invalid charly.yml deploy key (dots are reserved for dotted-path addressing), so the deploy would save and the NEXT config load would hard-fail (the 2026-07 `charly config ghcr.io/…:tag` corruption). A registry image needs an explicit short deploy name. Gated on BOTH a dot (invalid key) AND an image `:tag` (so a github repo ref, which pins with @version, and a bare dotted-path address are untouched).
func RelativeCandySequence ¶ added in v0.2026193.1801
func RelativeCandySequence(boxName string, parentProvided map[string]bool, boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel, globalOrder []string, pixiBound map[string]bool) []string
RelativeCandySequence returns an image's candies minus what the parent provides, ordered according to the global candy order.
func RemoveBoxDeploy ¶ added in v0.2026193.1222
func RemoveBoxDeploy(dc *BundleConfig, boxName string)
RemoveBoxDeploy removes an image's entry from a deploy config.
func RemoveByExactSource ¶ added in v0.2026196.928
RemoveByExactSource removes entries whose source matches the exact deploy key (no cross-instance match). Relocated from charly/provides.go.
func RemoveBySource ¶ added in v0.2026196.928
RemoveBySource removes all entries injected by the given image (same base, any instance). Returns the filtered list and whether anything was removed. Relocated from charly/provides.go.
func RenderDnfConfWrite ¶ added in v0.2026192.1709
RenderDnfConfWrite renders the dnf download-tuning conf snippet (appended to /etc/dnf/dnf.conf before the bootstrap install). Relocated from charly (P8).
func ResolveBoxEngineForDeploy ¶ added in v0.2026198.345
ResolveBoxEngineForDeploy resolves the run engine from the per-host deploy config, falling back to globalEngine. No charly.yml (project) dependency.
func ResolveBoxEngineFromMeta ¶ added in v0.2026198.345
func ResolveBoxEngineFromMeta(meta *spec.BoxMetadata, globalEngine string) string
ResolveBoxEngineFromMeta returns the engine from image metadata labels, falling back to globalEngine if not set.
func ResolveBoxLevels ¶ added in v0.2026192.1709
func ResolveBoxLevels(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([][]string, error)
ResolveBoxLevels resolves box dependencies and returns them grouped by build level. Boxes at the same level can be built concurrently.
func ResolveBoxOrder ¶ added in v0.2026192.1709
func ResolveBoxOrder(boxes map[string]*buildkit.ResolvedBox, layers map[string]CandyModel) ([]string, error)
ResolveBoxOrder resolves box dependencies and returns them in build order. Boxes that reference other boxes via `base` create dependencies. Each box's Builder field determines its builder dependency. Pass candies to enable conditional builder dependency; nil for unconditional.
func ResolveCandyOrder ¶ added in v0.2026192.1709
func ResolveCandyOrder(requested []string, layers map[string]CandyModel, parentCandies map[string]bool) ([]string, error)
ResolveCandyOrder resolves candy dependencies and returns them in topological order. It takes the explicitly requested candies and the full candy map, then: 1. Expands candy composition (candy: field) 2. Transitively resolves all dependencies 3. Topologically sorts the result 4. Returns candies in install order (dependencies before dependents)
parentCandies contains candies already installed by parent boxes (via base chain). These are excluded from the returned order.
func ResolveCascadePackages ¶ added in v0.2026190.848
func ResolveCascadePackages(layer CandyModel, img *ResolvedBox) (pkgs []string, raw map[string]any, matched bool)
func ResolveContainer ¶ added in v0.2026198.345
ResolveContainer resolves engine + container name, verifying the container is running. Use "." as image name for local mode (returns empty engine and name).
func ResolveDeployBoxName ¶ added in v0.2026198.345
func ResolveDeployBoxName(key, instance string, rp *spec.ResolvedProject) string
ResolveDeployBoxName is THE deploy-key→image-name resolver for a caller holding a *spec.ResolvedProject (rp may be nil — the project-level fallback is then skipped). Mirrors charly/deploy.go's resolveDeployBoxName precedence: the per-host deploy-config overlay (LoadDeployConfigForRead) wins, then rp.Deploy[key].Image, then the bare key.
func ResolveDeployChain ¶ added in v0.2026190.848
func ResolveDeployChain(roots map[string]BundleNode, dotted string, root DeployExecutor) (*BundleNode, DeployExecutor, error)
ResolveDeployChain walks `dotted` through `roots` (typically the merged deployment tree from resolveTreeRoot) and returns the leaf BundleNode + a composed DeployExecutor chain that reaches it from `root`.
`root` is typically &ShellExecutor{} (the operator's host, or the harness-sandbox context the harness loop runs in). Pass nil to substitute ShellExecutor.
For each path segment, a single hop is added based on the node's target classification:
target: pod / container → NestedExecutor with JumpPodmanExec /
JumpDockerExec into "charly-<flat-path>".
Container name flattens dot-separated
paths to underscore-separated to remain
a legal podman container name.
target: vm → plain SSHExecutor when the parent chain
is local (no wrapper overhead), otherwise
NestedExecutor with JumpSSH on top.
target: host → no hop (host nodes share the parent
venue).
target: k8s → error (k8s manifests are leaves; not
traversable as exec targets).
Returns clear errors with available-name hints when a segment fails to resolve.
func ResolveHome ¶ added in v0.2026190.848
func ResolveHome(p *spec.InstallPlan, home string)
ResolveHome substitutes the deferred HomeToken with a concrete home in every home-bearing step field, in place. Each DeployTarget calls this once at emit time with the home of its real destination: img.Home for the OCI/pod-overlay build, the host home for the external local deploy, the GUEST home (SSH executor ResolveHome) for the external vm deploy. Idempotent — fields without the token are left untouched, so a second call is a no-op.
Covered fields: ShellHookStep env values + PathAdd, ShellSnippetStep Snippet + Destination + PathAppend, FileStep.Dest. OpStep cmd/content bodies are intentionally NOT touched — `~`/`$HOME` there shell-expand at runtime on the destination as the deploy user, which is already correct on every venue. BuilderStep is also untouched — its home is resolved separately by renderBuilderScript against the builder/guest home (see execBuilder).
A free function (not a method on spec.InstallPlan) because it type-switches the concrete step vocabulary, which lives in deploykit.
func ResolveNodePath ¶ added in v0.2026190.848
func ResolveNodePath(roots map[string]BundleNode, path string) (*BundleNode, []*BundleNode, error)
ResolveNodePath walks roots[path0].Children[path1]...[pathN] and returns the targeted node plus its parent chain (root-first, excluding the target itself). Returns a descriptive error when any path segment is missing so the user sees which segment doesn't exist.
An empty path is invalid — callers dispatch to WalkPreOrder/WalkPostOrder against a named root instead of resolving "".
func ResolveSidecarContainer ¶ added in v0.2026198.345
ResolveSidecarContainer resolves engine + container name for a named sidecar, verifying it is running.
func ResolveTemplate ¶ added in v0.2026198.358
ResolveTemplate replaces template placeholders in a string:
{{.ContainerName}} -> containerName
{{.ContainerPort <N>}} -> <N> (literal — kept for symmetry/readability)
{{.HostPort <N>}} -> host port mapped to container port <N>
(looked up in portMap; falls back to <N>
if not found — caller should validate the
port is actually published before relying
on the substitution)
portMap is a {containerPort -> hostPort} table built from the resolved port mapping list at env-injection time. nil portMap is accepted (every {{.HostPort N}} degrades to the literal container port — useful for validation-time substitution before runtime data is available).
func ResolveUserSpec ¶ added in v0.2026192.1709
func ResolveUserSpec(userField string, img *buildkit.ResolvedBox) (directive, chown string)
ResolveUserSpec converts a task's `user:` field to (userDirective, chownPair).
func ResolveVolumeBacking ¶ added in v0.2026194.615
func ResolveVolumeBacking(boxName, instance string, labelVolumes []VolumeMount, deployVolumes []vmshared.DeployVolumeConfig, home string, encStoragePath string, volumesPath string) ([]VolumeMount, []ResolvedBindMount)
ResolveVolumeBacking splits image volumes into named volumes and bind mounts based on the deploy's charly.yml volume configuration. Volumes without a deploy override stay named volumes; a type=bind/encrypted override becomes a ResolvedBindMount; deploy-only volumes (carrying Path, absent from any label) are added as binds. PURE — the host resolves labelVolumes (ExtractMetadata) + deployVolumes (charly.yml) and calls this in the config-resolve seam; the pod plugin consumes the result.
func ResolveWorkingDir ¶ added in v0.2026194.615
func ResolveWorkingDir(volumes []VolumeMount, bindMounts []ResolvedBindMount, home, boxName, instance string) string
ResolveWorkingDir returns the container working directory — the "workspace" volume/bind's container path if declared, else home.
func ResourceCapArgs ¶ added in v0.2026198.345
func ResourceCapArgs(sec spec.SecurityConfig) []string
ResourceCapArgs returns the podman run flags for memory and CPU caps. Emitted identically in both the privileged and non-privileged branches of SecurityArgs because privileged containers still need resource limits.
func SaveBundleConfig ¶ added in v0.2026196.928
func SaveBundleConfig(dc *BundleConfig, marshalNode func(name string, node *BundleNode) (*yaml.Node, error)) error
SaveBundleConfig writes a BundleConfig to the standard charly.yml path. The kind-blind file shell: the HEAD version stamp (kit.LatestSchemaVersion), the provides directive, the caller-supplied per-entry node-form bodies, and the atomic tempfile+os.Rename write with a fail-safe re-check. The deploy-kind-specific marshal (the struct-body → compact node-form transform) is the caller's responsibility — supplied via marshalNode, which returns the MIGRATED node-form body for one BundleNode (the value placed under the entry's name key). This keeps SaveBundleConfig kind-blind: no per-kind map, no target-vocabulary switch, no deploy-kind-specific struct knowledge. Relocated from charly/deploy.go (K5-Unit-1); the LoadUnified hop (the fail-safe re-check) reaches core through DeployStateHost.
func SaveDeployState ¶ added in v0.2026196.928
func SaveDeployState(boxName, instance string, input SaveDeployStateInput, marshalNode func(name string, node *BundleNode) (*yaml.Node, error))
SaveDeployState persists deployment parameters to charly.yml (best-effort). Merges onto any existing entry to preserve fields from charly bundle import. Relocated from charly/deploy.go (K5-Unit-1); the process-shared flock is a kind-blind kit primitive (kit.AcquireFileLock on the deploy-config path) and the loader reaches core through the DeployStateHost seam (LoadUnifiedBundleConfig). marshalNode is the deploy-kind-specific node-form serializer the caller supplies (the callback SaveBundleConfig invokes per entry).
func SchemeTarget ¶ added in v0.2026194.615
SchemeTarget returns the backend URL for a tunnel scheme + port.
func ScopeVolumesToDeployKey ¶ added in v0.2026196.928
func ScopeVolumesToDeployKey(meta *spec.BoxMetadata, deployName, instance string)
ScopeVolumesToDeployKey renames meta's named-volume mounts from the image-derived prefix (charly-<image>-) to the deploy's own prefix (DeployVolumePrefix), so every distinctly-named deploy ALWAYS gets volume mounts distinct from any other deploy of the same image. No-op when the deploy's prefix already equals the image prefix (the common `charly config <image>` base deploy). Idempotent. Relocated from charly/deploy.go (reads *spec.BoxMetadata, no core dep — folds cleanly into the kit).
func SecretDeclaredOnBox ¶ added in v0.2026198.358
func SecretDeclaredOnBox(meta *spec.BoxMetadata) map[string]bool
SecretDeclaredOnBox returns the set of env var names an image declares as credential-backed (secret_accepts or secret_requires). Returns a non-nil empty set when meta is nil or has no secret declarations.
func SecretDepNames ¶ added in v0.2026198.358
func SecretDepNames(meta *spec.BoxMetadata) []string
SecretDepNames returns the flat list of env var names declared as credential-backed on an image. Used to populate deploykit.SaveDeployStateInput.SecretNames for the defense-in-depth scrub in saveDeployState. Returns nil (not an empty slice) when meta has no secret declarations — matches the rest of the omitempty-style API.
func SecretKeyForDep ¶ added in v0.2026198.358
func SecretKeyForDep(dep spec.EnvDependency) (service, key string)
SecretKeyForDep returns the (service, key) tuple used to look up a secret in the credential store. When the candy author set an explicit `key: charly/api-key/openrouter` override, that's parsed into its two segments; otherwise the default (charly/secret, dep.Name) is returned. The format is enforced by validateSecretDeps at build time, so this is purely a structural split — no validation is re-run here.
func SecurityArgs ¶ added in v0.2026198.345
func SecurityArgs(sec spec.SecurityConfig) []string
SecurityArgs returns the container run arguments for the given security config.
Note on the ShmSize+IpcMode interaction: podman rejects `--shm-size` when the IPC namespace is shared with the host (`--ipc=host`) because the host's /dev/shm is shared in-kernel and sized by the host kernel; an explicit shm-size on the container makes no sense in that case and yields a runtime error like "cannot set shmsize when running in the {host} IPC Namespace". Same logic applies to the quadlet generator's ShmSize= directive elsewhere.
func ServiceEntryAppliesToDistro ¶ added in v0.2026190.848
func ServiceEntryAppliesToDistro(entry *ServiceEntry, distros []string) bool
ServiceEntryAppliesToDistro reports whether a service entry should render for the given distro tag chain. An entry with an EMPTY distro: list applies to EVERY distro (the backward-compatible default — every pre-existing candy's services keep rendering everywhere). A non-empty list restricts the entry to the named distros, matched against either a bare distro name ("debian") or a full versioned tag ("debian:13") anywhere in the chain. This is the service analogue of a check step's exclude_distros: — the mechanism that lets ONE candy carry per-distro-divergent packaged units (modular virtqemud.socket on Fedora/Arch vs monolithic libvirtd.socket on Debian/Ubuntu) without a <name>-host sibling candy (CLAUDE.md R3).
func ServiceName ¶ added in v0.2026198.345
ServiceName returns the systemd service name for an image.
func ServiceNameInstance ¶ added in v0.2026198.345
ServiceNameInstance returns the systemd service name for an image with optional instance.
func ServiceRenderDistros ¶ added in v0.2026190.848
func ServiceRenderDistros(img *ResolvedBox, hostCtx HostContext) []string
compileServiceSteps turns the candy's service declarations into IR steps. Preference order:
- Unified `services:` list (Task 6) — preferred when present. Each entry becomes either a ServicePackagedStep (use_packaged:) or a ServiceCustomStep (full spec).
compileServiceSteps — unified schema only. Each ServiceEntry becomes either a ServicePackagedStep (use_packaged:) or a ServiceCustomStep (custom exec). Legacy fields (raw-INI service:, system_services:) are gone — external candies must run `charly migrate`.
**Init-system polymorphism filter (2026-05).** When a candy declares the same service `name:` twice — once with `use_packaged:` and once with custom `exec:` (the mixed-entry polymorphism pattern documented in CLAUDE.md "Init-system polymorphism via mixed `service:` entries" and `/charly-build:layer` "Service Declaration") — the compiler picks ONE based on the target's init system:
- systemd target (host / vm) → emit the packaged form, SKIP the custom-exec sibling (the packaged unit handles the daemon).
- supervisord target (oci/pod build) → SKIP the packaged form (supervisord can't consume systemd units), emit the custom form.
For singleton entries (no mixed pair), each entry renders as-is on the matching init system; mismatched singletons (e.g. a lone `use_packaged:` entry on a supervisord target) are silently skipped.
For systemd targets, the compiler ALSO pre-populates UnitText/UnitPath on the ServiceCustomStep by calling RenderService, so executors don't need a runtime lazy-render step. This consolidates what used to live in three different places (the deleted in-proc VM-target lazy fallback, the OCI build's per-entry routing, and the legacy nothing-rendered path on the local deploy target) into ONE compile-time filter. ServiceRenderDistros returns the distro tag chain a service entry's distro: filter is matched against for a deploy target. img.Distro is the AUTHORITATIVE deploy-target chain and always wins (mirrors PrimaryDistroTag): syntheticVmBox sets the GUEST chain (e.g. ["debian:13","debian"]), syntheticHostBox the operator host's, ResolveBox the image's. Using hostCtx.Distro here was the bug that made a vm deploy filter services against the OPERATOR's distro (arch) instead of the guest's (debian) — detectHostContext defaults hostCtx.MachineVenue=true + the operator distro even for a vm deploy, so a hostCtx-wins rule mis-scoped every vm/pod service. For a host deploy img.Distro is the operator's own tag chain (a SUPERSET of the single PrimaryTag, so arch-derivative hosts like cachyos now also match `arch:` entries). hostCtx.Distro is only a fallback when img carries no distro.
func SidecarTemplatesOf ¶ added in v0.2026198.358
func SidecarTemplatesOf(dc *BundleConfig) map[string]json.RawMessage
SidecarTemplatesOf returns the project-root sidecar templates carried by a deploy config (nil-safe), as OPAQUE bodies. These extend/override the embedded set inside the sidecar plugin's OpResolve.
func SortByPopularity ¶ added in v0.2026193.1801
SortByPopularity sorts by descending popularity, then lexicographic ascending.
func SortedEnvList ¶ added in v0.2026198.254
SortedEnvList returns env as a deterministically-ordered []spec.KeyValue (template iteration order — a Go map has none of its own).
func SortedKeys ¶ added in v0.2026193.1801
SortedKeys returns sorted keys from a trie-node map.
func SortedNestedKeys ¶ added in v0.2026190.848
func SortedNestedKeys(children map[string]*BundleNode) []string
func SplitDottedPath ¶ added in v0.2026190.848
SplitDottedPath splits a dotted deployment path into segments. An empty input or a path with any empty segment (leading/trailing/ doubled dots) yields nil so callers can flag the error at their layer with the original offending path string.
func StageInlineContent ¶ added in v0.2026192.1709
StageInlineContent writes a write-task's inline content to <buildDir>/_inline/<candy>/<sha256> on disk and returns the build-context-relative path suitable for COPY. Writes are idempotent — repeated calls with identical content are no-ops via content-addressed filenames. Relocated from charly (P8).
func StepToView ¶ added in v0.2026190.848
func StepToView(step InstallStep) spec.InstallStepView
StepToView projects one concrete InstallStep onto its serializable wire view.
func StepsToView ¶ added in v0.2026190.848
func StepsToView(steps []InstallStep) []spec.InstallStepView
StepsToView / stepsFromView convert a whole ordered slice. Order is preserved (the InstallPlan's step ordering is load-bearing — see ResolveHome / StepsByVenue).
func StringSliceFromYAML ¶ added in v0.2026190.848
StringSliceFromYAML coerces a YAML-decoded value into []string. The decoder produces []interface{} for sequences; we tolerate already- stringified slices for callers that pre-process.
func StripSecretEnvNames ¶ added in v0.2026190.848
StripSecretEnvNames removes any KEY=VAL entries from env whose KEY is in the blocked list. The blocked list is expected to be short (one entry per secret_* declaration on the image), so a per-entry delete is fine.
func StripVersion ¶ added in v0.2026190.848
StripVersion splits an @-prefixed ref into its bare form and pinned version. A non-@ ref returns (ref, "").
func SystemdUserDir ¶ added in v0.2026198.345
SystemdUserDir returns the user-level systemd unit directory (~/.config/systemd/user/).
func TailscaleFlag ¶ added in v0.2026194.615
TailscaleFlag returns the tailscale serve/funnel flag for a scheme.
func TaskCacheMounts ¶ added in v0.2026192.1709
func TaskCacheMounts(t vmshared.Op, img *buildkit.ResolvedBox) []string
TaskCacheMounts renders a task's candy-declared `cache:` paths as BuildKit cache-mount flags. Ownership follows the task's user (root → shared, non-root → uid/gid-owned).
func TaskCoalescesWith ¶ added in v0.2026192.1709
TaskCoalescesWith returns true if next can be batched with current under the adjacent-coalescing rule: same verb, same user, both verbs support batching.
func TaskKnownNames ¶ added in v0.2026192.1709
TaskKnownNames returns the ${NAME} references that resolve cleanly for this candy: auto-exports ∪ candy.Vars keys.
func TaskSubstAutoExports ¶ added in v0.2026192.1709
func TaskSubstAutoExports(s string, img *buildkit.ResolvedBox) string
TaskSubstAutoExports substitutes the image-level auto-exports (USER/UID/GID/HOME) in s. ARCH/BUILD_ARCH are NOT substituted here.
func TaskSubstPath ¶ added in v0.2026192.1709
func TaskSubstPath(p string, img *buildkit.ResolvedBox) string
TaskSubstPath resolves a destination/path field: auto-export substitution plus leading ~/ expansion to the resolved HOME.
func TaskUnresolvedRefs ¶ added in v0.2026192.1709
TaskUnresolvedRefs returns the names of ${VAR} references in s not in known.
func TopoSortByPopularity ¶ added in v0.2026193.1801
TopoSortByPopularity performs topological sort with popularity tie-breaking. Higher popularity candies come first among zero-in-degree candidates.
func TunnelServiceFilename ¶ added in v0.2026194.615
TunnelServiceFilename returns the systemd service filename for a cloudflare tunnel companion unit.
func UpdateBoxBase ¶ added in v0.2026193.1801
func UpdateBoxBase(imgName, parentName string, result map[string]*buildkit.ResolvedBox)
UpdateBoxBase updates an image's Base to point to the given parent.
func ValidateProvidesTemplate ¶ added in v0.2026198.358
ValidateProvidesTemplate checks that only known placeholders are present. Allowed:
{{.ContainerName}}
{{.ContainerPort <N>}} N must parse as a positive integer
{{.HostPort <N>}} N must parse as a positive integer
func WalkDeploymentTree ¶ added in v0.2026190.848
func WalkDeploymentTree(rootPath string, root *BundleNode, parentExec DeployExecutor, visit DeployTreeVisitor) error
WalkDeploymentTree performs a pre-order walk rooted at the given node, calling visit on each node. Dotted-path accumulation is handled internally: the root's `rootPath` argument seeds the identifier; children are rendered as `<parent>.<childKey>`.
Errors short-circuit: as soon as any visit call returns a non-nil error, the walk stops and that error propagates.
func WireView ¶ added in v0.2026190.848
func WireView(p *spec.InstallPlan) spec.InstallPlanView
WireView projects the rich in-core spec.InstallPlan onto the JSON-roundtrippable spec.InstallPlanView the host marshals into an external deploy/step provider's op.Params. The Steps interface slice round-trips through the SINGLE StepsToView / stepsFromView converter (step_view.go) — an external deploy/step plugin walks the same ordered step IR the in-proc DeployTargets walk and EXECUTES it on the venue (R3; proven by the step-IR round-trip test). The remaining fields are identity + provenance.
A free function (not a method on spec.InstallPlan) because it type-switches the concrete step vocabulary via StepsToView — that lives in deploykit, so spec never imports deploykit.
Types ¶
type ApkInstallStep ¶
type ApkInstallStep struct {
Packages []ApkPackageSpec
CandyName string
CandyDir string // candy source dir — anchors relative committed-APK paths
}
ApkInstallStep installs Android apps onto a `kind: android` device. It is the IR form of a candy's `apk:` package section — the apk "package format" (parallel to SystemPackagesStep for rpm/deb/pac, and BuilderStep for aur).
Unlike every other step, an apk install lands on a RUNNING Android device, not the build/host filesystem. `target: android` is an EXTERNAL deploy substrate (F1): NO in-proc DeployTarget executes this step — the host-side android deploy preresolver (collectAndroidInstalls, android_deploy_preresolve.go) READS it to collect the apk install specs and ships them to the deploy:android plugin (candy/plugin-adb: apkeep + adb), which drives the device. Every DeployTarget SKIPS it — OCITarget emits nothing (no device at image-build time), and Local/Vm/Pod targets record a skip (a host/VM/pod is not an Android device). This is the same "wrong venue → skip" shape `aur:` uses off-Arch, expressed as a clean recorded skip rather than an error (an image legitimately builds without installing apps).
func (*ApkInstallStep) Kind ¶
func (s *ApkInstallStep) Kind() StepKind
func (*ApkInstallStep) RequiresGate ¶
func (s *ApkInstallStep) RequiresGate() Gate
func (*ApkInstallStep) Reverse ¶
func (s *ApkInstallStep) Reverse() []ReverseOp
Reverse returns no STATIC ledger ops — Android teardown ops are DYNAMIC, recorded from the deploy:android plugin's OpExecute reply (the uninstall reverse ops) at deploy time, replayed at `charly bundle del` like any external deploy substrate.
func (*ApkInstallStep) Scope ¶
func (s *ApkInstallStep) Scope() Scope
Scope is system — installing an app mutates device-global package state.
func (*ApkInstallStep) Venue ¶
func (s *ApkInstallStep) Venue() Venue
Venue is host-native — the android deploy preresolver reads this step from the host (the install itself runs in the deploy:android plugin over the wire).
type ApkPackageSpec ¶
type ApkPackageSpec = spec.ApkPackageSpec
type ArtifactRef ¶
type ArtifactRef struct {
ContainerPath string // path inside the builder stage/container
HostPath string // path on the deploy target (host fs or final-image fs)
Chown bool // whether to re-own to the target user
}
ArtifactRef describes an output path from a builder that needs to be extracted back to the host or copied into the final OCI image.
For user-scope pixi/npm/cargo on the host target: the host path is bind-mounted into the builder, so there's no "extraction" — the Artifacts list is empty because the bind-mount already put the files in place. For aur: the list contains /tmp/aur-pkgs/*.pkg.tar.zst, which the host target pulls out to a staging dir then hands to pacman.
type BuilderDef ¶
type BuilderDef = spec.BuilderDef
type BuilderPreresolved ¶ added in v0.2026190.848
BuilderPreresolved is one candy×builder's pre-resolved payload. The Candy-coupled functions that BUILD it stay in charly; the compiler only reads it.
type BuilderRunOpts ¶ added in v0.2026190.848
type BuilderRunOpts = spec.BuilderRunOpts
type BuilderStep ¶
type BuilderStep struct {
Builder string // "pixi" | "npm" | "cargo" | "aur"
BuilderImage string // resolved image ref (e.g. "fedora-builder:2026.04")
CandyName string // layer that triggered this builder (for ledger)
CandyDir string // absolute layer source path (bind-mounted as /work)
Phase Phase // typically PhaseInstall
Artifacts []ArtifactRef // outputs to extract (empty for user-scope pixi/npm/cargo; populated for aur)
// Builder-specific template context — the compiler populates this from
// the candy's manifest files + the embedded builder definition (charly/charly.yml).
RawStageContext map[string]any
// LocalPkg is the package format's localpkg contract, populated by the
// compiler for the `aur` builder only. The aur builder produces package
// files (.pkg.tar.zst) that the host/VM deploy targets install onto the
// venue via the SAME config-driven transfer+install leg the localpkg step
// uses (R3) — so the install command + package glob come from
// the embedded `pac.local_pkg` vocabulary, never a hardcoded literal. Nil for
// pixi/npm/cargo (home-artifact builders, no package-file install).
LocalPkg *LocalPkgDef
// BuilderDef is the resolved builder definition from the embedded build vocabulary (charly/charly.yml) for this builder
// (img.BuilderConfig.Builder[Builder]), populated by the compiler. The
// host-venue deploy targets render its phase.install.host cell via
// renderBuilderScript — the plain-shell analog of the container stage — so the
// host build script is config-driven, not hardcoded Go. nil only on
// synthetic test paths that don't supply a BuilderConfig.
BuilderDef *BuilderDef
// PreResolvedReverse is the builder's teardown ops, resolved HOST-SIDE in the build
// PRE-PASS (builder_preresolve.go → the externalized builder plugin's OpReverse) and stashed
// here so Reverse() is a PURE getter — the per-builder reverse-op KIND (pixi-env-remove /
// package-remove / …) is exactly the logic externalized out-of-process, and Reverse() runs
// host-side (step-view projection + RunHostStep) with no registry handle. Carried across the
// wire on InstallStepView.ReverseOps (the host-computed teardown field) and restored by
// stepFromView. Nil for a custom candy builder / a direct compile with no pre-pass.
PreResolvedReverse []ReverseOp
}
BuilderStep runs a multi-stage builder (pixi/npm/cargo/aur). On the OCI target this emits a FROM + RUN stage plus a final-stage COPY --from. On the host target this emits a `podman run <builder>` with HOME-remap and appropriate bind-mounts.
func (*BuilderStep) Kind ¶
func (s *BuilderStep) Kind() StepKind
func (*BuilderStep) RequiresGate ¶
func (s *BuilderStep) RequiresGate() Gate
func (*BuilderStep) Reverse ¶
func (s *BuilderStep) Reverse() []ReverseOp
func (*BuilderStep) Scope ¶
func (s *BuilderStep) Scope() Scope
func (*BuilderStep) Venue ¶
func (s *BuilderStep) Venue() Venue
type BundleConfig ¶ added in v0.2026190.848
type BundleConfig struct {
Provides *ProvidesConfig `yaml:"provides,omitempty" json:"provides,omitempty"`
Bundle map[string]BundleNode `yaml:"deploy" json:"deploy"`
// Sidecar carries the project's sidecar-template library as OPAQUE bodies
// (the raw PluginKinds["sidecar"] map). candy/plugin-sidecar's OpResolve merges
// these UNDER each deploy node's own overrides; the kernel reads no fields
// (the sidecar de-type, Cutover D).
Sidecar map[string]json.RawMessage `yaml:"sidecar,omitempty" json:"sidecar,omitempty"`
}
--- BundleConfig state container (moved from charly/deploy.go, P4) --- BundleConfig represents per-machine deployment overrides (~/.config/charly/charly.yml). Only runtime/deployment fields are supported — build-time fields are structurally excluded.
Schema v4: the top-level map key is `deployment:` (singular, flat). The legacy `images:` / `deployments.images.*` nesting is gone — all target kinds (host / vm / pod / k8s) live under the single `deployment:` map.
func ExportAllBox ¶ added in v0.2026196.928
func ExportAllBox(rp *spec.ResolvedProject) *BundleConfig
ExportAllBox exports all runtime-relevant fields for all enabled boxes in a RESOLVED project envelope. Relocated from charly/deploy.go (K5-Unit-1, the #67 keystone): the former `ExportAllBox(cfg *Config)` read the live *Config graph; this rewrite reads the spec.ResolvedProject envelope the "resolved-project" HostBuild seam (K5-Unit-0) produces, so the deploy state model is built from the SAME envelope inspect/list/validate consume — no core *Config dep. The box-authored deploy-overlay surfaces (description / env / env_file / security / network) ride #ResolvedBoxView (grown in this cutover); version is the box's EffectiveVersion (the stable content-derived CalVer), matching the prior behaviour's `img.Version`.
func LoadBundleConfig ¶ added in v0.2026196.928
func LoadBundleConfig() (*BundleConfig, error)
LoadBundleConfig reads the per-host deploy overlay (~/.config/charly/charly.yml) through the unified loader — the SAME LoadUnified path as every project charly.yml. Returns nil, nil if the file doesn't exist. Relocated from charly/deploy.go (K5-Unit-1); the LoadUnified hop reaches core through DeployStateHost.LoadUnifiedBundleConfig.
Every transform the old bespoke parser did — the `images:` legacy-key reject, the deployment-tree / required-box: / preemptible / ephemeral-naming validation, and the ephemeral→disposable auto-promotion — runs INSIDE LoadUnified (its version gate + the deploy-validation block subsume the legacy check; the ephemeral/naming validators + promotion were consolidated there so a PROJECT charly.yml's inline deploy: entries get them too — R3, one path).
func LoadDeployConfigForRead ¶ added in v0.2026196.928
func LoadDeployConfigForRead(context string) *BundleConfig
LoadDeployConfigForRead loads charly.yml for read-only consumption. Unlike the historical `dc, _ := LoadBundleConfig()` pattern (silently discards validation errors → caller proceeds with nil → feature degrades invisibly), this helper SURFACES the load error as a stderr warning while still returning nil — preserving the existing caller nil-check contract but giving the operator visibility into why a command behaved as if charly.yml were absent. Relocated from charly/deploy.go (K5-Unit-1).
context is a short human-readable label included in the warning message so the operator can trace which code path noticed the problem (e.g. "charly status", "config injectEnvProvides").
func LoadDeployConfigForWrite ¶ added in v0.2026196.928
func LoadDeployConfigForWrite(context string) (*BundleConfig, error)
LoadDeployConfigForWrite loads charly.yml for mutation. Unlike the historical `dc, _ := LoadBundleConfig()` pattern (silently discards validation errors → writer constructs an empty config → SaveBundleConfig truncates the file), this helper PROPAGATES the load error so writers can ABORT instead of destroying data. Relocated from charly/deploy.go (K5-Unit-1).
context is a short human-readable label included in the error message (e.g. "saveDeployState"). Returns (nil, error) when the file exists but failed parse/validation; (fresh empty config, nil) when the file doesn't exist; (parsed config, nil) on clean load.
func LoadDeployFile ¶ added in v0.2026193.1222
func LoadDeployFile(path string) (*BundleConfig, error)
LoadDeployFile reads a charly.yml from an arbitrary path into a BundleConfig.
func MergeDeployConfigs ¶ added in v0.2026190.848
func MergeDeployConfigs(configs ...*BundleConfig) *BundleConfig
MergeDeployConfigs merges multiple DeployConfigs left-to-right. Later configs take precedence (field-level replace per image). The merge walks every yaml-tagged field of BundleNode via reflect: a field copies from src → dst when src's value is non-zero (string != "", slice/map/ptr not nil, bool != false, numeric != 0). This makes adding a new field to BundleNode automatically merge-correct — the pre-2026-05 hand-rolled per-field merge silently dropped 19+ fields (ResolvedPort, Description, Secret, Sidecar, Shell, Kubernetes, ForwardGpgAgent, ForwardSshAgent, Kind, Replica, Restart, Schedule, Resources, Expose, Storage, Probes, Cpus, Ram, DiskSize) whenever any merge → save cycle ran.
The yaml tag `-` (currently only BundleNode.Inside, a derived runtime field) skips the merge. Untagged fields are also skipped.
func (*BundleConfig) DeployedContainerNames ¶ added in v0.2026190.848
func (dc *BundleConfig) DeployedContainerNames() []string
DeployedContainerNames returns the sorted, de-duplicated container names for every bundle entry.
func (*BundleConfig) GlobalEnvForImage ¶ added in v0.2026190.848
func (dc *BundleConfig) GlobalEnvForImage(consumerKey, ctrName string, acceptedEnv map[string]bool) []string
GlobalEnvForImage builds the env-var injection list for a consumer container from the deploy state's env + MCP provides, filtered by the consumer's accepts.
func (*BundleConfig) Lookup ¶ added in v0.2026190.848
func (dc *BundleConfig) Lookup(deployName, instance string) (BundleNode, bool)
Lookup returns the BundleNode for (deployName, instance), or (zero, false) when the entry is absent. Safe to call on a nil *BundleConfig — lets callers chain `loadDeployConfigForRead(...).Lookup(deployName, instance)` without a separate nil check. deployName is the charly.yml key base the caller is operating on (typically c.Image), NOT the baked image short-name — for a kind:check bed or Pattern-B deploy the two differ. Pass the deploy key, never a value derived from an image label (see MergeDeployOntoMetadata).
func (*BundleConfig) LookupKey ¶ added in v0.2026190.848
func (dc *BundleConfig) LookupKey(key string) (BundleNode, bool)
LookupKey looks up a deploy entry by its full charly.yml key (e.g. "foo", "foo/instance", "vm:name"). Safe on nil receiver.
func (*BundleConfig) OccupiedHostPorts ¶ added in v0.2026190.848
func (dc *BundleConfig) OccupiedHostPorts(excludeKey string) map[int]bool
OccupiedHostPorts returns the set of host ports already claimed by bundle entries other than excludeKey (resolved pins preferred over authored).
type BundleNode ¶ added in v0.2026190.848
type BundleNode = spec.BundleNode
func FindVmDeployNode ¶ added in v0.2026190.848
func FindVmDeployNode(deploys map[string]BundleNode, name, vmName string) (BundleNode, bool)
FindVmDeployNode finds the BundleNode for a vm-target deploy. It is THE shared "which deploy entry backs this VM" lookup used by both `charly bundle add` (artifact-env collection) and `charly check live` (tests overlay), so the two never diverge. Resolution order:
- by deploy NAME (the entry key) — the precise match;
- by the legacy "vm:<name>" key form;
- by scanning for any target:vm entry whose `vm:` field == vmName (or == name) — the fallback when the caller only knows the vm entity.
Keying by the deploy NAME first is load-bearing: a bed whose key differs from its vm entity (e.g. check-k3s-vm -> vm: k3s-vm) is found by its key, not mis-resolved via the vm entity name.
func MergeBundleNode ¶ added in v0.2026190.848
func MergeBundleNode(dst, src BundleNode) BundleNode
MergeBundleNode applies non-zero fields from `src` onto `dst` and returns the merged copy. Walks every yaml-tagged field via reflect; the yaml `-` tag (derived/runtime-only fields) is skipped. Same precedence rule as the underlying merge: src non-zero wins, otherwise dst passes through. Per R3 the single helper replaces the hand-rolled per-field merges that previously lived in MergeDeployConfigs (drift-prone — every new struct field needed a remembered append, and 19+ were missed).
type CacheMountDef ¶
type CacheMountDef = spec.CacheMount
type CacheMountSpec ¶
CacheMountSpec mirrors the BuildKit cache-mount configuration carried in the embedded build vocabulary's format/builder definitions (charly/charly.yml). The OCI target renders these as `--mount=type=cache,...`; the host target ignores them.
type CandyArtifact ¶ added in v0.2026190.848
type CandyArtifact = vmshared.CandyArtifact
type CandyCapabilities ¶ added in v0.2026190.848
type CandyCapabilities = spec.CandyCapabilities
type CandyModel ¶ added in v0.2026190.848
type CandyModel interface {
GetName() string
GetSourceDir() string
GetVersion() string
Vars() map[string]string
PlanSteps() []Step
Reboot() bool
Apk() []ApkPackageSpec
EnvConfig() (*EnvConfig, error)
Service() []ServiceEntry
Shell() *ShellConfig
TopPackages() []string
FormatSection(name string) *PackageSection
LocalPkg(format string) string
TagSection(tag string) *TagPkgConfig
HasFile(filename string) bool
// P8 render-delta accessors (build-mode graph/render surface). Field-backed
// members use Get* to avoid a field/method name collision on the charly *Candy
// implementer; the three already-methods keep their names.
GetIncludedCandy() []CandyRef // candy: composition refs (splicing)
GetRequire() []CandyRef // require: deps (ordering + resolution)
HasContent() bool
HasInstallFiles() bool // at least one install file (drives pixi-bound detection)
PixiManifest() string
GetHasPackageJson() bool
GetHasCargoToml() bool
GetExternalBuilder() string // external_builder: word (the out-of-tree builder plugin this candy selects)
HasFormatPackages() bool
GetRemote() bool // true if the candy came from a remote repo
HasExtract() bool
Extract() []ExtractYAML
HasData() bool
Data() []DataYAML
GetHasPixiLock() bool
GetRepoPath() string
GetSubPathPrefix() string
HasEnv() bool
HasRoute() bool
Route() (*RouteConfig, error)
// P8 init-cluster accessors (emitInitAssembly/emitInitFragmentStages/
// generateInitFragments). RelayPorts wraps the field-backed PortRelayPorts to
// avoid a field/method name collision on the charly *Candy implementer.
HasInit(initName string) bool // this candy contributes to the named init system
ServiceFiles() []string // file_copy-model service unit paths (globbed)
RelayPorts() []int // port_relay: ports (init-agnostic)
// P8 writeCandySteps accessors.
HasTasks() bool // the candy has any tasks: (runOps non-empty)
RunOps() []vmshared.Op // the candy's plan lowered to build-mode run ops
}
candy_model.go — CandyModel, the read-only view of a runtime candy that the deploy-plan compiler (BuildDeployPlan) consumes. The concrete runtime Candy lives in charly and implements this interface; the compiler depends on the abstraction (kernel/plugin boundary law: a Mechanism consumes an interface, the concrete kind implements it), so the candy struct + its whole test suite stay in charly with zero cross-package churn.
func NewSpecCandyModel ¶ added in v0.2026195.544
func NewSpecCandyModel(m spec.CandyModel, v spec.CandyView) CandyModel
NewSpecCandyModel builds a deploykit.CandyModel from a candy's resolved-project envelope views. m + v are the CandyModels[name] / Candies[name] entries; SourceDir comes from m.
type CandyPluginDecl ¶ added in v0.2026190.848
type CandyPluginDecl = vmshared.CandyPluginDecl
type CandyRef ¶ added in v0.2026190.848
type CandyRef struct {
Raw string // original ref, e.g. "@github.com/org/repo/candy/x:v1" or bare "x"
// Resolved is the qualified candy-map key assigned when a freshly-fetched
// remote candy's plain-name sibling deps are qualified to
// "<repo>/<subpathprefix><name>" (qualifyRemoteSiblingDeps). Empty for every
// other ref, where the map key derives from Raw.
Resolved string
}
CandyRef is a single candy reference as authored in the candy manifest `require:` / `candy:` (or charly.yml `candy:`). It carries the ORIGINAL ref string — with any `@repo` prefix and `:version` suffix — as the single source of truth; the bare map-key form (.Bare()) and the pinned version (.Version()) are DERIVED on demand, so a ref's identity and its version can never drift apart.
func ToCandyRefs ¶ added in v0.2026190.848
ToCandyRefs wraps raw ref strings into CandyRef values. Returns nil for a nil/empty input so an absent list stays absent.
func (CandyRef) Bare ¶ added in v0.2026190.848
Bare returns the candy-map key (no @ prefix, no :version) — the form used for dependency resolution and graph keying.
type CollectedSecret ¶ added in v0.2026194.615
type CollectedSecret struct {
Name string // podman secret name: "charly-<image>-<name>"
Target string // container mount path
Env string // env var name INSIDE the container
HostEnv string // env var name on the HOST to read the value from
SecretName string // original secret name from the candy manifest
Service string // credential store service override
Key string // credential store key override
RotateOnConfig bool // bypass podmanSecretExists short-circuit (rotate every config)
}
CollectedSecret is a fully resolved secret ready for provisioning + quadlet emission (the Secret= directive). Resolved runtime state (ruling C: the plugin builds it internally), not a wire type — owned here as a plain struct.
type CycleError ¶ added in v0.2026192.1709
type CycleError struct {
Cycle []string
}
CycleError represents a circular dependency error
func (*CycleError) Error ¶ added in v0.2026192.1709
func (e *CycleError) Error() string
type DataProvisionMode ¶ added in v0.2026198.345
type DataProvisionMode string
DataProvisionMode controls how ProvisionData copies files.
const ( // DataProvisionInitial copies all data into empty directories (cp -a). // Used by charly config for first-time setup. DataProvisionInitial DataProvisionMode = "initial" // DataProvisionMerge adds missing files without overwriting existing ones (cp -an). // Used by charly update to add new data while preserving user modifications. DataProvisionMerge DataProvisionMode = "merge" // DataProvisionForce overwrites all data unconditionally (cp -a). // Used by charly config --force-seed. DataProvisionForce DataProvisionMode = "force" )
type DeployExecutor ¶ added in v0.2026190.848
type DeployExecutor = spec.DeployExecutor
func AppendHopForFlatPath ¶ added in v0.2026190.848
func AppendHopForFlatPath(chain DeployExecutor, node *BundleNode, flatPath, leaf string) (DeployExecutor, error)
AppendHopForFlatPath stacks one executor hop so commands land inside `node`'s substrate. flatPath is the dotted path with dots replaced by underscores — the host-side container name suffix; leaf is the final path segment (the node's own key), used for a pod deployed STANDALONE inside a VM guest (which has no parent-path concept — see the pod case).
func CheckBoxContainerChain ¶ added in v0.2026197.1320
func CheckBoxContainerChain(engine, imageRef string) (DeployExecutor, func(), error)
CheckBoxContainerChain is the R44 Option-A box-mode executor: instead of a fresh `podman run --rm <img> bash` per check step (N container SETUPS — each a rootfs mount + temp-/etc/passwd generation that races concurrent build-store churn, the exit-127 passwd-file-race root cause), it creates ONE long-lived container from imageRef and returns a ContainerChain exec'ing into it (O(N)→O(1) setups), unifying box-mode with check-live's `podman exec` model. The per-step isolation of `--rm` is intentionally traded for the shared container: `check:` steps are idempotent goss-style probes and check-live ALREADY runs them against ONE shared container, so box-mode merely aligns (see the check skill; any check secretly relying on fresh-container isolation is flushed by the all-images gate).
The single container-CREATE is the one remaining setup that can race the store; its failure is CLASSIFIED (kit.ClassifyContainerInfraFailure): an infra failure returns a MARKED error so the caller exits the INFRA class (a plain error → exit 1), never checks-failed — a residual setup failure is surfaced LOUDLY, never absorbed by a retry (classify-only, R44 ruling).
Returns the exec chain + a teardown closure (always safe to call, even on the error paths).
func ContainerChain ¶ added in v0.2026190.848
func ContainerChain(engine, containerName string) DeployExecutor
ContainerChain returns a one-hop chain that exec's into a single named running container (`<engine> exec <name> bash`). Convenience for the simple `charly check live <name>` path where there is no nested dotted path to walk — equivalent to ResolveDeployChain on a single-segment dotted path that resolves to a pod node, but skips the tree lookup.
func RootExecutorForDeployNode ¶ added in v0.2026190.848
func RootExecutorForDeployNode(node *BundleNode) (DeployExecutor, error)
RootExecutorForDeployNode selects the ROOT DeployExecutor for a `target: local` deployment node from its `host:` field — the single source of truth for "where does a local deploy's work run?", shared by `charly bundle add` (the local deploy target.Add) and `charly check live` (runLocalCheck) so neither re-implements the selection (R3):
host: "" / "local" → ShellExecutor{} (this machine, direct shell)
host: "<user>@<machine>" → &SSHExecutor{User, Host, Port, …}
host: "<machine>" + user: → SSHExecutor with User from node.User
It does NOT handle the nested-inside-a-parent case (opts.ParentExec); that stays in the local deploy target.Add because it's deploy-execution-specific. Returns ShellExecutor{} for a nil node.
func VmChildExecutor ¶ added in v0.2026190.848
func VmChildExecutor(parentExec DeployExecutor, deployName string) (DeployExecutor, error)
VmChildExecutor wraps parentExec with an SSH jump into the VM represented by this node. At the root (parentExec == nil or ShellExecutor), the child gets a plain SSHExecutor — no nesting overhead for the common case of a VM on localhost.
The SSH alias keys off the per-deploy DOMAIN IDENTITY (charly-<VmDomainIdentity(deployName)>), NOT node.From (the shared kind:vm entity) — `charly vm create <entity> --domain <deploy>` writes the managed stanza under `charly-<deploy>` (P33). Several beds may share one entity via `from:`, so an entity-keyed alias collides them on ONE stanza (the R10 defect where sibling beds both derived `charly-eval-vm`); keying by the deploy makes the alias distinct per bed and matches the stanza vm create actually wrote. A direct create (deploy == entity) resolves to `charly-<entity>` naturally, and VmDomainIdentity flattens a dotted member path consistently with the domain the lifecycle named (bundle_members.go's `vmDomainIdentity(memberKey)`).
type DeployTarget ¶ added in v0.2026190.848
type DeployTarget = spec.DeployTarget
type DeployTreePhase ¶ added in v0.2026190.848
type DeployTreePhase int
DeployTreePhase indicates which lifecycle phase the walker is in. Pre-order for add; teardown walks the flat-path chain (deploy_chain.go).
const ( DeployTreePhaseAdd DeployTreePhase = iota DeployTreePhaseDel )
type DeployTreeVisitor ¶ added in v0.2026190.848
type DeployTreeVisitor func(path string, node *BundleNode, parentExec DeployExecutor) (childExec DeployExecutor, err error)
DeployTreeVisitor is invoked once per node in the walk. It receives the node's dotted path, the node itself, and the parent executor (nil at the root). The return value is the DeployExecutor that this node's CHILDREN should use as their parent. A host-target node returns the same executor it was given (candies applied in-place on the parent venue); a container or vm node returns a NestedExecutor that drills into the newly-created environment.
Returning (nil, nil) for a node with children is an error — it means "cannot compute child executor", which the walker surfaces with the offending path.
type EmitOpts ¶ added in v0.2026190.848
func InstallOptsApplyTo ¶ added in v0.2026190.848
func InstallOptsApplyTo(o *InstallOptsConfig, opts EmitOpts) EmitOpts
ApplyTo merges install_opts settings into an EmitOpts. CLI flags still win — charly.yml provides defaults, not overrides. Nil receiver is a no-op.
type EmitPluginOpParams ¶ added in v0.2026195.1912
type EmitPluginOpParams struct {
Dir string `json:"dir"`
BoxName string `json:"box_name"`
Op *spec.Op `json:"op"`
}
EmitPluginOpParams carries the plugin-verb op to the core EmitPluginOp logic (the providerRegistry.ResolveVerb + ProvisionActor/OpEmit dispatch). The img (for distros) is read from the cached Generator's gen.Boxes[box_name].
type EmitPluginOpResult ¶ added in v0.2026195.1912
EmitPluginOpResult carries the rendered fragment + whether it is an act-script.
type EnsureBuildersParams ¶ added in v0.2026195.1912
EnsureBuildersParams carries the builder words to core ensureBuildersConnected.
type EnvDependency ¶ added in v0.2026190.848
type EnvDependency = vmshared.EnvDependency
type EnvProvideEntry ¶ added in v0.2026190.848
type EnvProvideEntry struct {
Name string `yaml:"name" json:"name"`
Value string `yaml:"value" json:"value"`
Source string `yaml:"source" json:"source"`
}
EnvProvideEntry is a resolved env_provides entry in charly.yml.
func PodAwareEnvProvides ¶ added in v0.2026190.848
func PodAwareEnvProvides(entries []EnvProvideEntry, consumerKey, ctrName string) []EnvProvideEntry
PodAwareEnvProvides rewrites same-deploy env values to localhost and dedups cross-deploy entries by name (local wins).
func (EnvProvideEntry) GetName ¶ added in v0.2026190.848
func (e EnvProvideEntry) GetName() string
func (EnvProvideEntry) GetSource ¶ added in v0.2026190.848
func (e EnvProvideEntry) GetSource() string
type ExternalPluginStep ¶
type ExternalPluginStep struct {
Op *Op // the run: step op — Plugin (verb word) + PluginInput + RunAs
CandyName string // owning candy (provenance + the ledger CandyRecord key)
ResolvedUser string // uid:gid or "root" after resolveUserSpec — drives Scope
Distros []string // the image's distro tag chain (img.Tags) for the build-emit BuildEnv
}
ExternalPluginStep is the install-timeline IR node for a `run: plugin: <verb>` step whose verb is served by an EXTERNAL (out-of-process) plugin — a grpcProvider, not a built-in TypedStepProvider (package/service) or ProvisionActor (the state-provision shell verbs) or the `command` install verb. compileActOp routes it here; the Invoke op is picked per venue, placement-agnostic above the registry:
- the DEPLOY venue (the install runs ON the target, not into an image): BOTH target:local AND target:vm externalized, so an ExternalPluginStep on a deploy is reached by the external local/vm plugin's kit.WalkPlans, which routes it through the host's RunHostStep (the nested ExternalPluginStep case) → executeExternalPluginStep → Invoke(OpExecute) WITH the live DeployExecutor on the go-plugin broker (the E3b reverse channel), so the plugin runs its deploy-context effect (RunSystem/RunUser) on the real venue and RETURNS its teardown ReverseOps which the host records into the ledger (record-and-replay — only recorded ops are reversed at `charly bundle del`). This is the deploy-context counterpart of the build-context OpEmit leg (tasks.go emitPluginFragment), reusing the SAME spec.DeployReply / ReverseOp wire as the external deploy TARGET (deploy_target_external.go) — R3.
- EmitOCI (a BUILD venue — the pod-overlay Containerfile): Invoke(OpEmit) via the SHARED emitPluginFragment, splicing the plugin's Containerfile FRAGMENT verbatim — it cannot deploy-execute at build (no live venue). Identical behaviour to the box-build path (writeCandySteps → emitTasks `case "plugin"`), just relocated. EmitOCI is the ONLY in-proc Emit* this provider still implements.
Reverse() is static-nil: the reversal ops are DYNAMIC — they come from the plugin's OpExecute reply at emit time, recorded by the host's RunHostStep handler into the CandyRecord (the externalDeployTarget record-and-replay pattern).
func (*ExternalPluginStep) Kind ¶
func (s *ExternalPluginStep) Kind() StepKind
func (*ExternalPluginStep) RequiresGate ¶
func (s *ExternalPluginStep) RequiresGate() Gate
RequiresGate is GateNone — an external plugin verb-step is operator-authorized build/deploy-time plugin execution (the candy author opted into it), mirroring the external deploy TARGET which is ungated; the plugin picks its own privilege via RunSystem/RunUser on the reverse channel.
func (*ExternalPluginStep) Reverse ¶
func (s *ExternalPluginStep) Reverse() []ReverseOp
Reverse is static-nil: the teardown ops are recorded DYNAMICALLY from the plugin's OpExecute DeployReply at emit time (EmitLocal/EmitVM append reply.ReverseOps to the CandyRecord), exactly like the external deploy target — never recomputed.
func (*ExternalPluginStep) Scope ¶
func (s *ExternalPluginStep) Scope() Scope
Scope classifies by the step's user context — the SAME rule OpStep uses (OpStepScope): root/empty → system, a named/numeric non-root user → user. The plugin then chooses RunSystem vs RunUser on the reverse channel per its own effect; this scope drives only the ledger reverse-op privilege bookkeeping.
func (*ExternalPluginStep) Venue ¶
func (s *ExternalPluginStep) Venue() Venue
type ExternalStep ¶ added in v0.2026190.848
type ExternalStep struct {
Word string // the reserved step word; Kind() = "external:" + Word
ScopeV Scope // plugin-declared (StepContract.scope)
VenueV Venue // plugin-declared (StepContract.venue)
GateV Gate // plugin-declared (StepContract.gate) — the step SKIPs if the gate is not enabled
Payload json.RawMessage // opaque per-kind input — the OpExecute params
CandyName string // owning candy (provenance + the ledger CandyRecord key)
ReverseOps []ReverseOp // set DYNAMICALLY from the plugin's OpExecute reply (record-and-replay)
}
ExternalStep is an EXTERNAL, plugin-CONTRIBUTED install-step KIND: a step whose Kind() is "external:<word>", carried OPAQUELY (Payload) and whose Scope/Venue/Gate come from the serving class:step plugin's DECLARED StepContract. Its host EXECUTION funnels through the OpExecute-to-the-serving-plugin path; teardown ops are DYNAMIC (recorded from the OpExecute reply), so Reverse() returns the recorded slice.
func (*ExternalStep) Kind ¶ added in v0.2026190.848
func (s *ExternalStep) Kind() StepKind
func (*ExternalStep) RequiresGate ¶ added in v0.2026190.848
func (s *ExternalStep) RequiresGate() Gate
func (*ExternalStep) Reverse ¶ added in v0.2026190.848
func (s *ExternalStep) Reverse() []ReverseOp
func (*ExternalStep) Scope ¶ added in v0.2026190.848
func (s *ExternalStep) Scope() Scope
func (*ExternalStep) Venue ¶ added in v0.2026190.848
func (s *ExternalStep) Venue() Venue
type ExtractYAML ¶ added in v0.2026190.848
type ExtractYAML = spec.ExtractYAML
type FileStep ¶
type FileStep struct {
Source string // path to source content (under layer dir or .build/_inline/)
Dest string // absolute destination path
Mode os.FileMode // permissions
Owner string // "root" or "uid:gid" or the invoking user's name
CandyName string // for ledger
}
FileStep places a single file. The compiler may emit these for candy-declared file directives that aren't wrapped as tasks (e.g. supervisord fragment assembly). Today's tasks.go handles most file placement via OpStep; FileStep exists for cases where the compiler synthesizes file writes that weren't in the candy manifest (e.g. service unit files, managed-block contents).
func (*FileStep) RequiresGate ¶
type Generator ¶ added in v0.2026192.1709
type Generator struct {
Dir string
Candies map[string]CandyModel
Tag string
Boxes map[string]*buildkit.ResolvedBox
BuildDir string
Containerfiles map[string]string // cached content per image (build pipes via stdin)
GlobalOrder []string // popularity-weighted global candy order for cache reuse
RequestedBoxes []string // scopes which Containerfiles Generate() writes; empty = all
// DevLocalPkg makes localpkg candies (the charly toolchain) build from LOCAL
// in-development source instead of the published release — set ONLY for
// disposable check-bed image builds. See renderLocalPkgImageInstall.
DevLocalPkg bool
// EmitPluginOp dispatches a non-"command" plugin verb op through the core
// Provider registry: a ProvisionActor returns (script, true, nil) so emitTasks
// emits it via EmitCmd; any other provider returns (fragment, false, nil) so
// emitTasks writes it verbatim. The Provider registry + OpEmit dispatch (and its
// error strings) STAY CORE; charly's toDeploykit() wires this closure. Op =
// vmshared.Op = spec.Op.
EmitPluginOp func(op *spec.Op, img *buildkit.ResolvedBox) (out string, isScript bool, err error)
// CollectBoxPorts returns an image's aggregated exposed ports. Wraps the core
// CollectBoxPorts(cfg, layers, boxName) aggregator (which reads the core Config
// + Candy graph — RESOLVE-side, stays core). The first of the Collect* label
// seams; the others (volumes/shell/security/hooks/descriptions/alias/caps) land
// as their return types relocate to sdk (the writeLabels type-cascade).
CollectBoxPorts func(boxName string) ([]string, error)
// ValidateEgress gates a hand-built config (traefik routes, …) against the
// egress CUE schemas before it is written into the build context. Wraps core
// ValidateEgress (the egress validation stays core / its plugin) — mode "bytes".
ValidateEgress func(kind, label string, data []byte) error
// ValidateTextEgress gates a rendered TEXT artifact (the Containerfile — rejects the
// "<no value>" template-failure marker) against the rendered_text constraint. Wraps core
// validateTextEgress (kind "rendered_text", mode "text"). Distinct from ValidateEgress (bytes)
// because the Containerfile is a rendered string, not a YAML/JSON blob (#67 render-DRIVE move).
ValidateTextEgress func(label, text string) error
// RenderService materializes a ServiceEntry into a RenderedService via
// candy/plugin-init's OpResolve (the init-system template knowledge lives in
// the plugin) and egress-gates the unit text. The plugin Invoke + the egress
// gate STAY CORE; charly's toDeploykit() wires core RenderService here. Used by
// GenerateInitFragments (fragment_assembly model).
RenderService func(entry *spec.ServiceEntry, def *spec.ResolvedInit, ctx spec.ServiceRenderContext) (*spec.RenderedService, error)
// RewriteHeaderCopyForRemote rewrites a stage_header_copy COPY line so its
// source points at a materialized remote build-config asset (host fs write).
// Wraps core rewriteHeaderCopyForRemote → materializeBuildConfigAsset (host
// fs, stays core). Used by EmitInitFragmentStages.
RewriteHeaderCopyForRemote func(headerCopy string) (string, error)
// ExternalizedBuilders is the set of builder words whose inline render crosses
// to a plugin's OpResolve (vs the embedded builder: vocabulary install_template).
// Wired from core's externalizedBuilders registry fact. Read by WriteCandySteps
// to pick the inline-builder branch.
ExternalizedBuilders map[string]bool
// RenderLocalPkgImageInstall renders a candy's localpkg OS-package install for
// the image build. The PRODUCTION path is pure render (a curl+install RUN); the
// DevLocalPkg path builds the in-development package on the HOST (makepkg). Wraps
// core renderLocalPkgImageInstall (host-coupled dev leg stays core). Used by
// WriteCandySteps.
RenderLocalPkgImageInstall func(step *LocalPkgInstallStep, devLocalPkg bool, imageDir, boxName string) (string, error)
// ResolveInlineBuilder connects + OpResolves an externalized INLINE builder and
// returns its in-candy fragment (C10 InlineFragment). Wraps the core builder-emit
// cluster (ensureBuildersConnected + registry ResolveBuilder + resolveBuilderStage;
// registry-coupled, stays core), preserving its per-failure error strings. Used by
// WriteCandySteps.
ResolveInlineBuilder func(candyName, builderName string, bDef *buildkit.BuilderDef, ctx *spec.BuildStageContext, img *buildkit.ResolvedBox) (inlineFragment string, err error)
// EnsureBuildersConnected connects the EXTERNALIZED detection-builder plugins an
// image triggers (on-demand, scoped — the SAME machinery the deploy build PRE-PASS
// uses, R3), so their OpResolve build leg can be Invoked. Wraps core
// ensureBuildersConnected(ctx, cfg, dir, detected) (registry-coupled, stays core).
// Used by EmitBuilderStages.
EnsureBuildersConnected func(detected []string) error
// ResolveDetectionBuilderStage resolves + Invokes an externalized DETECTION-builder
// plugin's OpResolve build leg for one (candy, builder), returning the rendered
// BuilderResolveReply. deploykit builds the render context (BuildStageContext +
// builderResolveInputFrom) and passes the serializable input; the seam does the
// registry ResolveBuilder + OpResolve Invoke (its "not connected" error preserved
// byte-exact). Wraps core resolveDetectionBuilder's registry half. Used by EmitBuilderStages.
ResolveDetectionBuilderStage func(builderName string, in spec.BuilderResolveInput, img *buildkit.ResolvedBox) (spec.BuilderResolveReply, error)
// ResolveExternalBuilderStage resolves + Invokes an `external_builder:`-selected
// out-of-tree builder provider's OpResolve, returning the reply (non-empty Stage
// required). The seam does registry ResolveBuilder + the *grpcProvider assertion +
// the minimal-input Invoke (all its error strings preserved byte-exact). Wraps core
// resolveExternalBuilder + its provider resolution. Used by EmitExternalBuilderStages.
ResolveExternalBuilderStage func(word, candyName string, img *buildkit.ResolvedBox) (spec.BuilderResolveReply, error)
// EmitBakedPlugins bakes each composing candy's `bake_plugin:` out-of-tree plugin
// binaries into the FINAL image at /usr/lib/charly/plugins/. The deploykit render
// calls this seam post-main-FROM (after EmitExternalBuilderArtifacts). The host
// (live path) wires the charly emitBakedPlugins closure; plugin-build wires it via
// HostBuild("bake-plugins"). Used by generateContainerfile (#67 render-DRIVE move).
EmitBakedPlugins func(b *strings.Builder, boxName string, candyOrder []string) error
// CollectBoxVolume returns an image's aggregated volume mounts. Wraps the core
// CollectBoxVolume(cfg, layers, boxName, home, nil) aggregator (which reads the core
// Config + Candy graph — RESOLVE-side, stays core). Used by generateDataImageContainerfile.
CollectBoxVolume func(boxName string, home string) ([]VolumeMount, error)
// contains filtered or unexported fields
}
Generator is the build-mode RENDER engine, homed in sdk/deploykit (P8).
WHY deploykit and not buildkit: the render calls the build-compile helpers resolveCascadePackages / compileLocalPkgStep / compileShellSnippetSteps (sdk/deploykit/install_build.go) and reads deploykit.CandyModel. The import DAG is one-way deploykit→buildkit, so a buildkit-hosted render would cycle. deploykit already holds the build-compile foundation, so the render belongs here; buildkit stays the low keystone layer (ResolvedBox, RenderTemplate).
The render operates over CandyModel (never the charly-side *Candy) and over buildkit.ResolvedBox. Every host-coupled dependency the render needs — the Config/Candy-graph label aggregators (CollectBox*/Collect*/Aggregate*), init resolution (ActiveInit/ResolveInitSystem), the registry/plugin Invoke legs (ensureBuildersConnected, OpResolve/OpEmit), the registry image probe (InspectImageUser), and the few Config.Defaults/BoxConfig reads — is threaded in as a function-value SEAM field (added compiler-driven as each render method is relocated onto this type). The charly-side resolve half (NewGenerator: LoadConfig/ScanAllCandy/loadProjectPlugins/ResolveAllBox/ ComputeIntermediates/GlobalCandyOrder) constructs this value and wires the seams from the existing core functions; the podman orchestration (runBoxBuild/runBoxGenerate/push/retry/manifest) lives in candy/plugin-build and drives the build, calling back HostBuild for this host-side render.
func NewRenderGenerator ¶ added in v0.2026192.1709
func NewRenderGenerator() *Generator
NewRenderGenerator constructs a render Generator with its unexported per-image reply caches initialized. The caller (charly's g.toDeploykit()) sets the exported data fields + seam function values directly on the returned value — the caches cannot be set cross-package, which is the whole reason this constructor exists.
func NewRenderGeneratorFromProject ¶ added in v0.2026196.1550
func NewRenderGeneratorFromProject(ctx context.Context, ex *sdk.Executor, rp *spec.ResolvedProject, dir string, devLocalPkg bool) (*Generator, error)
NewRenderGeneratorFromProject constructs a deploykit.Generator from the resolved-project envelope + wires the host-coupled seams (the host callbacks the render still needs). It returns the Generator (the build order is the caller's responsibility — plugin-build computes it from the reply, plugin-deploy-pod computes the overlay candies from the live plans).
func (*Generator) BuildStageContext ¶ added in v0.2026192.1709
func (g *Generator) BuildStageContext(layer CandyModel, builderName string, builderDef *buildkit.BuilderDef, img *buildkit.ResolvedBox, builderRef string) *spec.BuildStageContext
BuildStageContext builds the render context for a candy's builder stage: stage names, copy source, user, cache mounts, detected manifest + lockfile-aware install command, manylinux fix, build script, and config-detected packages. Relocated from charly (P8); byte-identical.
func (*Generator) BuilderRefForFormat ¶ added in v0.2026192.1709
BuilderRefForFormat returns the full tag of the builder image for a format, or "" when there is no distinct builder. Relocated from charly (P8).
func (*Generator) CandyCopySource ¶ added in v0.2026192.1709
CandyCopySource returns the build-context path a candy's files are COPYed from: the staged _candy dir for a remote candy, the default candy/<name>/ for a local candy at the default location, else the relative SourceDir. Relocated (P8).
func (*Generator) CandyNeedsBuilder ¶ added in v0.2026192.1709
func (g *Generator) CandyNeedsBuilder(img *buildkit.ResolvedBox, layer CandyModel, builderDef *buildkit.BuilderDef) bool
CandyNeedsBuilder returns true if a candy triggers a builder: a DetectFiles match always triggers; a DetectConfig match triggers only when the image's build formats include that format (a config-only detection is distro-coupled — the IR compiler only emits install steps for formats in img.BuildFormats). Relocated from charly (P8); byte-identical (buildFormatsInclude inlined as slices.Contains).
func (*Generator) CollectBuilderRuntimeEnv ¶ added in v0.2026192.1709
func (g *Generator) CollectBuilderRuntimeEnv(candyOrder []string, img *buildkit.ResolvedBox) []*kit.EnvConfig
CollectBuilderRuntimeEnv gathers the runtime env + PATH contributions declared by each builder a candy in the image triggers (via CandyNeedsBuilder). Relocated (P8).
func (*Generator) EmitBaseBootstrap ¶ added in v0.2026192.1709
func (g *Generator) EmitBaseBootstrap(b *strings.Builder, boxName string, img *buildkit.ResolvedBox)
EmitBaseBootstrap emits the base-stage bootstrap: a builder-rootfs ADD for a `from: builder:` base, then either the full WriteBootstrap (external base) or a USER root reset (internal base). Relocated from charly (P8); byte-identical.
func (*Generator) EmitBuilderArtifacts ¶ added in v0.2026194.1727
func (g *Generator) EmitBuilderArtifacts(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string)
EmitBuilderArtifacts copies builder artifacts/binaries into the main image. For an EXTERNALIZED detection builder (pixi/npm/aur) the COPY lines come from the plugin's cached OpResolve reply (detectionBuilderReplies, populated by EmitBuilderStages) — the plugin owns the copy_artifact/copy_binary shape now (C10). For a custom (non-externalized) builder they come from the embedded builder: vocabulary copy_artifacts/copy_binary. Both preserve the former structure: the `# Copy <builder> artifacts` header once per builder, then each candy's artifacts, and the builder BINARY copied ONCE per builder (deduped across candies).
func (*Generator) EmitBuilderStages ¶ added in v0.2026194.1727
func (g *Generator) EmitBuilderStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, candyOrder []string) error
EmitBuilderStages emits per-candy multi-stage build stages. Each builder declares detect_files and/or detect_config (the embedded builder: vocabulary, host-side DETECTION); for each matching candy an EXTERNALIZED detection builder (pixi/npm/aur) renders its stage via its plugin's OpResolve leg (ResolveDetectionBuilderStage → kit.BuilderResolve, C10 — no longer an in-core stage template); a non-externalized builder emits no build-time multi-stage (a custom builder must be an external_builder plugin). The externalized builder plugins are connected on-demand (EnsureBuildersConnected). The reply is cached per (candy, builder) for EmitBuilderArtifacts.
func (*Generator) EmitExternalBuilderArtifacts ¶ added in v0.2026194.1727
EmitExternalBuilderArtifacts writes the post-main-FROM COPY --from directives for each candy whose external builder resolved in EmitExternalBuilderStages (read from the per-image cache — never re-Invoked). The artifacts pull the built files out of the plugin's multi-stage build into the final image.
func (*Generator) EmitExternalBuilderStages ¶ added in v0.2026194.1727
func (g *Generator) EmitExternalBuilderStages(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string) error
EmitExternalBuilderStages emits the pre-main-FROM multi-stage block for every candy that selects an `external_builder:` — the build-time BUILDER leg, the multi-stage counterpart of a `run:` step's `plugin:` verb. For each such candy it resolves the builder word through the ResolveExternalBuilderStage seam (registry ResolveBuilder + *grpcProvider assertion + OpResolve Invoke, charly-side, all error strings byte-preserved) and writes the returned BuilderResolveReply's Stage verbatim (egress-validated with the rest of the Containerfile). The reply is CACHED on the Generator so EmitExternalBuilderArtifacts can splice the matching COPY --from directives post-main-FROM without re-Invoking. The cache is RESET here so it scopes to ONE image.
func (*Generator) EmitExtractStages ¶ added in v0.2026192.1709
EmitExtractStages emits a `FROM <source> AS <candy>-extract-<i>` stage per candy extract directive (the source images files are extracted from). (P8).
func (*Generator) EmitExtractedFiles ¶ added in v0.2026192.1709
func (g *Generator) EmitExtractedFiles(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string)
EmitExtractedFiles emits the COPY --from=<extract-stage> directives that pull extracted files into the image (chowned to the image user). (P8).
func (*Generator) EmitInitAssembly ¶ added in v0.2026192.1709
func (g *Generator) EmitInitAssembly(b *strings.Builder, img *buildkit.ResolvedBox, candyOrder []string, activeInits map[string]*spec.ResolvedInit, initHasFragments map[string]bool) error
EmitInitAssembly emits the assembly_template, system_enable_template, and post_assembly_template RUN steps for each active init system. Relocated from charly (P8); byte-identical. initHasFragments gates the assembly step (a fragment-less init contributed no scratch stage to bind-mount from).
func (*Generator) EmitInitFragmentStages ¶ added in v0.2026192.1709
func (g *Generator) EmitInitFragmentStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, candyOrder []string, activeInits map[string]*spec.ResolvedInit) (map[string]bool, error)
EmitInitFragmentStages emits the per-init scratch stages that COPY service fragments, relay configs, and detected service files, and returns the per-init map of whether any fragment content was contributed (consumed by EmitInitAssembly). Relocated from charly (P8); byte-identical.
func (*Generator) EmitPreMainCandyStages ¶ added in v0.2026194.1727
func (g *Generator) EmitPreMainCandyStages(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, candyOrder []string) error
EmitPreMainCandyStages emits the pre-main-FROM per-candy stages: the FROM-scratch COPY stages, the detection-builder multi-stage build stages (fully config-driven from the embedded builder: vocabulary), the EXTERNAL builder stages (a candy selecting an `external_builder:` gets its provider's OpResolve stage spliced pre-main-FROM; the artifacts COPY follows post-main-FROM via EmitExternalBuilderArtifacts), and the extraction stages.
func (*Generator) EmitScratchStages ¶ added in v0.2026192.1709
EmitScratchStages emits a `FROM scratch AS <candy>` + `COPY <src>/ /` per candy, staging each candy's files in its own scratch layer. Relocated (P8).
func (*Generator) EmitTasks ¶ added in v0.2026192.1709
func (g *Generator) EmitTasks(b *strings.Builder, layer CandyModel, img *buildkit.ResolvedBox, ops []vmshared.Op, buildDir, contextRelPrefix string) (string, error)
emitTasks renders a candy's tasks to b in strict order, with adjacent-coalescing for mkdir/link/setcap batches, parent-dir auto-insertion for copy/write, USER switches on user change, and implicit build-task auto-append. Returns the final USER (so writeCandySteps knows whether to reset the candy boundary). Relocated from charly core (P8); byte-identical. The `plugin` verb case is the ONLY host seam — dispatched through g.EmitPluginOp (the Provider registry stays core).
func (*Generator) EmitTraefikRouteStage ¶ added in v0.2026192.1709
func (g *Generator) EmitTraefikRouteStage(b *strings.Builder, boxName string, img *buildkit.ResolvedBox, candyOrder []string) (hasRoutes, hasTraefik bool, err error)
EmitTraefikRouteStage emits the traefik-routes scratch stage when the image has route candies AND traefik, generating the routes file. Returns (hasRoutes, hasTraefik). Relocated from charly (P8); byte-identical.
func (*Generator) Generate ¶ added in v0.2026195.1912
Generate renders a Containerfile for each box in order, writing them to g.BuildDir/<name>/Containerfile and caching the content in g.Containerfiles. The caller (charly's hostBuildBuildResolve generate-prep, or plugin-build's runBoxGenerate/runBoxBuild) provides the order; the build-PREP (cleanStaleBuildDirs, MkdirAll, writeContextIgnore, createRemoteCandyCopies, ResolveBoxOrder, filterBox, resolveUserContext) stays HOST — Generate does ONLY the per-box render.
func (*Generator) GenerateInitFragments ¶ added in v0.2026192.1709
func (g *Generator) GenerateInitFragments(boxName, initName string, def *spec.ResolvedInit, candyOrder []string) error
GenerateInitFragments writes init system config fragments to .build/<image>/<fragmentDir>/. Schema-driven: iterates each candy's service: list and renders every entry that binds to this init via per-entry routing (use_packaged → systemd; custom exec → any init with a service_template). Relocated from charly (P8); byte-identical. The service render itself crosses to candy/plugin-init via the RenderService seam.
func (*Generator) GenerateTraefikRoutes ¶ added in v0.2026192.1709
func (g *Generator) GenerateTraefikRoutes(boxName string, candyOrder []string, _ *buildkit.ResolvedBox) error
GenerateTraefikRoutes writes the image's traefik dynamic-config (routers + services) to .build/<box>/traefik-routes.yml, egress-gated before write. Relocated from charly (P8); byte-identical.
func (*Generator) GlobalOrderForBox ¶ added in v0.2026192.1709
func (g *Generator) GlobalOrderForBox(imageCandies []string, parentCandies map[string]bool) ([]string, error)
GlobalOrderForBox returns the candy order for an image by filtering the global order to only the image's needed candies (expanded + transitively resolved). Shared candies keep the same cross-image order, maximizing cache reuse. Any needed candy missing from the global order is appended in resolution order (a safety net that shouldn't trigger). Relocated from charly core (P8); byte-identical.
func (*Generator) ResolveBaseImage ¶ added in v0.2026192.1709
func (g *Generator) ResolveBaseImage(img *buildkit.ResolvedBox) string
ResolveBaseImage returns the base image ref for img: the external OCI ref when external, else the parent image's full CalVer tag. Relocated from charly (P8).
func (*Generator) WriteBootstrap ¶ added in v0.2026192.1709
func (g *Generator) WriteBootstrap(b *strings.Builder, img *buildkit.ResolvedBox)
WriteBootstrap emits the base-image bootstrap block: cache mounts, dnf tuning, bootstrap package install, distro workarounds, the go-task install, user/group creation (or adoption), and WORKDIR. Relocated from charly (P8); byte-identical.
func (*Generator) WriteCandyEnv ¶ added in v0.2026192.1709
func (g *Generator) WriteCandyEnv(b *strings.Builder, candyOrder []string, img *buildkit.ResolvedBox)
WriteCandyEnv emits the merged candy env + builder runtime env as sorted ENV directives (plus a PATH-append). Relocated from charly (P8); byte-identical (sortStrings → slices.Sort is the same lexicographic order).
func (*Generator) WriteCandySteps ¶ added in v0.2026192.1709
func (g *Generator) WriteCandySteps(b *strings.Builder, candyName string, img *buildkit.ResolvedBox, skipRootReset bool) (bool, error)
WriteCandySteps writes the RUN steps for a single candy (the per-candy render call-graph: ENV/packages/localpkg/tasks/builders/shell/user-reset sharing the asUser state). Relocated from charly (P8); byte-identical. skipRootReset prevents emitting USER root after user-mode steps (the last candy when no post-candy root steps follow); returns true if the candy ended in user mode.
func (*Generator) WriteDataStaging ¶ added in v0.2026192.1709
func (g *Generator) WriteDataStaging(b *strings.Builder, candyOrder []string, img *buildkit.ResolvedBox)
WriteDataStaging emits COPY --from=<candy-scratch-stage> directives that stage a candy's data/ tree under /data/<volume>/[dest] for deploy-time provisioning into bind-backed volumes. Uses the short stage alias (GetName) — a remote candy's map key is not a valid build-stage ref. Relocated from charly (P8); byte-identical.
func (*Generator) WriteExpose ¶ added in v0.2026192.1709
WriteExpose emits EXPOSE directives for an image's aggregated ports (via the CollectBoxPorts seam). Relocated from charly (P8); byte-identical.
func (*Generator) WriteLabels ¶ added in v0.2026195.1912
WriteLabels emits the image metadata LABEL block from a fully-baked *spec.BakedLabelSet. It is the format-only mirror of the former charly writeLabels: it reads NO live graph, only the carrier, so it is placement-agnostic (the live render path and the plugin-build envelope path feed it the same struct). LABELs are emitted LAST in the final stage (the caller places the call after the final USER directive) so a test/label edit only reruns the LABEL instructions (metadata-only) instead of invalidating the buildkit cache for every upstream RUN/COPY.
type HooksConfig ¶ added in v0.2026190.848
type HooksConfig = spec.HooksConfig
type HostContext ¶ added in v0.2026190.848
type HostContext struct {
// MachineVenue selects compilation mode (P9): false (zero value) → compile for a
// CONTAINER image build (the pod overlay / OCI target); true → compile for a MACHINE
// venue with a system init (a target:local / target:vm deploy — services render as
// systemd units, home is deferred via {{.Home}}). detectHostContext sets it true for a
// host deploy; the OCI/pod-overlay compile passes the zero value. It replaced the former
// string Target ("host"/"vm"/"oci"), whose "vm" arm was dead (a vm deploy compiles with
// the host detectHostContext) — the machine-vs-container distinction IS the trait.
MachineVenue bool
// Distro is the resolved host distro tag, e.g. "fedora:43". Used to
// pick the right format section when compiling for a host target
// whose distro differs from the image's primary distro.
Distro string
// GlibcVersion is the host's glibc major.minor as reported by
// `ldd --version`. Used by the host target's preflight check against
// the selected builder image. Optional; empty means skip the check.
GlibcVersion string
// BuilderImage overrides the default builder-image selection for
// VenueContainerBuilder steps. Populated from --builder-image. ""
// means "use the embedded build vocabulary's default".
BuilderImage string
// BuilderContext carries the host-side build PRE-PASS result: each externalized
// detection-builder's per-candy stage context + teardown ops, keyed by
// BuilderCtxKey(candy, builder). Populated by preresolveBuilderContexts BEFORE
// this pure compile (the deploy command path); read by collectBuilderContext +
// compileBuilderSteps so the compiler NEVER dials a builder plugin (purity). Nil
// when no pre-pass ran (a direct BuildDeployPlan caller / test) or no externalized
// builder is triggered → the affected builder gets base-only context, no teardown.
BuilderContext map[string]BuilderPreresolved
}
HostContext carries host-side information the compiler needs to decide (a) which format section to pick for the host target, (b) which builder image to run user-scope builders in, (c) whether to gate AUR-specific steps, etc. For the OCI target, the caller passes a zero-value HostContext (the compiler ignores host-only choices when MachineVenue is false).
type InlineBuilderParams ¶ added in v0.2026195.1912
type InlineBuilderParams struct {
Dir string `json:"dir"`
BoxName string `json:"box_name"`
CandyName string `json:"candy_name"`
BuilderName string `json:"builder_name"`
BDef *spec.Builder `json:"b_def"`
Ctx *spec.BuildStageContext `json:"ctx"`
}
InlineBuilderParams carries the inputs to core resolveInlineBuilderSeam. BDef is spec.Builder (BuilderDef = spec.Builder); Ctx is spec.BuildStageContext — both CUE-sourced, json-tagged.
type InlineBuilderResult ¶ added in v0.2026195.1912
type InlineBuilderResult struct {
Fragment string `json:"fragment"`
}
InlineBuilderResult carries the inline fragment.
type InstallOptsConfig ¶ added in v0.2026190.848
type InstallOptsConfig = vmshared.InstallOptsConfig
type InstallPlan ¶ added in v0.2026190.848
type InstallPlan = spec.InstallPlan
func BuildDeployPlan ¶ added in v0.2026190.848
func BuildDeployPlan(layer CandyModel, img *ResolvedBox, hostCtx HostContext) (*InstallPlan, error)
BuildDeployPlan compiles one Candy into an InstallPlan.
For whole-image deploys, the caller iterates the ordered candy list (from ResolveCandyOrder) and builds one plan per candy, then merges them. Keeping one plan per candy makes refcounting trivial in the ledger: each candy's teardown is independent.
func MergePlan ¶ added in v0.2026190.848
func MergePlan(plans []*InstallPlan, image string, addCandies []string) *InstallPlan
MergePlan combines a list of per-candy plans into one whole-image plan. Used by deploy targets that want to see all steps in one sequence (for sudo batching, overall dry-run display, etc.) while preserving per-candy provenance for the ledger.
type InstallStep ¶ added in v0.2026190.848
type InstallStep = spec.InstallStep
func CompileApkStep ¶ added in v0.2026190.848
func CompileApkStep(layer CandyModel) InstallStep
CompileApkStep turns a candy's `apk:` package list into a single ApkInstallStep, or nil if the candy declares no apk packages. The `apk` format is target-agnostic at compile time — the step carries the specs and each DeployTarget decides whether to execute (android) or skip (everything else), exactly as the IR intends for venue-specific work.
func CompileLocalPkgStep ¶ added in v0.2026190.848
func CompileLocalPkgStep(layer CandyModel, img *ResolvedBox, _ HostContext) InstallStep
CompileLocalPkgStep turns a candy's `localpkg:` field into a single LocalPkgInstallStep, or nil if the candy declares none. Like CompileApkStep it is target-agnostic at compile time — the step carries the author's PKGBUILD hint plus the candy dir AND the deploy project dir (os.Getwd, the same handle compileServiceSteps reads) as the two anchors the emit-time walk-up search uses to locate the PKGBUILD. Each DeployTarget decides whether to build+install (localpkg-capable host/guest), skip (image build, non-pac targets, android, k8s).
The localpkg mechanism is fully config-driven: the format's `local_pkg:` block (resolved here via DistroDef.LocalPkgFormat, the SAME DistroDef the system-package steps read) supplies the build/install templates, package glob, foreign-deps query, probe, and dependency-builder name. BuilderImage is resolved for that block's DepBuilder the same way builder steps resolve theirs (resolveBuilderImage) so the executor can build the package's dependency closure through the EXISTING builder before installing. When the distro declares no localpkg-capable format, LocalPkg is nil and the executor skips; when no dep builder resolves, BuilderImage is "" and the dep-build is skipped with a clear log (the candy's own curl/COPY fallback still covers non-localpkg targets).
func CompileOpSteps ¶ added in v0.2026190.848
func CompileOpSteps(layer CandyModel, img *ResolvedBox) []InstallStep
CompileOpSteps turns the candy's install timeline into InstallSteps. The timeline is the candy's `plan:` `run:` steps (StepKind()==KwRun) whose context includes build/deploy, in declared (cache-stable) order — the fold that retired the separate `task:` list. Each run op either LOWERS into an existing typed step (the `plugin: package` verb → SystemPackagesStep and the `plugin: service` verb → ServicePackagedStep, each via its TypedStepProvider) so emit + reversal are REUSED, or stays a generic OpStep (install verbs + command + the RenderProvisionScript plugin verbs). A run: step scoped runtime-only is plan-runtime provisioning the check Runner executes — NOT the install timeline — and is skipped here (avoids double-execution); check:/agent-*/ include: steps are never lowered.
func CompileShellSnippetSteps ¶ added in v0.2026190.848
func CompileShellSnippetSteps(layer CandyModel, img *ResolvedBox, hostCtx HostContext) []InstallStep
CompileShellSnippetSteps returns one ShellSnippetStep per (candy, shell) pair the candy contributes. Selection rule (mirrors TagPkgConfig):
- If layer.Shell.ByShell[shell] exists, render it.
- Else if layer.Shell.Init is non-empty, render the generic body with ${SHELL_NAME} substituted to the active shell name.
- Else this shell gets nothing from this candy.
path_append entries are rendered into the snippet body using shell-appropriate syntax (PATH=... for bash/zsh/sh, fish_add_path for fish) before the step is emitted, so each DeployTarget emitter can write the snippet bytes verbatim.
Destination resolution is target-aware:
- Container build (hostCtx.MachineVenue == false): system-wide drop-in (/etc/profile.d/charly-<candy>-<shell>.sh, /etc/fish/conf.d/ charly-<candy>.fish). UseDropin=true.
- target:local, target:vm (hostCtx.MachineVenue == true): bash/zsh/sh → managed-block append in the user's rc file (UseDropin =false); fish → per-candy drop-in in ~/.config/fish/conf.d/ (UseDropin=true).
Returns nil when the candy has no shell: block.
func CompileSystemPackageSteps ¶ added in v0.2026190.848
func CompileSystemPackageSteps(layer CandyModel, img *ResolvedBox, _ HostContext) []InstallStep
CompileSystemPackageSteps emits SystemPackagesStep(s) for the candy's package sections, honoring the distro-tag-wins-over-build-format rule from today's writeCandySteps.
Phase 1: walk img.Distro tags in order; first match wins. If a tag section is found, emit ONE install step using that section and stop.
Phase 2: if no tag matched, walk img.BuildFormats in order; emit one install step per format section that has packages. (Today's writeCandySteps does this to support images that install both rpm and aur packages, for example.)
For the IR we additionally break each install into the three-phase structure (prepare/install/cleanup) so the host target can gate PhasePrepare on --allow-repo-changes. The embedded vocabulary (charly/charly.yml) currently has only one phase per format (the monolithic install_template); Task 4 will split templates into phases. Until then, we emit everything as PhaseInstall. CompileSystemPackageSteps resolves a candy's package surface for an image via the distro-specificity CASCADE and emits ONE SystemPackagesStep for the image's primary format. img.Distro is the most-specific-first tag chain (e.g. [debian:13, debian] or [ubuntu:24.04, ubuntu]); the candy's top-level package: list (layer.TopPackages) is the always-included BASE.
- packages = UNION of the base + every matching tag section's packages (dedup), so a shared package at one level plus extras at another accumulate.
- repo/copr/options/exclude/module = the MOST-SPECIFIC matching level that declares the field wins (a version's repo overrides the bare distro's).
img.Distro is most-specific-first, so iterating it in REVERSE (least → most specific) and letting later writes win yields most-specific-wins for the Raw extras while packages union regardless of order. fedora/arch reach their packages via the bare-distro tag (img.Distro = [fedora] / [arch]); there is no format-section fallback — the deb collapse that caused non-deterministic repo selection is gone (per-distro tag sections never share a mutable section).
func StepFromView ¶ added in v0.2026190.848
func StepFromView(v spec.InstallStepView) (InstallStep, error)
StepFromView reconstructs the concrete InstallStep a view projects. An unknown Kind is a hard error (the wire carried a step kind this charly does not know — a genuine version/contract breach, never silently dropped).
type LocalPkgDef ¶
type LocalPkgInstallStep ¶
type LocalPkgInstallStep struct {
PkgbuildRef string // the layer's `localpkg:` value (e.g. "pkg/arch") — a hint, resolved at emit
CandyName string
CandyDir string // layer source dir — one anchor for the relative PKGBUILD search
ProjectDir string // the deploy project dir (os.Getwd() at deploy time) — the other anchor
// Format is the package-format name whose `local_pkg:` config drives this
// step (e.g. "pac"). "" when the target distro declares no localpkg-capable
// format — the executor then treats the step as a clean no-op.
Format string
// LocalPkg is the format's localpkg contract resolved from the embedded build vocabulary (charly/charly.yml) at
// compile time (DistroDef.LocalPkgFormat). It carries the build/install
// templates, package glob, source-dir sentinel, and probe command — so the
// executor renders every package-manager command from config instead of
// hardcoding build/install/glob literals. The install command auto-resolves
// the package's dependencies from the target's repos (pacman -U / dnf
// install / apt-get install), so there is no dep-closure builder. Nil when
// Format == "".
LocalPkg *LocalPkgDef
}
--------------------------------------------------------------------------- LocalPkgInstallStep — build a bundled PKGBUILD on the host (makepkg) and install the resulting `.pkg.tar.zst` onto a pac-based deploy target. ---------------------------------------------------------------------------
LocalPkgInstallStep is the IR form of a candy's `localpkg:` field — a pointer at a bundled Arch PKGBUILD directory (relative to the candy dir or the project root). It is the proper-package counterpart of the charly candy's ad-hoc curl-a-binary `cmd:` task: on an Arch/CachyOS DEPLOY target the package is built from the repo's bundled PKGBUILD on the HOST (`makepkg`), the resulting artifact is transferred to the target, and `pacman -U`-installed — so `charly` lands as the tracked `opencharly-git` package at /usr/bin/charly rather than an untracked binary at /usr/local/bin/charly.
Like ApkInstallStep, the step is compiled REGARDLESS of target and each DeployTarget decides whether to execute or skip:
- the external local deploy (Arch/CachyOS host) and external vm deploy (Arch/CachyOS guest) EXECUTE it via the RunHostStep host-engine leg (build on host → transfer → pacman -U on the target).
- On a NON-pac deploy target the executor records a clean skip (a Fedora / Debian host has no pacman; the candy's own `cmd:` task curls the binary there as the documented fallback).
- The IMAGE build (generate.go writeCandySteps) AND the pod-overlay build-emit RENDER the localpkg IMAGE install via renderLocalPkgImageInstall: a PRODUCTION box DOWNLOADS the published release, a DISPOSABLE check bed BUILDS the in-development package on the host and COPYs it in (both install via the SAME dep-resolving install template). The pod-overlay build-emit routes through candy/plugin-installstep's `step:local-pkg-install` OpEmit, which calls back the host `step-emit` seam (stepEmitLocalPkgInstall) — the build engine stays in core. A distro with no localpkg-capable format (LocalPkg==nil) renders nothing; the candy's own COPY/curl `cmd:` task is the fallback there.
- the android / k8s substrates (external) SKIP it (no Arch package surface).
The PKGBUILD location is resolved at EMIT time (not compile time), so the step carries only the author's hint (`PkgbuildRef`) plus the candy's source dir + the deploy project dir for the walk-up search. When no PKGBUILD is found the step is a no-op (the candy's existing curl/COPY task is the fallback).
func (*LocalPkgInstallStep) Kind ¶
func (s *LocalPkgInstallStep) Kind() StepKind
func (*LocalPkgInstallStep) RequiresGate ¶
func (s *LocalPkgInstallStep) RequiresGate() Gate
func (*LocalPkgInstallStep) Reverse ¶
func (s *LocalPkgInstallStep) Reverse() []ReverseOp
Reverse returns no ledger ops — the package is the deploy substrate's own pacman-tracked package, removed (if ever) via `pacman -R opencharly-git` by the operator, not by deploy teardown. Mirrors ApkInstallStep's empty Reverse.
func (*LocalPkgInstallStep) Scope ¶
func (s *LocalPkgInstallStep) Scope() Scope
Scope is system — installing a pacman package mutates global package state.
func (*LocalPkgInstallStep) Venue ¶
func (s *LocalPkgInstallStep) Venue() Venue
Venue is host-native — makepkg runs on the host (like the aur builder), then the artifact is shipped to the target and installed via pacman.
type LocalPkgParams ¶ added in v0.2026195.1912
type LocalPkgParams struct {
Dir string `json:"dir"`
BoxName string `json:"box_name"`
CandyName string `json:"candy_name"`
ImageDir string `json:"image_dir"`
DevLocalPkg bool `json:"dev_local_pkg"`
}
LocalPkgParams carries the SCALAR inputs to core renderLocalPkgImageInstall. The LocalPkgInstallStep itself is NOT carried (no json tags); the host rebuilds it via CompileLocalPkgStep(gen.Candies[candyName], gen.Boxes[boxName], HostContext{}) — the SAME call the deploykit render makes (candy_steps.go), so byte-exact.
type LocalPkgResult ¶ added in v0.2026195.1912
type LocalPkgResult struct {
Fragment string `json:"fragment"`
}
LocalPkgResult carries the rendered localpkg image-install fragment.
type MCPProvideEntry ¶ added in v0.2026190.848
type MCPProvideEntry = spec.MCPProvideEntry
type MCPServerYAML ¶ added in v0.2026190.848
type MCPServerYAML = spec.MCPServerYAML
type Named ¶ added in v0.2026196.928
Named is the interface for provides entries (shared pipeline logic). EnvProvideEntry and MCPProvideEntry both satisfy it via their GetName/GetSource methods. Relocated from charly/provides.go so RemoveBySource/RemoveByExactSource (used by CleanDeployEntry) stay in the same package as their caller.
type NestedExecutor ¶ added in v0.2026190.848
type NestedExecutor = kit.NestedExecutor
type NestedJump ¶ added in v0.2026190.848
type NestedJump = kit.NestedJump
type OCIEmitStepParams ¶ added in v0.2026196.1550
type OCIEmitStepParams struct {
Dir string `json:"dir,omitempty"`
StepView spec.InstallStepView `json:"step_view,omitempty"`
PlanView spec.InstallPlanView `json:"plan_view,omitempty"`
}
OCIEmitStepParams is the plain-Go param struct the candy marshals into HostBuild("step-emit", StepEmitRequest{Word:"oci-emit-step", Payload: <OCIEmitStepParams>}).Distros}) — the per-step render seam for the pod-overlay build (P11c). It rides INSIDE the opaque StepEmitRequest.Payload bytes (a deploykit-internal dispatch detail, NOT a boundary-validated wire contract — the CUE wire type is StepEmitRequest itself; this is the SAME convention as the render-seam param structs in render_seam.go). Dir is the project dir — the key the host "oci-emit-step" emitter uses to look up the cached overlay buildEngineContext (the live *Generator/DistroDef/BuilderConfig/Box cannot cross the wire). StepView is the step's wire form (the candy serializes via StepToView); PlanView is the step's plan wire form (WireView) — the host reconstructs both via StepFromView/PlanFromView + calls ociEmitStep (the full provider-registry dispatch: 12 compiler-emitted kinds + ExternalPlugin + authored external), returning the rendered Containerfile fragment.
type OCITarget ¶ added in v0.2026196.1550
type OCITarget struct {
// Dir is the project dir — the key the EmitStepOp seam (HostBuild("render-seam",
// "oci-emit-step")) uses to look up the host-side cached overlay buildEngineContext (the
// host overlay-prep constructs + caches it per dir, mirroring renderGenCache for the box
// build). The live *Generator / DistroDef / BuilderConfig / Box / ImageBuildDir /
// ContextRelPrefix the host step-emitters need never cross the wire — only this dir key does.
Dir string
// Home is the overlay base image's runtime home — read by the walker for ResolveHome (the
// `{{.Home}}` token in home-bearing step fields resolves to this, the home the baked paths
// run under). The host overlay-prep returns it to the candy (via a render-seam method); the
// walker never holds the full ResolvedBox.
Home string
// Distros is the overlay base image's distro tag set (Box.Tags) — threaded onto each step's
// EmitStepOp seam call so the host class:step OpEmit can gate a plugin's build-emit on the
// image's distro set (the SAME datum the former in-core OCITarget passed to spliceClassStepEmit).
Distros []string
// EmitStepOp is the host-coupled step-render seam: it renders ONE InstallStep's
// Containerfile fragment via the CORE provider-registry dispatch (spliceClassStepEmit for
// the 12 compiler-emitted plugin-served kinds + the authored external step; stepProviderFor
// .EmitOCI for ExternalPlugin), using the host-side overlay Generator + buildEngineContext
// cached by overlay-prep. The candy wires this via HostBuild("render-seam","oci-emit-step")
// (out-of-process) or an in-proc closure (compiled-in / tests). A step that emits nothing
// (a deploy-only step, or VenueSkip) returns "". Nil EmitStepOp => a no-op render (the walker
// still writes the `# Layer:` header + the home resolution; tests that exercise the dispatch
// wire a real seam or stay in core).
EmitStepOp func(step spec.InstallStep, plan *spec.InstallPlan, distros []string) (string, error)
// contains filtered or unexported fields
}
OCITarget emits Containerfile directives for an InstallPlan. One instance handles one overlay build; the caller (candy/plugin-deploy-pod's podPrepareVenue) constructs a target, calls Emit with the add_candy plans, and reads the rendered fragment via String.
func (*OCITarget) Emit ¶ added in v0.2026196.1550
Emit walks each plan's steps and appends Containerfile directives to the internal buffer. Multiple plans emit sequentially (per-candy), mirroring the pre-move in-core OCITarget.Emit.
type OpStep ¶
type OpStep struct {
Op *Op
CandyName string
CandyDir string
CtxPath string // absolute layer-dir path replacing "/ctx/" on host
ResolvedUser string // uid:gid or "root" after resolveUserSpec
// To is the home-resolved copy/download destination for the DEPLOY path.
// The compiler tokenizes the task's `to:` (~ / ${HOME} / $HOME → {{.Home}})
// here; InstallPlan.ResolveHome substitutes the destination's real home at
// emit. execTask uses this (not the raw Task.To) for PutFile, so a
// `copy: to: ${HOME}/...` lands in the actual guest/host home instead of a
// literal "${HOME}" directory under sudo (HOME=/root). Empty when the task
// has no `to:`. The OCI build emitter reads Task.To directly (build-time
// ENV expands ${HOME}), so it is unaffected by this field.
To string
// CandyVars are the candy manifest `vars:` map propagated into the task
// script as exports. Build-time gets these via Containerfile ENV
// directives (emitVarsEnv); host/local-deploy time has no equivalent
// mechanism, so the renderer emits `export K=V` lines from this field.
// Without this, candies like `kubernetes` whose download URLs reference
// ${K3D_VERSION} fetched an empty path-component at deploy time and
// curl 404'd.
CandyVars map[string]string
// Distros is the image's distro tag chain (img.Tags), carried so the act-emit
// enabler can pass it to a state-provision plugin verb's RenderProvisionScript
// (e.g. the cross-distro package resolution). Empty for non-plugin ops; the
// unix_group act ignores it, but a future package/service state-provision plugin
// reads it.
Distros []string
}
OpStep wraps a raw Op so the IR compiler doesn't have to transform it further. The OCI target and host target both understand Op shapes (cmd / mkdir / copy / write / link / download / setcap / build) and emit the appropriate directives. CtxPath substitutes for /ctx/ in cmd bodies on the host target (container RUN directives keep /ctx via bind-mount, which doesn't exist on the host).
func (*OpStep) RequiresGate ¶
type PackageItem ¶ added in v0.2026190.848
type PackageItem = vmshared.PackageItem
type PackageSection ¶ added in v0.2026190.848
type PackageSection = spec.PackageSection
PackageSection — a generic format-specific package section (rpm/deb/pac/aur). Raw carries the full YAML map for template rendering.
type PreemptibleConfig ¶ added in v0.2026190.848
type PreemptibleConfig = spec.PreemptibleConfig
type ProvidesConfig ¶ added in v0.2026190.848
type ProvidesConfig struct {
Env []EnvProvideEntry `yaml:"env,omitempty" json:"env,omitempty"`
MCP []MCPProvideEntry `yaml:"mcp,omitempty" json:"mcp,omitempty"`
}
ProvidesConfig holds all resolved provides entries in charly.yml.
type QuadletConfig ¶ added in v0.2026194.615
type QuadletConfig struct {
BoxName string
ImageRef string
Home string
Ports []string
Volumes []VolumeMount
BindMounts []ResolvedBindMount
GPU bool
BindAddress string
Tunnel *spec.TunnelConfig
UID int
GID int
Env []string
EnvFile string
Instance string
Security vmshared.SecurityConfig
Network string
Version string
Status string
Info string
Secrets []CollectedSecret
Entrypoint []string
CharlyBin string
EncryptedMounts bool
KeyringBackend bool
PodName string
Sidecar []ResolvedSidecar
}
QuadletConfig holds the parameters for generating a quadlet .container file. An INTERNAL library type (ruling C): the plugin constructs + consumes it in one process (built from config-resolve data), so it never crosses the host↔plugin boundary and needs no CUE-sourcing.
type RebootStep ¶
type RebootStep struct {
CandyName string
}
RebootStep requests a reboot of the deploy target after this candy's steps. It is emitted (last in the candy) when a candy declares `reboot: true` — the canonical case is a kernel-module candy (e.g. nvidia-open-dkms) whose module only loads on a fresh boot with nouveau blacklisted.
Only a rebootable venue acts on it: the external vm deploy reboots the guest over SSH (the host's RunHostStep RebootStep handler, gated on the rebootable-venue flag the vm substrate sets) and waits for the boot_id to change. OCITarget / PodDeployTarget have no machine to reboot at build time and skip it (the external k8s substrate does not consume the IR at all); the external local deploy refuses to reboot the host venue unattended (skip + note). Mirrors the ApkInstallStep "only one target executes" pattern.
func (*RebootStep) Kind ¶
func (s *RebootStep) Kind() StepKind
func (*RebootStep) RequiresGate ¶
func (s *RebootStep) RequiresGate() Gate
func (*RebootStep) Reverse ¶
func (s *RebootStep) Reverse() []ReverseOp
Reverse is empty — a reboot is not a persistent artifact to undo.
func (*RebootStep) Scope ¶
func (s *RebootStep) Scope() Scope
func (*RebootStep) Venue ¶
func (s *RebootStep) Venue() Venue
type RelayContext ¶ added in v0.2026192.1709
RelayContext is the template context for relay_template rendering.
type RepoChangeStep ¶
type RepoChangeStep struct {
Format string // "rpm" | "deb" | "pac"
File string // absolute path of the repo file
Content string // rendered repo file body
Checksum string // sha256 of Content, for idempotency check at install
CandyName string
}
RepoChangeStep records a repo config file mutation (e.g. adding rpmfusion-free.repo to /etc/yum.repos.d/). Distinct from SystemPackagesStep's PhasePrepare because the compiler often synthesizes these from `cmd:` tasks that happen to install a -release.rpm — we want them tracked separately so `charly bundle del` can reverse them precisely.
func (*RepoChangeStep) Kind ¶
func (s *RepoChangeStep) Kind() StepKind
func (*RepoChangeStep) RequiresGate ¶
func (s *RepoChangeStep) RequiresGate() Gate
func (*RepoChangeStep) Reverse ¶
func (s *RepoChangeStep) Reverse() []ReverseOp
func (*RepoChangeStep) Scope ¶
func (s *RepoChangeStep) Scope() Scope
func (*RepoChangeStep) Venue ¶
func (s *RepoChangeStep) Venue() Venue
type RepoSpec ¶
type RepoSpec struct {
// Fields captured verbatim from the candy manifest. Different formats use
// different subsets (rpm has url/id/key; deb has suite/components;
// pac has url/keys). Carried as map so the template-rendered host
// and container forms can pick what they need.
Raw map[string]any
}
type ResolvedBindMount ¶ added in v0.2026194.615
type ResolvedBindMount struct {
Name string // e.g. "secrets"
HostPath string // effective host path (plain: expanded host, encrypted: plain dir)
ContPath string // container path (expanded)
Encrypted bool // for status/mount checks
}
ResolvedBindMount is a deploy-time resolved bind mount (host-path state). Runtime-only (never baked into an OCI label — LabelVolumeEntry is the label type), so it lives here as a plain deploykit struct (no CUE). Relocated from charly/enc.go with the P11 enc-model move.
type ResolvedBox ¶ added in v0.2026190.848
type ResolvedBox = buildkit.ResolvedBox
type ResolvedSidecar ¶ added in v0.2026194.615
type ResolvedSidecar struct {
Name string // sidecar key (e.g., "tailscale")
Image string // resolved OCI image ref
Env map[string]string // merged env vars
Secret []CollectedSecret // provisioned podman secrets
Volume []VolumeMount // resolved named volumes
Security vmshared.SecurityConfig // merged security config
}
ResolvedSidecar is a fully-resolved sidecar ready for quadlet generation — the host-adapted form (the sidecar plugin's spec.ResolvedSidecar wire type is adapted on the host into these deploykit/vmshared runtime types). Resolved runtime state (ruling C), not a wire type, so it lives here as a plain struct beside the other pod config-write inputs. Consumed by the pod quadlet generators (generatePodQuadlet / generateSidecarQuadlet) that assemble the .pod + sidecar .container files.
func ResolvedSidecarFromSpec ¶ added in v0.2026198.358
func ResolvedSidecarFromSpec(s spec.ResolvedSidecar) ResolvedSidecar
ResolvedSidecarFromSpec adapts one plugin-resolved spec.ResolvedSidecar into the host's ResolvedSidecar (the quadlet-gen shape).
type ReverseOpKind ¶
type ReverseOpKind = spec.ReverseOpKind
type RouteConfig ¶ added in v0.2026190.848
type RouteConfig = spec.RouteConfig
RouteConfig — a resolved route file declaration (host + port-as-string).
type SSHExecutor ¶ added in v0.2026190.848
type SSHExecutor = kit.SSHExecutor
func SSHParamsForVm ¶ added in v0.2026190.848
func SSHParamsForVm(domainID string) *SSHExecutor
SSHParamsForVm returns an SSHExecutor pointing at the VM's managed ssh-config alias (charly-<domainID>) — the caller passes the per-deploy DOMAIN IDENTITY (VmDomainIdentity of the deploy), NOT the shared kind:vm entity (P33). All connection details — User, Port, IdentityFile, host-key checking — live in the Host stanza that `charly vm create` / `charly bundle add` published into ~/.config/charly/ssh_config; ssh(1) reads them from there. Our SSHExecutor needs only the alias as Host.
type SaveDeployStateInput ¶ added in v0.2026196.928
type SaveDeployStateInput struct {
Ports []string
// SetPorts gates whether Ports is written to charly.yml at all. This ensures
// `charly config <name>` (without --port flags) and `charly update <name>` no
// longer silently overwrite operator port overrides with image-label defaults.
SetPorts bool
Env map[string]string
CleanEnv bool // true = replace env map; false = merge (upsert by key)
EnvFile string
Network string
Security *spec.Security
Volume []spec.DeployVolume
Sidecar map[string]json.RawMessage
Tunnel *spec.TunnelYAML
// SecretNames lists env var names declared as secret_accepts / secret_requires on the
// image. saveDeployState uses this list to defensively strip any matching KEY=VAL entries
// from both the input Env and the existing persisted entry.Env before writing. Defense in
// depth for the §6 / Run() pipeline (MigratePlaintextEnvSecret and scrubSecretCLIEnv are
// the primary gates). Populated by the Run() call site from meta.SecretAccept/SecretRequires.
SecretNames []string
// Disposable + Lifecycle — the classification fields (see /charly-internals:disposable).
SetDisposable bool
Disposable bool
SetLifecycle bool
Lifecycle string
// Box + Target — the schema-required fields per the 2026-05-12 require-image cutover.
// Written when non-empty AND when the existing entry doesn't already have a value (don't
// clobber operator-authored refs on re-config).
Box string
Target string
// ResolvedImage is the concrete overlay image ref produced by a pod deploy's add_candy:
// overlay build, persisted by PrepareVenue so config/start deploy EXACTLY that overlay.
ResolvedImage string
// VmState + VmCrossRef — the vm substrate's persisted runtime state (instance-id, ssh_port,
// disk path) + the kind:vm cross-ref, shipped by the externalized vm plugin's PrepareVenue
// reply as the generic State patch. VmState is written whenever non-nil; VmCrossRef seeds
// entry.From only when unset.
VmState *spec.VmDeployState
VmCrossRef string
// Resource-arbitration axis: the holder-side Preemptible block + the claimant-side
// RequiresExclusive / RequiresShared token lists. Persisted so a deploy/bed MEMBER
// round-trips its arbiter role through the per-host overlay. Written when non-empty.
Preemptible *spec.PreemptibleConfig
RequiresExclusive []string
}
SaveDeployStateInput holds the deployment parameters to persist. Relocated from charly/deploy.go (K5-Unit-1). Every field type is a spec/vmshared type the SDK already carries — no core Mechanism dep.
type SecretYAML ¶ added in v0.2026190.848
type SecretYAML = spec.SecretYAML
type SecurityConfig ¶ added in v0.2026190.848
type SecurityConfig = spec.SecurityConfig
type ServiceCustomStep ¶
type ServiceCustomStep struct {
Name string // e.g. "charly-ollama-ollama"
UnitText string // fully rendered unit content
UnitPath string // absolute install path
TargetScope Scope // ScopeSystem or ScopeUser
Enable bool
CandyName string
}
ServiceCustomStep writes and enables a full service definition. The unit text is already rendered by the compiler from the candy's generic `services:` entry via the target init system's service_template.
func (*ServiceCustomStep) Kind ¶
func (s *ServiceCustomStep) Kind() StepKind
func (*ServiceCustomStep) RequiresGate ¶
func (s *ServiceCustomStep) RequiresGate() Gate
func (*ServiceCustomStep) Reverse ¶
func (s *ServiceCustomStep) Reverse() []ReverseOp
func (*ServiceCustomStep) Scope ¶
func (s *ServiceCustomStep) Scope() Scope
func (*ServiceCustomStep) Venue ¶
func (s *ServiceCustomStep) Venue() Venue
type ServiceEntry ¶ added in v0.2026190.848
type ServiceEntry = spec.ServiceEntry
type ServicePackagedStep ¶
type ServicePackagedStep struct {
Unit string // e.g. "postgresql.service"
TargetScope Scope // ScopeSystem → /etc/systemd/system/; ScopeUser → ~/.config/systemd/user/
Enable bool
OverridesText string // rendered drop-in (.conf) content; "" if no overrides
OverridesPath string // computed absolute path for the drop-in file
CandyName string // for ledger + drop-in naming
PriorEnabled bool // populated at install time (before enable); used for teardown restore
}
ServicePackagedStep enables a systemd unit that arrived via a distro package (e.g. postgresql.service). Optional drop-in overrides are written alongside the packaged unit without touching it. This step is only emitted when rendering to a systemd-based init system; supervisord targets emit a warning-and-skip.
func (*ServicePackagedStep) Kind ¶
func (s *ServicePackagedStep) Kind() StepKind
func (*ServicePackagedStep) RequiresGate ¶
func (s *ServicePackagedStep) RequiresGate() Gate
func (*ServicePackagedStep) Reverse ¶
func (s *ServicePackagedStep) Reverse() []ReverseOp
func (*ServicePackagedStep) Scope ¶
func (s *ServicePackagedStep) Scope() Scope
func (*ServicePackagedStep) Venue ¶
func (s *ServicePackagedStep) Venue() Venue
type ShellConfig ¶ added in v0.2026190.848
type ShellConfig = vmshared.ShellConfig
type ShellExecutor ¶ added in v0.2026190.848
type ShellExecutor = kit.ShellExecutor
type ShellHookStep ¶
type ShellHookStep struct {
CandyName string
EnvVars map[string]string
PathAdd []string // already {{.Home}}-substituted to absolute paths
EnvFile string // computed path (~/.config/opencharly/env.d/<candy>.env); populated at install
}
ShellHookStep records the env vars and PATH contributions a candy makes to the user's shell environment. On the OCI target these translate to `ENV K=V` directives in the Containerfile. On the host target they become `~/.config/opencharly/env.d/<candy>.env` plus a managed block in the user's shell init that sources the env.d directory.
func CompileShellHookStep ¶ added in v0.2026190.848
func CompileShellHookStep(layer CandyModel, _ *ResolvedBox) *ShellHookStep
CompileShellHookStep returns a ShellHookStep for the candy's env: and path_append: fields, or nil if the candy contributes neither.
Home resolution is DEFERRED: `~`/`$HOME` are rewritten to the literal `{{.Home}}` token rather than expanded against img.Home. Each DeployTarget resolves the token at emit time against the home of the actual deploy destination — img.Home for the OCI/pod-overlay build, the host home for the local deploy target, and the GUEST home (via the SSH executor's ResolveHome) for the vm deploy. Baking img.Home here was wrong for VM deploys: the synthetic plan's Home was the host operator's home, so env.d on the guest pointed at /home/<operator> instead of /home/<guest-user>. See InstallPlan.ResolveHome.
func (*ShellHookStep) Kind ¶
func (s *ShellHookStep) Kind() StepKind
func (*ShellHookStep) RequiresGate ¶
func (s *ShellHookStep) RequiresGate() Gate
func (*ShellHookStep) Reverse ¶
func (s *ShellHookStep) Reverse() []ReverseOp
func (*ShellHookStep) Scope ¶
func (s *ShellHookStep) Scope() Scope
func (*ShellHookStep) Venue ¶
func (s *ShellHookStep) Venue() Venue
type ShellSnippetStep ¶
type ShellSnippetStep struct {
CandyName string // candy this snippet belongs to (also Marker source)
Origin string // "<candy>" or "box" or "deploy" (for ledger refcount + LabelShell origin)
Shell string // bash | zsh | fish | sh
Snippet string // rendered body, ${SHELL_NAME}-substituted, ready to write
PathAppend []string // already rendered into Snippet by the compiler; tracked here for label round-trip / overlay
Destination string // resolved per-target at compile time; absolute path on the target
Marker string // managed-block marker tag (= CandyName) — consumed by the kit walk's managed-block splice (sdk/kit/profile.go)
UseDropin bool // true: write whole file (fish, container drop-in); false: managed-block append into existing rc file
Priority int // load-order hint, 0 = default
}
ShellSnippetStep records a per-(candy, shell) init snippet emitted from a candy's `shell:` block. The compiler emits one step per (candy, shell) pair after applying the selection rule (per-shell ByShell entry wins over generic, with ${SHELL_NAME} substitution).
Per-target rendering:
- OCITarget: snippet bytes are content-address-staged and COPYed to a system-wide drop-in (/etc/profile.d/charly-<candy>.sh for bash/zsh/sh, /etc/fish/conf.d/charly-<candy>.fish for fish).
- the external local / vm deploy (kit.WalkPlans on the venue): managed-block append to the user's rc file (~/.bashrc, ~/.zshrc, ~/.profile) keyed by `# opencharly:begin <Marker>` fence; for fish, a per-candy drop-in at ~/.config/fish/conf.d/charly-<candy>.fish (no fence needed, file IS the unit). UseDropin discriminates the two paths.
- the external k8s substrate: does not consume the InstallPlan IR at all (the host generates a Kustomize tree separately — no shell snippet).
func (*ShellSnippetStep) Kind ¶
func (s *ShellSnippetStep) Kind() StepKind
func (*ShellSnippetStep) RequiresGate ¶
func (s *ShellSnippetStep) RequiresGate() Gate
func (*ShellSnippetStep) Reverse ¶
func (s *ShellSnippetStep) Reverse() []ReverseOp
func (*ShellSnippetStep) Scope ¶
func (s *ShellSnippetStep) Scope() Scope
Scope: SnippetStep is system-wide for build-mode (Container drop-ins live under /etc/profile.d/ — root-owned), and user-profile for host/vm deploy- mode (managed block in ~/.bashrc etc.). The compiler picks the right Scope when constructing the step based on the destination path; the step records the choice so each emitter doesn't have to re-derive it.
func (*ShellSnippetStep) Venue ¶
func (s *ShellSnippetStep) Venue() Venue
type ShellSpec ¶ added in v0.2026190.848
func ResolveShellSpec ¶ added in v0.2026190.848
ResolveShellSpec applies the per-shell-wins-over-generic selection rule. Returns the resolved spec, the rendered init body (with ${SHELL_NAME} substituted for the generic case), the path_append slice, and whether the shell has anything to contribute. Generic init wins when no per-shell override exists; per-shell wins otherwise.
type SiblingKey ¶ added in v0.2026193.1801
SiblingKey identifies a sibling-grouping equivalence class for intermediate computation. Grouping by (Base, UID) — not just Base — ensures that images with different user contexts (e.g. uid=1000 default vs. uid=0 root) don't share an auto-intermediate. Sharing would bake one group's HOME-relative paths (path_append `~/.foo/bin`, env vars using `~` or `$HOME`) into the intermediate's `ENV PATH` directives, leaving the other group with dead PATH entries that can't be overridden by its own ENV emission.
func SortedSiblingKeys ¶ added in v0.2026193.1801
func SortedSiblingKeys(m map[SiblingKey][]string) []SiblingKey
SortedSiblingKeys returns the sibling-group keys in a deterministic order — by base name, then UID. Used to make auto-intermediate creation independent of Go's randomized map iteration (see ComputeIntermediates).
type StageFragmentContext ¶ added in v0.2026192.1709
StageFragmentContext is the template context for stage_fragment_copy rendering.
type StateHostMechanisms ¶ added in v0.2026196.928
type StateHostMechanisms struct {
// LoadUnifiedBundleConfig loads a per-host charly.yml configDir through the unified
// loader and returns its ProjectBundleConfig (or nil, nil when absent / empty).
LoadUnifiedBundleConfig func(configDir string) (*BundleConfig, error)
}
StateHostMechanisms carries the ONE host-side Mechanism the state-file load/save bodies need but the SDK cannot import: the unified LOADER (LoadUnified → uf.ProjectBundleConfig), reached through LoadUnifiedBundleConfig. charly/ fills it at init (RegisterDeployStateHost); a plugin or SDK consumer that does not register it gets nil-safe no-ops from the write paths (the read paths fall back to the kit-only file path when the seam is absent).
E/M justification (the kernel/plugin boundary law): LoadUnifiedBundleConfig is a kind-blind MECHANISM (M) — it loads ANY per-host charly.yml through the unified loader and returns its ProjectBundleConfig, never branching on a deploy kind. It lives in the seam (not in deploykit directly) ONLY because the LoadUnified orchestration has not yet relocated to sdk/loaderkit (K1, task #31): once K1 lands, plugin-bundle calls loaderkit.LoadUnified directly and this seam dies entirely. The deploy-kind-specific marshal is NOT here — it is the caller's responsibility, supplied as a callback to SaveBundleConfig (a kind-blind file shell). Tracked K1-exit task: this seam field is deleted when K1 lands.
var DeployStateHost *StateHostMechanisms
DeployStateHost is the seam charly fills at init. Nil-safe: the write paths (SaveDeployState / CleanDeployEntry) no-op when it is nil; LoadBundleConfig returns (nil, nil) (absent file) so the read-only validate/inspect paths work without a registration. A plugin/SDK consumer that never writes the per-host ledger leaves it nil.
type SystemEnableContext ¶ added in v0.2026192.1709
type SystemEnableContext struct {
Units []string
}
SystemEnableContext is the render context for an init system's system_enable_template (the distro-shipped units to enable). Relocated (P8).
type SystemPackagesStep ¶
type SystemPackagesStep struct {
Format string // "rpm" | "deb" | "pac"
Phase Phase // PhasePrepare | PhaseInstall | PhaseCleanup
Packages []string // package names (for Reverse)
Repos []RepoSpec // repository entries from the candy manifest (drives PhasePrepare)
Options []string // format-specific install flags
Copr []string // RPM-only: COPR repos to enable/disable
Modules []string // RPM-only: DNF modules to enable
Exclude []string // RPM-only: packages to exclude
Keys []string // PAC-only: GPG keys to trust
// CacheMounts and RawInstallContext are passed to template rendering.
// These are populated by the compiler and consumed by the OCI target;
// the host target ignores CacheMounts (no BuildKit outside containers).
CacheMount []CacheMountSpec
RawInstallContext map[string]any
}
SystemPackagesStep installs packages via a distro package manager. One step typically expands to (PhasePrepare + PhaseInstall + PhaseCleanup) stages; the compiler emits one SystemPackagesStep per phase so the host target can gate PhasePrepare on --allow-repo-changes.
func BuildSystemPackagesStep ¶ added in v0.2026190.848
func BuildSystemPackagesStep(format string, phase Phase, packages []string, raw map[string]any, cacheMounts []CacheMountDef) *SystemPackagesStep
BuildSystemPackagesStep constructs a SystemPackagesStep from a PackageSection's Raw map, extracting the well-known structured fields (repos, options, copr, modules, exclude, keys) for gate checkuation while also preserving the full Raw map for template rendering later.
func (*SystemPackagesStep) Kind ¶
func (s *SystemPackagesStep) Kind() StepKind
func (*SystemPackagesStep) RequiresGate ¶
func (s *SystemPackagesStep) RequiresGate() Gate
func (*SystemPackagesStep) Reverse ¶
func (s *SystemPackagesStep) Reverse() []ReverseOp
func (*SystemPackagesStep) Scope ¶
func (s *SystemPackagesStep) Scope() Scope
func (*SystemPackagesStep) Venue ¶
func (s *SystemPackagesStep) Venue() Venue
type TagPkgConfig ¶ added in v0.2026190.848
type TagPkgConfig = spec.TagPkgConfig
TagPkgConfig — a distro/version-specific package section (debian:13, ubuntu:24.04, fedora:43…). Raw captures the full YAML so tag sections carry repos:/options:/keys:.
type TrieNode ¶ added in v0.2026193.1801
type TrieNode struct {
Layer string // layer at this position ("" for root)
Children map[string]*TrieNode // layer name → child node
Boxes []string // user-defined images terminating here
}
TrieNode represents a node in the candy prefix trie.
func NewTrieNode ¶ added in v0.2026193.1801
NewTrieNode returns an empty trie node labeled with layer.
type VolumeMount ¶ added in v0.2026193.1222
type VolumeMount = spec.VolumeMount
VolumeMount is a resolved named-volume mount (charly-<deploy>-<name> → container path). CUE-sourced in spec (boxmetadata.cue, P2B) + aliased here; consumers keep using deploykit.VolumeMount unchanged. DISTINCT from spec.ResolvedVolumeMount (the box-aggregate `charly box inspect --format volumes` entry): same two fields, different concept + call sites — do NOT conflate them.
type VolumeYAML ¶ added in v0.2026190.848
type VolumeYAML = spec.VolumeYAML
Source Files
¶
- bootstrap.go
- box_engine.go
- builder_support.go
- builders_render.go
- buildkit_aliases.go
- bundle_derive.go
- candy_collect.go
- candy_env.go
- candy_field_aliases.go
- candy_model.go
- candy_ref.go
- candy_stage.go
- candy_steps.go
- check_box_chain.go
- compile_seams.go
- compiler_deps.go
- container_resolve.go
- data.go
- deploy_box_name.go
- deploy_chain.go
- deploy_file.go
- deploy_nodeform.go
- deploy_state.go
- deploy_tree.go
- deploy_volume.go
- effective_version.go
- generate.go
- graph.go
- header_copy_remote.go
- init.go
- install_build.go
- intermediates.go
- kit_aliases.go
- layer_model.go
- oci_target.go
- order.go
- plan.go
- provides.go
- quadlet.go
- quadlet_paths.go
- quadlet_pod.go
- render_generator.go
- render_generator_from_project.go
- render_seam.go
- routes.go
- secret_declare.go
- security.go
- service_render_context.go
- sidecar_resolve.go
- spec_candy_adapter.go
- spec_resolved_box_adapter.go
- start_args.go
- state_aliases.go
- step_view.go
- steps.go
- tasks_emit.go
- tasks_render.go
- tasks_stage.go
- write_labels.go