Documentation
¶
Index ¶
- func CleanupCrucibleImages(ctx context.Context, tags ...string) error
- func CosignAttest(ctx context.Context, digestRef, predicatePath, keyPath string) error
- func CosignAvailable() bool
- func CosignSign(ctx context.Context, digestRef, keyPath string, multiArch bool) error
- func CrucibleTag(purpose, runID string) string
- func ImageBinaryHash(ctx context.Context, image string) (string, error)
- func ImageDigest(ctx context.Context, image string) (string, error)
- func ImageEnvFingerprint(ctx context.Context, image string) (string, error)
- func ImageLabel(ctx context.Context, image, label string) (string, error)
- func ImageVersion(ctx context.Context, image string) (string, error)
- func IsMultiPlatform(step build.BuildStep) bool
- func ParseBuildxOutput(output string) []build.LayerEvent
- func ParseMetadataDigest(metadataFile string) (string, error)
- func ResolveCosignKey() string
- func ResolveDigest(ctx context.Context, ref string) (string, error)
- func ResolveLocalDigest(ctx context.Context, ref string) (string, error)
- func Run(req Request) error
- type ArgDecl
- type Buildx
- func (bx *Buildx) Build(ctx context.Context, step build.BuildStep) (*build.StepResult, error)
- func (bx *Buildx) BuildWithLayers(ctx context.Context, step build.BuildStep) (*build.StepResult, []build.LayerEvent, error)
- func (bx *Buildx) EnsureBuilder(ctx context.Context) error
- func (bx *Buildx) Login(ctx context.Context, registries []build.RegistryTarget) error
- func (bx *Buildx) PushTags(ctx context.Context, tags []string) (int, error)
- func (bx *Buildx) Save(ctx context.Context, imageRef string, outputPath string) error
- type CrucibleCheck
- type CrucibleOpts
- type CrucibleResult
- type CrucibleVerification
- type InventoryResult
- type PackageInfo
- type PushError
- type Request
- type VerificationArtifact
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupCrucibleImages ¶
CleanupCrucibleImages removes temporary crucible images. Best-effort; errors are returned but should never downgrade a successful crucible result. Does not use --force to avoid removing images that a user may have manually tagged from the crucible output.
func CosignAttest ¶
CosignAttest attests a predicate against an image digest ref using cosign. The digestRef must be in the form repo@sha256:... — tags are never used.
func CosignAvailable ¶
func CosignAvailable() bool
CosignAvailable returns true if cosign is on PATH.
func CosignSign ¶
CosignSign signs an image digest ref using cosign. The digestRef must be in the form repo@sha256:... — tags are never used.
func CrucibleTag ¶
CrucibleTag returns a namespaced temporary image tag for crucible. Uses stagefreight/crucible-* namespace to prevent accidental pushes.
func ImageBinaryHash ¶
ImageBinaryHash extracts the sha256 hash of /usr/local/bin/stagefreight from a local docker image.
func ImageDigest ¶
ImageDigest returns the local image ID (config digest) via docker inspect.
func ImageEnvFingerprint ¶
ImageEnvFingerprint returns an informational hash of the execution environment inside a docker image. Non-authoritative.
func ImageLabel ¶
ImageLabel reads a specific OCI label from a local image via docker inspect.
func ImageVersion ¶
ImageVersion extracts the stagefreight version string from a local docker image.
func IsMultiPlatform ¶
IsMultiPlatform returns true if the step targets more than one platform. Multi-platform builds cannot use --load (buildx limitation).
func ParseBuildxOutput ¶
func ParseBuildxOutput(output string) []build.LayerEvent
ParseBuildxOutput parses captured buildx --progress=plain output into layer events. Only meaningful build layers are returned (FROM, COPY, RUN, etc.). Internal steps (load build definition, load .dockerignore, metadata) are filtered out.
func ParseMetadataDigest ¶
ParseMetadataDigest parses the digest from a buildx --metadata-file JSON output.
func ResolveCosignKey ¶
func ResolveCosignKey() string
ResolveCosignKey finds the cosign signing key path. Checks COSIGN_KEY env var first, then .stagefreight/cosign.key.
func ResolveDigest ¶
ResolveDigest queries the registry for the manifest digest of a pushed image.
func ResolveLocalDigest ¶
ResolveLocalDigest extracts the pushed digest from a locally loaded image via docker inspect RepoDigests. This is a fallback for when buildx imagetools inspect can't reach the registry. Only returns a digest that matches the requested ref's registry/path to prevent cross-ref confusion.
Types ¶
type Buildx ¶
Buildx wraps docker buildx commands.
func (*Buildx) Build ¶
Build executes a single build step via docker buildx. When ParseLayers is true, buildx runs with --progress=plain and the output is parsed into layer events for structured display.
func (*Buildx) BuildWithLayers ¶
func (bx *Buildx) BuildWithLayers(ctx context.Context, step build.BuildStep) (*build.StepResult, []build.LayerEvent, error)
BuildWithLayers executes a build step and parses the output for layer events. Uses --progress=plain to get parseable output. The original Stdout/Stderr writers receive the raw output; layer events are parsed from the stderr copy.
func (*Buildx) EnsureBuilder ¶
EnsureBuilder checks that a buildx builder is available and creates one if needed.
func (*Buildx) Login ¶
Login authenticates to registries that have a credentials label configured. The Credentials field on each RegistryTarget is a user-chosen env var prefix:
credentials: DOCKERHUB_PRPLANIT → DOCKERHUB_PRPLANIT_USER / DOCKERHUB_PRPLANIT_PASS credentials: GHCR_ORG → GHCR_ORG_USER / GHCR_ORG_PASS
No credentials field → no login attempted (public or pre-authenticated). If credentials are configured but the env vars are missing, Login returns an error.
func (*Buildx) PushTags ¶
PushTags pushes already-loaded local images to their remote registries. Used in single-platform load-then-push strategy where buildx builds with --load first, then we push each remote tag explicitly.
Returns the count of successfully pushed tags and the first error encountered. On full success: (len(tags), nil). On failure: (N, *PushError) where tags[:N] succeeded and tags[N] failed. Callers can retry with tags[pushed:].
type CrucibleCheck ¶
type CrucibleCheck struct {
Name string // e.g. "binary hash", "version", "image digest"
Status string // "match", "differs", "unavailable"
Detail string // e.g. "sha256:abc123..."
}
CrucibleCheck is a single verification data point.
func (CrucibleCheck) IsHardFailure ¶
func (c CrucibleCheck) IsHardFailure() bool
IsHardFailure returns true if this check's failure should fail the crucible.
type CrucibleOpts ¶
type CrucibleOpts struct {
Image string // pass-1 candidate image ref
FinalTag string // tag for the verification artifact
RepoDir string // absolute path to repo root (mounted into container)
ExtraFlags []string // original user flags minus --build-mode
EnvVars []string // credential and CI env vars to forward (KEY=VALUE)
RunID string // correlates passes in logs
Verbose bool
}
CrucibleOpts configures the pass-2 container invocation.
type CrucibleResult ¶
CrucibleResult captures the outcome of a pass-2 invocation.
func RunCrucible ¶
func RunCrucible(ctx context.Context, opts CrucibleOpts) (*CrucibleResult, error)
RunCrucible executes pass 2 inside the pass-1 candidate image. It streams stdout/stderr directly — pass-2 output is the canonical build log.
type CrucibleVerification ¶
type CrucibleVerification struct {
ArtifactChecks []CrucibleCheck
ExecutionChecks []CrucibleCheck
TrustLevel string
}
CrucibleVerification holds the complete verification result.
func VerifyCrucible ¶
func VerifyCrucible(ctx context.Context, pass1Image, pass2Image string) (*CrucibleVerification, error)
VerifyCrucible compares pass-1 and pass-2 images to determine trust level. Uses promoted identity helpers from image_inspect.go for all inspections.
func (*CrucibleVerification) HasHardFailure ¶
func (cv *CrucibleVerification) HasHardFailure() bool
HasHardFailure returns true if any check is a hard failure.
type InventoryResult ¶
type InventoryResult struct {
BaseImages []PackageInfo // normalized primary base image versions from FROM refs
Lineage []PackageInfo // inferred distro lineage from tag suffixes
Packages []PackageInfo // all discovered packages
Args []ArgDecl // ARG declarations with defaults
}
InventoryResult holds all extracted packages grouped by manager.
func ExtractInventory ¶
func ExtractInventory(dockerfilePath string) (*InventoryResult, error)
ExtractInventory parses a Dockerfile and extracts package inventory. This is the main entry point for inventory extraction.
type PackageInfo ¶
type PackageInfo struct {
Name string // package name
Version string // version if known, empty otherwise
Pinned bool // true if version is explicitly pinned
Source string // broad category: "dockerfile", "dockerfile_arg", "base_image"
SourceRef string // narrow origin: the actual instruction or ARG declaration
Manager string // package manager name: "apk", "pip", "npm", "go", "galaxy", "binary", "base", "apt"
Confidence string // "inferred" for heuristic-derived items, empty for authoritative
URL string // download URL for binary installs
Stage string // stage name from "AS <name>", empty for unnamed stages
Final bool // true if this is from the last FROM stage (the shipped image)
}
PackageInfo represents a discovered package/dependency from Dockerfile analysis. This is the build package's internal model — manifest generation converts these to schema types. Keeps the build package reusable without circular coupling.
type PushError ¶
type PushError struct {
Tag string // fully qualified ref that failed
ExitCode int // process exit code (1 if not determinable)
Stderr string // stderr from the failed push only
Cause error // underlying exec error
}
PushError is the structured error from a failed docker push. Implements error — PushTags return type stays (int, error).
type Request ¶
type Request struct {
Context context.Context
RootDir string
Config *config.Config
Verbose bool
Local bool
Platforms []string
Tags []string
Target string
BuildID string
SkipLint bool
DryRun bool
BuildMode string
ConfigFile string // forwarded by crucible to inner build
Stdout io.Writer
Stderr io.Writer
}
Request holds all inputs for a docker build pipeline run. Every field that previously came from a package-global variable is explicitly passed here, eliminating hidden coupling to cobra flag state.
type VerificationArtifact ¶
type VerificationArtifact struct {
Tag string // e.g. "stagefreight/crucible-verify:<run-id>"
}
VerificationArtifact encapsulates the extra --tag + --local added to pass 2 for post-build verification. Centralizes the concept so it isn't ad-hoc flag munging scattered across call sites.
func (VerificationArtifact) AppendFlags ¶
func (va VerificationArtifact) AppendFlags() []string
AppendFlags returns the flags needed to produce the verification artifact.