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 ¶
- func Interpolate(s string, lookup func(name string) (string, bool)) string
- func ParseEnvFile(content []byte) map[string]string
- type Parser
- func (p *Parser) DirectoryDependent() bool
- func (p *Parser) GetCommentToken() string
- func (p *Parser) GetKind() model.FileKind
- func (p *Parser) Parse(ctx context.Context, fileContent []byte, filePath string, ...) (resolved []byte, documents []model.Document, ignoreLines []int, ...)
- func (p *Parser) StringifyContent(content []byte) (string, error)
- func (p *Parser) SupportedExtensions() []string
- func (p *Parser) SupportedTypes() map[string]bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Interpolate ¶
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 ¶
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 ¶
NewDefaultWithFS returns a Parser reading sibling files (like .env) through fsys. A nil fsys falls back to the real disk.
func (*Parser) DirectoryDependent ¶
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 ¶
GetCommentToken return the comment token of YAML - #
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 ¶
StringifyContent converts original content into string formatted version
func (*Parser) SupportedExtensions ¶
SupportedExtensions returns extensions supported by this parser, which are yaml and yml extension
func (*Parser) SupportedTypes ¶
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. |