MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / load_dockerignore

Function load_dockerignore

crates/openshell-bootstrap/src/build.rs:340–363  ·  view source on GitHub ↗

Load and parse a `.dockerignore` file from the context directory. Returns an empty list if no `.dockerignore` exists.

(context_dir: &Path)

Source from the content-addressed store, hash-verified

338///
339/// Returns an empty list if no `.dockerignore` exists.
340fn load_dockerignore(context_dir: &Path) -> Vec<IgnorePattern> {
341 let dockerignore_path = context_dir.join(".dockerignore");
342 let Ok(contents) = std::fs::read_to_string(&dockerignore_path) else {
343 return Vec::new();
344 };
345
346 contents
347 .lines()
348 .map(str::trim)
349 .filter(|line| !line.is_empty() && !line.starts_with('#'))
350 .map(|line| {
351 line.strip_prefix('!').map_or_else(
352 || IgnorePattern {
353 pattern: line.to_string(),
354 negated: false,
355 },
356 |rest| IgnorePattern {
357 pattern: rest.trim().to_string(),
358 negated: true,
359 },
360 )
361 })
362 .collect()
363}
364
365/// Check whether a relative path should be ignored based on `.dockerignore` patterns.
366///

Callers 1

create_build_context_tarFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected