extract

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandStartLine

func CommandStartLine(location []dfparser.Range) int

func NormalizeContinuation added in v0.27.2

func NormalizeContinuation(script string, escapeToken, target rune) string

NormalizeContinuation rewrites Dockerfile escape tokens at the end of each line into the target shell's native line-continuation character. This is a no-op when the escape token already matches the target (e.g. backtick escape with PowerShell, or backslash escape with POSIX shells).

Callers should choose target based on the shell variant:

POSIX shells (bash, sh, …) → '\\'
PowerShell                 → '`'
cmd.exe                    → '^'

Types

type Mapping

type Mapping struct {
	// Script is the extracted script body with Dockerfile syntax blanked out so
	// mvdan positions line up with the original Dockerfile columns.
	Script string

	// OriginStartLine is the 1-based Dockerfile line corresponding to script line 1.
	OriginStartLine int

	// FallbackLine is the 1-based Dockerfile line to use if precise mapping fails.
	FallbackLine int

	// IsHeredoc reports whether the script came from a heredoc body.
	IsHeredoc bool

	// ShellNameOverride overrides the stage shell when the heredoc is explicitly
	// fed to another shell, for example `RUN <<EOF bash`.
	ShellNameOverride string
}

func ExtractHealthcheckCmdShellScript

func ExtractHealthcheckCmdShellScript(
	sm *sourcemap.SourceMap,
	node *dfparser.Node,
	escapeToken rune,
) (Mapping, bool)

func ExtractOnbuildRunScript

func ExtractOnbuildRunScript(sm *sourcemap.SourceMap, node *dfparser.Node, escapeToken rune) (Mapping, bool)

func ExtractRunScript

func ExtractRunScript(sm *sourcemap.SourceMap, node *dfparser.Node, escapeToken rune) (Mapping, bool)

func ExtractShellFormScript

func ExtractShellFormScript(
	sm *sourcemap.SourceMap,
	node *dfparser.Node,
	escapeToken rune,
	keyword string,
) (Mapping, bool)

Jump to

Keyboard shortcuts

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