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
Represents an ADD instruction in the Dockerfile.
§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>>)
Represents an ARG instruction in the Dockerfile.
§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>)
Represents a CMD instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let cmd = Instruction::Cmd(Vec::from([
String::from("echo"),
String::from("Hello, World!"),
]));
Comment(String)
Represents a comment in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let comment = Instruction::Comment(String::from("# This is a comment"));
Copy
Represents a COPY instruction in the Dockerfile.
§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
Represents an empty line in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let empty = Instruction::Empty;
Entrypoint(Vec<String>)
Represents an ENTRYPOINT instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let entrypoint = Instruction::Entrypoint(Vec::from([String::from("entrypoint.sh")]));
Env(BTreeMap<String, String>)
Represents an ENV instruction in the Dockerfile.
§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
Represents an EXPOSE instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let expose = Instruction::Expose {
ports: Vec::from([String::from("8080")]),
};
From
Represents a FROM instruction in the Dockerfile.
§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>)
Represents a LABEL instruction in the Dockerfile.
§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
Represents a RUN instruction in the Dockerfile.
§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>)
Represents a SHELL instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let shell = Instruction::Shell(Vec::from([String::from("/bin/sh"), String::from("-c")]));
Stopsignal
Represents a STOPSIGNAL instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let stopsignal = Instruction::Stopsignal {
signal: String::from("SIGTERM"),
};
User
Represents a USER instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let user = Instruction::User {
user: String::from("1001"),
group: None,
};
Volume
Represents a VOLUME instruction in the Dockerfile.
§Example
use dockerfile_parser_rs::Instruction;
let volume = Instruction::Volume {
mounts: Vec::from([String::from("/data")]),
};
Workdir
Represents a WORKDIR instruction in the Dockerfile.
§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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more