pub fn find_context_zimagefile(context: &Path) -> Result<Option<PathBuf>>Expand description
Discover a ZImagefile in the build context directory.
Resolution order matches user intuition:
- Literal
ZImagefilein the context root — by far the most common layout (e.g. a one-image repo whose build file is justZImagefile). - Any
ZImagefile.<suffix>glob — the convention this repo itself uses (ZImagefile.zlayer-node,ZImagefile.zlayer-manager, …). If exactly one match exists, use it. - Zero matches → return
Ok(None)so the caller falls through to the Dockerfile path. - Multiple
ZImagefile.<suffix>matches and no literalZImagefile→ ambiguous; return an error telling the user to pick one with-z <path>. We don’t silently pick “the first one” because that’s a correctness landmine — a repo withZImagefile.prodandZImagefile.devwould otherwise build whichever entry the filesystem listed first.
The lookup is sync (a single read_dir) and doesn’t follow symlinks
beyond the standard DirEntry::file_type() semantics. Errors reading the
directory propagate so the caller can attach a BuildError::ContextRead.
§Errors
Propagates the read_dir error when the context directory exists but
cannot be read (a missing directory yields Ok(None), not an error).