Skip to main content

DockerfileEnvironment

Trait DockerfileEnvironment 

Source
pub trait DockerfileEnvironment {
    // Required methods
    fn read_dockerfile(&self, path: &str) -> Result<String, String>;
    fn resolve_build_arg(&self, name: &str) -> Option<String>;
}
Expand description

Abstract IO environment for the dockerfile interpreter. The only side effect this domain performs is reading Dockerfile text and resolving build-arg values from environment — both behind this trait so tests use a mock and production wraps real filesystem/env access.

Required Methods§

Source

fn read_dockerfile(&self, path: &str) -> Result<String, String>

Read the Dockerfile at path. In the canonical-instance path the “path” is just the spec’s name and the text comes from the authored spec itself; a real consumer wraps std::fs::read_to_string.

§Errors

Implementations return their own error which the interpreter converts to SpecError::Interp { phase: "read-dockerfile" }.

Source

fn resolve_build_arg(&self, name: &str) -> Option<String>

Resolve a build-arg’s value from the environment (e.g. --build-arg TARGETARCH=amd64). Returns None on miss — the interpreter falls back to the ARG’s declared default, or leaves it unresolved if neither exists.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§