dockercompose

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interpolate

func Interpolate(s string, lookup func(name string) (string, bool)) string

Interpolate expands Compose-spec variable references in s using lookup:

$$              literal $
${VAR} / $VAR   value; left in place when unset
${VAR:-word}    word when VAR is unset or empty
${VAR-word}     word when VAR is unset
${VAR:?word}    required; left in place when unset
${VAR?word}     required when unset; left in place when unset
${VAR:+word}    word when VAR is set and non-empty; left in place when unset
${VAR+word}     word when VAR is set; left in place when unset

Unresolvable references stay in the text: collapsing them to empty would fabricate findings (untagged `image: ${IMAGE}`) and hide others (the word in a `:+` default), so rules see the original expression as before.

func ParseEnvFile

func ParseEnvFile(content []byte) map[string]string

ParseEnvFile parses a Compose .env file into a variable map. It follows the Compose spec: KEY=VAL lines, blank lines and #-comments ignored, an optional "export " prefix, and surrounding quotes stripped (single-quoted values are literal, double-quoted values unescape \n, \t and \\). No interpolation happens inside .env files themselves.

Types

type Parser

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

Parser is the DockerCompose-flavored YAML parser: shared YAML handling plus Compose-spec interpolation resolved from the sibling .env file (never the host environment). Unresolvable references stay in place so rules see the original expression instead of a fabricated empty value.

func NewDefaultWithFS

func NewDefaultWithFS(fsys vfs.FS) *Parser

NewDefaultWithFS returns a Parser reading sibling files (like .env) through fsys. A nil fsys falls back to the real disk.

func (*Parser) DirectoryDependent

func (p *Parser) DirectoryDependent() bool

DirectoryDependent reports that this parser's output can depend on files other than the one being parsed: Compose semantics resolve .env, override and extends targets from the file's directory, so two files with identical content in different directories can parse differently. The runner must not share such parses across files with identical content.

func (*Parser) GetCommentToken

func (p *Parser) GetCommentToken() string

GetCommentToken return the comment token of YAML - #

func (*Parser) GetKind

func (p *Parser) GetKind() model.FileKind

GetKind returns YAML constant kind

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context, fileContent []byte, filePath string,
	resolveReferences bool, maxResolverDepth int) (
	resolved []byte,
	documents []model.Document,
	ignoreLines []int,
	resolvedFiles map[string]model.ResolvedFile,
	err error)

Parse parses a Compose YAML file and returns it as Documents, with interpolation applied before line tracking so every rewritten value keeps the line it was declared on.

func (*Parser) StringifyContent

func (p *Parser) StringifyContent(content []byte) (string, error)

StringifyContent converts original content into string formatted version

func (*Parser) SupportedExtensions

func (p *Parser) SupportedExtensions() []string

SupportedExtensions returns extensions supported by this parser, which are yaml and yml extension

func (*Parser) SupportedTypes

func (p *Parser) SupportedTypes() map[string]bool

SupportedTypes returns types supported by this parser, which is dockercompose

Directories

Path Synopsis
Package names holds the default Docker Compose file names as a leaf package, shared by the Compose parser and the analyzer's classifier (which sit on opposite sides of an import cycle through pkg/parser/yaml), so both agree on which files are base files and which are auto-merged overrides.
Package names holds the default Docker Compose file names as a leaf package, shared by the Compose parser and the analyzer's classifier (which sit on opposite sides of an import cycle through pkg/parser/yaml), so both agree on which files are base files and which are auto-merged overrides.

Jump to

Keyboard shortcuts

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