pub struct DofigenContext {
pub offline: bool,
pub update_file_resources: bool,
pub update_url_resources: bool,
pub update_docker_tags: bool,
pub display_updates: bool,
pub no_default_labels: bool,
/* private fields */
}
Expand description
The representation of the Dofigen execution context
Fields§
§offline: bool
§update_file_resources: bool
§update_url_resources: bool
§display_updates: bool
§no_default_labels: bool
Implementations§
Source§impl DofigenContext
impl DofigenContext
pub fn image_updates( &self, previous: &DofigenContext, ) -> Vec<UpdateCommand<ImageName, DockerTag>>
pub fn resource_updates( &self, previous: &DofigenContext, ) -> Vec<UpdateCommand<Resource, ResourceVersion>>
Sourcepub fn parse_from_string(&mut self, input: &str) -> Result<Dofigen>
pub fn parse_from_string(&mut self, input: &str) -> Result<Dofigen>
Parse an Dofigen from a string.
§Examples
Basic struct
use dofigen_lib::*;
use pretty_assertions_sorted::assert_eq_sorted;
let yaml = "
fromImage:
path: ubuntu
";
let image: Dofigen = DofigenContext::new().parse_from_string(yaml).unwrap();
assert_eq_sorted!(
image,
Dofigen {
stage: Stage {
from: ImageName {
path: String::from("ubuntu"),
..Default::default()
}.into(),
..Default::default()
},
..Default::default()
}
);
Advanced image with builders and artifacts
use dofigen_lib::*;
use pretty_assertions_sorted::assert_eq_sorted;
use std::collections::HashMap;
let yaml = r#"
builders:
builder:
fromImage:
path: ekidd/rust-musl-builder
copy:
- paths: ["*"]
run:
- cargo build --release
fromImage:
path: ubuntu
copy:
- fromBuilder: builder
paths:
- /home/rust/src/target/x86_64-unknown-linux-musl/release/template-rust
target: /app
"#;
let image: Dofigen = DofigenContext::new().parse_from_string(yaml).unwrap();
assert_eq_sorted!(
image,
Dofigen {
builders: HashMap::from([
("builder".to_string(), Stage {
from: ImageName { path: "ekidd/rust-musl-builder".into(), ..Default::default() }.into(),
copy: vec![CopyResource::Copy(Copy{paths: vec!["*".into()].into(), ..Default::default()}).into()].into(),
run: Run {
run: vec!["cargo build --release".parse().unwrap()].into(),
..Default::default()
},
..Default::default()
}),
]),
stage: Stage {
from: ImageName {
path: "ubuntu".into(),
..Default::default()
}.into(),
copy: vec![CopyResource::Copy(Copy{
from: FromContext::FromBuilder(String::from("builder")),
paths: vec![String::from(
"/home/rust/src/target/x86_64-unknown-linux-musl/release/template-rust"
)],
options: CopyOptions {
target: Some(String::from("/app")),
..Default::default()
},
..Default::default()
})].into(),
..Default::default()
},
..Default::default()
}
);
Sourcepub fn parse_from_reader<R: Read>(&mut self, reader: R) -> Result<Dofigen>
pub fn parse_from_reader<R: Read>(&mut self, reader: R) -> Result<Dofigen>
Parse an Dofigen from an IO stream.
§Examples
Basic struct
use dofigen_lib::*;
use pretty_assertions_sorted::assert_eq_sorted;
let yaml = "
fromImage:
path: ubuntu
";
let image: Dofigen = DofigenContext::new().parse_from_reader(yaml.as_bytes()).unwrap();
assert_eq_sorted!(
image,
Dofigen {
stage: Stage {
from: ImageName {
path: String::from("ubuntu"),
..Default::default()
}.into(),
..Default::default()
},
..Default::default()
}
);
Advanced image with builders and artifacts
use dofigen_lib::*;
use pretty_assertions_sorted::assert_eq_sorted;
use std::collections::HashMap;
let yaml = r#"
builders:
builder:
fromImage:
path: ekidd/rust-musl-builder
copy:
- paths: ["*"]
run:
- cargo build --release
fromImage:
path: ubuntu
copy:
- fromBuilder: builder
paths:
- /home/rust/src/target/x86_64-unknown-linux-musl/release/template-rust
target: /app
"#;
let image: Dofigen = DofigenContext::new().parse_from_reader(yaml.as_bytes()).unwrap();
assert_eq_sorted!(
image,
Dofigen {
builders: HashMap::from([
("builder".to_string(), Stage {
from: ImageName { path: "ekidd/rust-musl-builder".into(), ..Default::default() }.into(),
copy: vec![CopyResource::Copy(Copy{paths: vec!["*".into()].into(), ..Default::default()}).into()].into(),
run: Run {
run: vec!["cargo build --release".parse().unwrap()].into(),
..Default::default()
},
..Default::default()
}),
]),
stage: Stage {
from: ImageName {
path: String::from("ubuntu"),
..Default::default()
}.into(),
copy: vec![CopyResource::Copy(Copy {
from: FromContext::FromBuilder(String::from("builder")),
paths: vec![String::from(
"/home/rust/src/target/x86_64-unknown-linux-musl/release/template-rust"
)],
options: CopyOptions {
target: Some(String::from("/app")),
..Default::default()
},
..Default::default()
})].into(),
..Default::default()
},
..Default::default()
}
);
Sourcepub fn parse_from_resource(&mut self, resource: Resource) -> Result<Dofigen>
pub fn parse_from_resource(&mut self, resource: Resource) -> Result<Dofigen>
Parse an Dofigen from a Resource (File or Url)
§Example
use dofigen_lib::*;
use pretty_assertions_sorted::assert_eq_sorted;
use std::path::PathBuf;
let dofigen: Dofigen = DofigenContext::new().parse_from_resource(Resource::File(PathBuf::from("tests/cases/simple.yml"))).unwrap();
assert_eq_sorted!(
dofigen,
Dofigen {
stage: Stage {
from: ImageName {
path: String::from("alpine"),
..Default::default()
}.into(),
..Default::default()
},
..Default::default()
}
);
pub fn clean_unused(&mut self)
pub fn new() -> Self
pub fn from( resources: HashMap<Resource, ResourceVersion>, images: HashMap<ImageName, DockerTag>, ) -> Self
Auto Trait Implementations§
impl Freeze for DofigenContext
impl RefUnwindSafe for DofigenContext
impl Send for DofigenContext
impl Sync for DofigenContext
impl Unpin for DofigenContext
impl UnwindSafe for DofigenContext
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