Struct dockerfile_parser::Dockerfile
source · [−]pub struct Dockerfile {
pub content: String,
pub global_args: Vec<ArgInstruction>,
pub instructions: Vec<Instruction>,
}Expand description
A parsed Dockerfile.
An ordered list of all instructions is available via instructions, and
individual stages in a multi-stage build may be iterated over using
Dockerfile::iter_stages().
Example
use dockerfile_parser::Dockerfile;
use std::io::Read;
let s = r#"
FROM alpine:3.11
RUN echo "hello world"
"#;
assert_eq!(
Dockerfile::parse(&s).unwrap(),
s.parse::<Dockerfile>().unwrap()
);
assert_eq!(
Dockerfile::parse(&s).unwrap(),
Dockerfile::from_reader(s.as_bytes()).unwrap()
);Fields
content: StringThe raw content of the Dockerfile
global_args: Vec<ArgInstruction>An ordered list of parsed ARG instructions preceding the first FROM
instructions: Vec<Instruction>An ordered list of all parsed instructions, including global_args
Implementations
sourceimpl Dockerfile
impl Dockerfile
sourcepub fn parse(input: &str) -> Result<Dockerfile>
pub fn parse(input: &str) -> Result<Dockerfile>
Parses a Dockerfile from a string.
sourcepub fn from_reader<R>(reader: R) -> Result<Dockerfile> where
R: Read,
pub fn from_reader<R>(reader: R) -> Result<Dockerfile> where
R: Read,
Parses a Dockerfile from a reader.
sourcepub fn stages(&self) -> Stages<'_>
pub fn stages(&self) -> Stages<'_>
Returns a Stages, which splits this Dockerfile into its build stages.
pub fn iter_stages(&self) -> IntoIter<Stage<'_>>
sourcepub fn splicer(&self) -> Splicer
pub fn splicer(&self) -> Splicer
Creates a Splicer for this Dockerfile.
Note that the original input string is needed to actually perform any splicing.
sourcepub fn get_global_arg(&self, name: &str) -> Option<&ArgInstruction>
pub fn get_global_arg(&self, name: &str) -> Option<&ArgInstruction>
Attempts to find a global argument by name. Returns None if no global ARG with the given name exists.
Trait Implementations
sourceimpl Clone for Dockerfile
impl Clone for Dockerfile
sourcefn clone(&self) -> Dockerfile
fn clone(&self) -> Dockerfile
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Dockerfile
impl Debug for Dockerfile
sourceimpl FromStr for Dockerfile
impl FromStr for Dockerfile
sourceimpl PartialEq<Dockerfile> for Dockerfile
impl PartialEq<Dockerfile> for Dockerfile
sourcefn eq(&self, other: &Dockerfile) -> bool
fn eq(&self, other: &Dockerfile) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &Dockerfile) -> bool
fn ne(&self, other: &Dockerfile) -> bool
This method tests for !=.
impl StructuralPartialEq for Dockerfile
Auto Trait Implementations
impl RefUnwindSafe for Dockerfile
impl Send for Dockerfile
impl Sync for Dockerfile
impl Unpin for Dockerfile
impl UnwindSafe for Dockerfile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more