Documentation
¶
Overview ¶
Package compose parses Compose through compose-go — the same loader docker compose v2 uses — so the supported dialect is exactly what Compose accepts; Onebox does not reimplement the Compose specification.
What it parses is Onebox's own generated runtime, not a file the user wrote. The engine works in services and images, and parsing our own output is the cheapest way to keep one definition of what a service is.
It infers nothing — not which service is the application, which is a database, nor what order they start in. The project states all of it, because a guess that disagrees with the author is worse than a question.
Index ¶
- func Load(ctx context.Context, composePath, projectName string, envFiles ...string) (*types.Project, error)
- func LoadBytes(ctx context.Context, content []byte, projectName, dir string, ...) (*types.Project, error)
- func MaskValuesYAML(rendered, key []byte) ([]byte, error)
- func PayloadRewrites(p *types.Project) map[string]string
- func RedactEnvYAML(rendered []byte) ([]byte, error)
- func RewriteSources(rendered []byte, rewrites map[string]string) []byte
- func StagePayload(p *types.Project, stagingDir string) (map[string]string, error)
- func StagePayloadContext(ctx context.Context, p *types.Project, stagingDir string, ...) (map[string]string, error)
- type InterpolationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadBytes ¶
func LoadBytes(ctx context.Context, content []byte, projectName, dir string, env map[string]string) (*types.Project, error)
LoadBytes parses a Compose document already in memory. Onebox generates its runtime rather than reading one, so there is no file to point the loader at — and writing a temporary one into the user's repository to read it straight back would be a worse answer than passing the bytes.
dir anchors relative paths (build contexts, env files) exactly as the project file's directory does elsewhere. env supplies `${VAR}` expressions carried in verbatim from a Compose source the project referenced. It is deliberately explicit rather than inherited: the runner's own environment is a developer's laptop, and a document that parsed differently there than on the target would be the worst kind of difference — invisible until it deployed.
func MaskValuesYAML ¶
MaskValuesYAML returns a non-executable, structure-preserving view of YAML. Mapping keys remain visible, while every non-empty scalar value becomes a keyed opaque marker. Using one random key for the live and planned documents makes their diff meaningful without exposing values or creating markers that can be brute-forced or correlated across proposals.
func PayloadRewrites ¶
PayloadRewrites is the pure half of StagePayload: the abs→"./rel" map, with no copying. Plan and apply both use it, so the rendered bytes a plan stores are byte-identical to what apply would render.
func RedactEnvYAML ¶
RedactEnvYAML rewrites every `environment:` VALUE in rendered compose YAML to a content hash (`redacted:sha256:<12hex>`), leaving keys and all other structure intact. Environment is the conventional home of application secrets, and ob's contract is that their content is never displayed or persisted — only a hash travels. Because the placeholder is derived from the value, a rotated secret still shows as a changed hash, so the plan diff and the apply-time drift check both stay meaningful without ever exposing the value.
The walk is recursive and matches `environment:` ANYWHERE — under services, but also under top-level `x-*` extension blocks (compose-go preserves those verbatim, and shared anchors like `&server-env` are defined there). Missing even one such block would leak. Non-secret-by-convention fields (image, command, labels, env_file paths) are untouched, so the diff stays reviewable.
func RewriteSources ¶
RewriteSources replaces complete absolute runner path scalars with their release-relative forms. Longer paths go first, and scalar boundaries prevent a project root such as /srv/app from corrupting an unrelated /srv/app-data host mount.
func StagePayload ¶
StagePayload copies every file the compose file references from INSIDE the project dir (bind-mount sources, env_files — compose-go absolutized them at load) into the staging dir under its project-relative path, and returns the abs→"./rel" rewrites to apply to the rendered YAML. Sources outside the project dir (/var/run/docker.sock, /data/...) are host paths — untouched. This makes the transferred release directory self-contained.
func StagePayloadContext ¶
func StagePayloadContext(ctx context.Context, p *types.Project, stagingDir string, projected map[string]bool) (map[string]string, error)
StagePayloadContext is StagePayload with cancellation checks while walking and copying project payloads.
projected names files the caller supplies directly in the staging dir, keyed by project-relative slash path. They are referenced by the document like any other payload, but do not need copying from the project. They stay in the rewrite map, because the rendered bytes must not depend on how a file arrived.
Types ¶
type InterpolationError ¶
type InterpolationError struct {
// contains filtered or unexported fields
}
InterpolationError is a `${VAR}` a referenced Compose source needs and the project's environment files do not supply.
func (*InterpolationError) Error ¶
func (e *InterpolationError) Error() string
func (*InterpolationError) Unwrap ¶
func (e *InterpolationError) Unwrap() error