Documentation
¶
Overview ¶
Package invocation models planned Dockerfile build invocations produced by Dockerfile-oriented entrypoints and build orchestrators such as Bake and Compose.
Index ¶
- Constants
- func CanonicalPath(path string) (string, error)
- func ConcreteBuildArgs(args map[string]*string) map[string]string
- func InvocationKey(source InvocationSource, dockerfilePath string) string
- func IsDockerfileName(path string) bool
- func IsObviousOrchestratorName(path string) bool
- func LabelForSource(source *InvocationSource) string
- func ProbeEntrypointKind(path string) (string, bool)
- func ResolveDockerfilePath(baseDir string, ctx ContextRef, dockerfile string) (string, error)
- type BakeProvider
- type BuildInvocation
- type CommandOverride
- type ComposeProvider
- type ContextRef
- type DiscoveryResult
- type HealthcheckSpec
- type InvocationContext
- type InvocationSource
- type PortBinding
- type PortSpec
- type Provider
- type ResolveOptions
- type SecretRef
Constants ¶
const ( KindDockerfile = "dockerfile" KindBake = "bake" KindCompose = "compose" ContextKindDir = "dir" ContextKindTar = "tar" ContextKindGit = "git" ContextKindURL = "url" ContextKindEmpty = "empty" ContextKindDockerImage = "docker-image" ContextKindTarget = "target" ContextKindService = "service" ContextKindOCILayout = "oci-layout" SecretScopeBuild = "build" SecretScopeService = "service" )
Variables ¶
This section is empty.
Functions ¶
func CanonicalPath ¶
CanonicalPath returns an absolute, cleaned local path.
func ConcreteBuildArgs ¶
ConcreteBuildArgs returns only build args with concrete values.
func InvocationKey ¶
func InvocationKey(source InvocationSource, dockerfilePath string) string
InvocationKey returns the stable cross-run identity for an invocation.
func IsDockerfileName ¶
IsDockerfileName reports whether a path follows common Dockerfile naming conventions.
func IsObviousOrchestratorName ¶
IsObviousOrchestratorName reports whether a filename extension implies an orchestrator entrypoint candidate.
func LabelForSource ¶
func LabelForSource(source *InvocationSource) string
LabelForSource returns a human-readable invocation label for grouping.
func ProbeEntrypointKind ¶
ProbeEntrypointKind performs a cheap content-based classification for files whose extension alone is ambiguous.
func ResolveDockerfilePath ¶
func ResolveDockerfilePath(baseDir string, ctx ContextRef, dockerfile string) (string, error)
ResolveDockerfilePath resolves a Dockerfile declaration relative to a local primary context. Non-local primary contexts cannot produce a stable local Dockerfile path in the MVP unless the Dockerfile path is absolute.
Types ¶
type BakeProvider ¶
type BakeProvider struct{}
BakeProvider discovers build invocations from Docker Buildx Bake files.
func (BakeProvider) Discover ¶
func (p BakeProvider) Discover(_ context.Context, opts ResolveOptions) (*DiscoveryResult, error)
Discover implements Provider.
type BuildInvocation ¶
type BuildInvocation struct {
Key string `json:"-"`
Source InvocationSource `json:"source"`
DockerfilePath string `json:"dockerfilePath"`
ContextRef ContextRef `json:"context"`
BuildArgs map[string]*string `json:"buildArgs,omitempty"`
Platforms []string `json:"platforms,omitempty"`
TargetStage string `json:"targetStage,omitempty"`
NamedContexts map[string]ContextRef `json:"namedContexts,omitempty"`
Environment map[string]*string `json:"environment,omitempty"`
PublishedPorts []PortBinding `json:"publishedPorts,omitempty"`
ExposedPorts []PortSpec `json:"exposedPorts,omitempty"`
Networks []string `json:"networks,omitempty"`
// Labels flattens build-time image labels and Compose service/container
// labels into one map. Compose service labels take precedence over build
// labels with the same key, so consumers must not assume every label came
// from a Dockerfile LABEL instruction.
Labels map[string]string `json:"labels,omitempty"`
Secrets []SecretRef `json:"secrets,omitempty"`
Healthcheck *HealthcheckSpec `json:"healthcheck,omitempty"`
EntrypointOverride *CommandOverride `json:"entrypointOverride,omitempty"`
CommandOverride *CommandOverride `json:"commandOverride,omitempty"`
RuntimeUser string `json:"runtimeUser,omitempty"`
RuntimeWorkingDir string `json:"runtimeWorkingDir,omitempty"`
StopSignal string `json:"stopSignal,omitempty"`
}
BuildInvocation describes one planned build of one Dockerfile under one invocation context. Providers must store local path-typed fields as absolute, cleaned paths at runtime, including DockerfilePath, ContextRef.Value when the context kind is "dir", and NamedContexts values that refer to local dirs. The rest of the pipeline relies on simple string equality for grouping and lookup.
func NewDockerfileInvocation ¶
func NewDockerfileInvocation(dockerfilePath, contextDir string) (*BuildInvocation, error)
NewDockerfileInvocation creates the normalized invocation used by direct Dockerfile linting when a context directory is declared, for example via --context. ClassifyContextRef receives baseDir "." so CanonicalPath resolves the context against the process working directory, not the Dockerfile's directory.
type CommandOverride ¶
type CommandOverride struct {
Args []string `json:"args,omitempty"`
ClearsImageValue bool `json:"clearsImageValue,omitempty"`
}
CommandOverride preserves Compose command/entrypoint override semantics.
type ComposeProvider ¶
type ComposeProvider struct{}
ComposeProvider discovers build invocations from Docker Compose files.
func (ComposeProvider) Discover ¶
func (p ComposeProvider) Discover(ctx context.Context, opts ResolveOptions) (*DiscoveryResult, error)
Discover implements Provider.
type ContextRef ¶
ContextRef classifies a declared build context without dereferencing remote content.
func ClassifyContextRef ¶
func ClassifyContextRef(baseDir, raw string) (ContextRef, error)
ClassifyContextRef normalizes and classifies a declared build context.
type DiscoveryResult ¶
type DiscoveryResult struct {
Kind string
EntrypointPath string
Invocations []BuildInvocation
ZeroLintableReason string
}
DiscoveryResult is the normalized output of provider discovery.
type HealthcheckSpec ¶
type HealthcheckSpec struct {
Test []string `json:"test,omitempty"`
Disable bool `json:"disable,omitempty"`
Interval string `json:"interval,omitempty"`
Timeout string `json:"timeout,omitempty"`
Retries *uint64 `json:"retries,omitempty"`
StartPeriod string `json:"startPeriod,omitempty"`
StartInterval string `json:"startInterval,omitempty"`
IntervalDur time.Duration `json:"-"`
TimeoutDur time.Duration `json:"-"`
StartPeriodDur time.Duration `json:"-"`
StartIntervalDur time.Duration `json:"-"`
}
HealthcheckSpec preserves Compose healthcheck override metadata.
func (*HealthcheckSpec) UnmarshalJSON ¶
func (s *HealthcheckSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON preserves the string form while also populating parsed duration companions for consumers that need numeric comparisons.
type InvocationContext ¶
type InvocationContext struct {
// contains filtered or unexported fields
}
InvocationContext is the rule-facing view of one build invocation.
func NewContext ¶
func NewContext(inv *BuildInvocation) *InvocationContext
NewContext creates an invocation context from normalized invocation metadata.
func (*InvocationContext) ContextRef ¶
func (c *InvocationContext) ContextRef() ContextRef
ContextRef returns the declared primary context reference.
func (*InvocationContext) Invocation ¶
func (c *InvocationContext) Invocation() *BuildInvocation
Invocation returns the underlying build invocation, if any.
type InvocationSource ¶
type InvocationSource struct {
Kind string `json:"kind"`
File string `json:"file"`
Name string `json:"name,omitempty"`
}
InvocationSource identifies the source declaration that produced an invocation.
type PortBinding ¶
type PortBinding struct {
ContainerStart int `json:"containerStart"`
ContainerEnd int `json:"containerEnd"`
HostStart int `json:"hostStart,omitempty"`
HostEnd int `json:"hostEnd,omitempty"`
HostIP string `json:"hostIP,omitempty"`
Protocol string `json:"protocol"`
AppProtocol string `json:"appProtocol,omitempty"`
Mode string `json:"mode,omitempty"`
}
PortBinding models published host-to-container ports such as Compose ports.
type PortSpec ¶
type PortSpec struct {
Start int `json:"start"`
End int `json:"end"`
Protocol string `json:"protocol"`
}
PortSpec models container-visible ports such as Compose expose entries.
type Provider ¶
type Provider interface {
Discover(ctx context.Context, opts ResolveOptions) (*DiscoveryResult, error)
}
Provider discovers invocations from an orchestrator source.
type ResolveOptions ¶
ResolveOptions configures provider discovery.
type SecretRef ¶
type SecretRef struct {
Scope string `json:"scope"`
ID string `json:"id,omitempty"`
Source string `json:"source,omitempty"`
Target string `json:"target,omitempty"`
}
SecretRef stores declaration metadata only. It never stores secret values. Source may be an absolute local file path, an env:<name> environment source, or a provider-specific secret identifier.