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: String
The 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§
Source§impl 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§
Source§impl Clone for Dockerfile
impl Clone for Dockerfile
Source§fn clone(&self) -> Dockerfile
fn clone(&self) -> Dockerfile
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Dockerfile
impl Debug for Dockerfile
Source§impl FromStr for Dockerfile
impl FromStr for Dockerfile
Source§impl PartialEq for Dockerfile
impl PartialEq for Dockerfile
impl StructuralPartialEq for Dockerfile
Auto Trait Implementations§
impl Freeze for Dockerfile
impl RefUnwindSafe for Dockerfile
impl Send for Dockerfile
impl Sync for Dockerfile
impl Unpin for Dockerfile
impl UnwindSafe for Dockerfile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more