Enum Instruction

Source
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

§checksum: Option<String>
§sources: Vec<String>
§destination: String
§

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

§sources: Vec<String>
§destination: String
§

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")]),
};

Fields

§ports: Vec<String>
§

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")),
};

Fields

§platform: Option<String>
§image: String
§

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

§network: Option<String>
§security: Option<String>
§command: Vec<String>
§heredoc: Option<Vec<String>>
§

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"),
};

Fields

§signal: String
§

User

Represents a USER instruction in the Dockerfile.

§Example
use dockerfile_parser_rs::Instruction;

let user = Instruction::User {
    user: String::from("1001"),
    group: None,
};

Fields

§user: String
§

Volume

Represents a VOLUME instruction in the Dockerfile.

§Example
use dockerfile_parser_rs::Instruction;

let volume = Instruction::Volume {
    mounts: Vec::from([String::from("/data")]),
};

Fields

§mounts: Vec<String>
§

Workdir

Represents a WORKDIR instruction in the Dockerfile.

§Example
use dockerfile_parser_rs::Instruction;

let workdir = Instruction::Workdir {
    path: String::from("/app"),
};

Fields

§path: String

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Instruction

Source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.