pub enum Instruction {
Show 17 variants
Add {
checksum: Option<String>,
chown: Option<String>,
chmod: Option<String>,
link: Option<String>,
sources: Vec<String>,
destination: String,
},
Arg(BTreeMap<String, Option<String>>),
Cmd(Vec<String>),
Comment(String),
Copy {
from: Option<String>,
chown: Option<String>,
chmod: Option<String>,
link: Option<String>,
sources: Vec<String>,
destination: String,
},
Empty {},
Entrypoint(Vec<String>),
Env(BTreeMap<String, String>),
Expose {
ports: Vec<String>,
},
From {
platform: Option<String>,
image: String,
alias: Option<String>,
},
Label(BTreeMap<String, String>),
Run {
mount: Option<String>,
network: Option<String>,
security: Option<String>,
command: Vec<String>,
heredoc: Option<Vec<String>>,
},
Shell(Vec<String>),
Stopsignal {
signal: String,
},
User {
user: String,
group: Option<String>,
},
Volume {
mounts: Vec<String>,
},
Workdir {
path: String,
},
}Expand description
This enum represents available instructions in a Dockerfile and their associated data.
Variants§
Add
ADD Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let add = Instruction::Add {
checksum: None,
chown: None,
chmod: None,
link: None,
sources: Vec::from([String::from("source1"), String::from("source2")]),
destination: String::from("/destination"),
};Fields
Arg(BTreeMap<String, Option<String>>)
ARG Dockerfile instruction.
§Example
use std::collections::BTreeMap;
use dockerfile_parser_rs::Instruction;
let arg = Instruction::Arg(BTreeMap::from([
(String::from("ARG1"), Some(String::from("value1"))),
(String::from("ARG2"), None),
]));Cmd(Vec<String>)
CMD Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let cmd = Instruction::Cmd(Vec::from([
String::from("echo"),
String::from("Hello, World!"),
]));Comment(String)
A comment.
§Example
use dockerfile_parser_rs::Instruction;
let comment = Instruction::Comment(String::from("# This is a comment"));Copy
COPY Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let copy = Instruction::Copy {
from: Some(String::from("builder")),
chown: None,
chmod: None,
link: None,
sources: Vec::from([String::from("source1"), String::from("source2")]),
destination: String::from("/destination"),
};Fields
Empty
Entrypoint(Vec<String>)
ENTRYPOINT Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let entrypoint = Instruction::Entrypoint(Vec::from([String::from("entrypoint.sh")]));Env(BTreeMap<String, String>)
ENV Dockerfile instruction.
§Example
use std::collections::BTreeMap;
use dockerfile_parser_rs::Instruction;
let env = Instruction::Env(BTreeMap::from([
(String::from("ENV1"), String::from("value1")),
(String::from("ENV2"), String::from("value2")),
]));Expose
EXPOSE Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let expose = Instruction::Expose {
ports: Vec::from([String::from("8080")]),
};From
FROM Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let from = Instruction::From {
platform: Some(String::from("linux/amd64")),
image: String::from("docker.io/library/fedora:latest"),
alias: Some(String::from("builder")),
};Label(BTreeMap<String, String>)
LABEL Dockerfile instruction.
§Example
use std::collections::BTreeMap;
use dockerfile_parser_rs::Instruction;
let label = Instruction::Label(BTreeMap::from([
(String::from("version"), String::from("1.0")),
(String::from("maintainer"), String::from("John Doe")),
]));Run
RUN Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let run = Instruction::Run {
mount: None,
network: None,
security: None,
command: Vec::from([String::from("<<EOF")]),
heredoc: Some(Vec::from([
String::from("dnf upgrade -y"),
String::from("dnf install -y rustup"),
String::from("EOF"),
])),
};Fields
Shell(Vec<String>)
SHELL Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let shell = Instruction::Shell(Vec::from([String::from("/bin/sh"), String::from("-c")]));Stopsignal
STOPSIGNAL Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let stopsignal = Instruction::Stopsignal {
signal: String::from("SIGTERM"),
};User
USER Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let user = Instruction::User {
user: String::from("1001"),
group: None,
};Volume
VOLUME Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let volume = Instruction::Volume {
mounts: Vec::from([String::from("/data")]),
};Workdir
WORKDIR Dockerfile instruction.
§Example
use dockerfile_parser_rs::Instruction;
let workdir = Instruction::Workdir {
path: String::from("/app"),
};Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a duplicate 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 Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Instruction
impl Display for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
Source§impl Serialize for Instruction
impl Serialize for Instruction
impl Eq for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnsafeUnpin for Instruction
impl UnwindSafe for Instruction
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