Skip to content

Commit b9b4d71

Browse files
committed
refactor: 'cast' -> 'build'
1 parent 672a42e commit b9b4d71

File tree

17 files changed

+72
-67
lines changed

17 files changed

+72
-67
lines changed

.github/images/overview.png

12.4 KB
Loading

CONTRIBUTING.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ There are currently four crates to know about:
1717

1818
## The metallurgy metaphor
1919

20-
Although end-users could probably ignore it, the internals of `goldboot` use vocabulary
21-
taken from the field of metallurgy.
20+
Although end-users could probably ignore it, the internals of `goldboot` use
21+
vocabulary taken from the field of metallurgy.
2222

2323
#### Foundry
2424

25-
An image foundry is a configuration object that knows how to build goldboot images.
25+
An image foundry is a configuration object that knows how to build goldboot
26+
images.
2627

2728
#### OS
2829

2930
An image mold takes an image source and refines it according to built-in rules.
3031
For example, the `ArchLinux` mold knows how to take Arch Linux install media (in
3132
the form of an ISO) and install it in an automated manner.
3233

33-
#### Casting
34+
#### Building
3435

35-
Casting (or building) is the process that takes image sources and produces
36-
a final goldboot image containing all customizations.
36+
Building is the process that takes image sources and produces a final goldboot
37+
image containing all customizations.
3738

3839
Under the hood, foundries cast images by spawning a Qemu virtual machine and
3940
running one or more image molds against it (via SSH or VNC). Once the virtual
@@ -51,18 +52,19 @@ fabricator runs shell commands on the image which can be useful in many cases.
5152

5253
## Adding new operating systems
5354

54-
If `goldboot` doesn't already support your operating system, it should be possible
55-
to add it relatively easily.
55+
If `goldboot` doesn't already support your operating system, it should be
56+
possible to add it relatively easily.
5657

5758
Start by finding an OS similar to yours in the `goldboot::foundry::os` module.
5859

5960
TODO
6061

6162
## OS maintenance
6263

63-
OS support often need constant maintenance as new upstream releases are made and old
64-
ones are retired. Typically this involves adding new versions and marking some
65-
as deprecated, but occasionally upstream changes may cause breakages for us.
64+
OS support often need constant maintenance as new upstream releases are made and
65+
old ones are retired. Typically this involves adding new versions and marking
66+
some as deprecated, but occasionally upstream changes may cause breakages for
67+
us.
6668

6769
For example, we have a struct that tracks Alpine releases which needs to be
6870
updated about twice per year:
@@ -84,4 +86,5 @@ pub enum AlpineRelease {
8486
```
8587

8688
## Testing
89+
8790
TODO

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ be tweaked to suit your needs. For example:
241241
There are many ways to customize the image, but for now just build it:
242242

243243
```sh
244-
goldboot cast .
244+
goldboot build .
245245
```
246246

247247
Once the build succeeds, the image will be saved to the system's library

goldboot/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ built = { version = "0.8.0", features = [
7676
] }
7777

7878
[features]
79-
default = ["cast", "include_ovmf"]
79+
default = ["build", "include_ovmf"]
8080

8181
# Support for registry server
8282
registry = []
8383

84-
# Support for casting images
85-
cast = [
84+
# Support for building images
85+
build = [
8686
"dep:fatfs",
8787
"dep:fscommon",
8888
"dep:png",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use validator::Validate;
55

66
pub fn run(cmd: super::Commands) -> ExitCode {
77
match cmd {
8-
super::Commands::Cast {
8+
super::Commands::Build {
99
record,
1010
debug,
1111
read_password,
@@ -57,7 +57,7 @@ pub fn run(cmd: super::Commands) -> ExitCode {
5757
// Run the build finally
5858
match foundry.run(output) {
5959
Err(err) => {
60-
error!(error = ?err, "Failed to cast image");
60+
error!(error = ?err, "Failed to build image");
6161
ExitCode::FAILURE
6262
}
6363
_ => ExitCode::SUCCESS,

goldboot/src/cli/cmd/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::foundry::{os::Os, FoundryConfigPath};
1+
use crate::foundry::{FoundryConfigPath, os::Os};
22

3-
pub mod cast;
3+
pub mod build;
44
pub mod deploy;
55
pub mod image;
66
pub mod init;
@@ -9,8 +9,8 @@ pub mod registry;
99

1010
#[derive(clap::Subcommand, Debug)]
1111
pub enum Commands {
12-
/// Cast (build) a new image
13-
Cast {
12+
/// Build a new image
13+
Build {
1414
/// Save a screenshot to ./screenshots after each boot command for
1515
/// debugging
1616
#[clap(long, num_args = 0)]

goldboot/src/foundry/fabricators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub mod exe;
1313
pub mod shell;
1414

1515
/// A `Fabricator` performs some custom operation on an image at the very end of
16-
/// the casting process.
16+
/// the build process.
1717
#[enum_dispatch(Fabricator)]
1818
pub trait Fabricate {
1919
fn run(&self, ssh: &mut SshConnection) -> Result<()>;

goldboot/src/foundry/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use self::qemu::{detect_accel, Accel};
1+
use self::qemu::{Accel, detect_accel};
22
use self::{fabricators::Fabricator, os::Os, sources::ImageSource};
3-
use crate::foundry::os::CastImage;
3+
use crate::foundry::os::BuildImage;
44
use crate::{cli::progress::ProgressBar, library::ImageLibrary};
55

66
use anyhow::Result;
77
use byte_unit::Byte;
8-
use clap::{builder::PossibleValue, ValueEnum};
8+
use clap::{ValueEnum, builder::PossibleValue};
99
use goldboot_image::ImageBuilder;
10-
use goldboot_image::{qcow::Qcow3, ImageArch, ImageHandle};
10+
use goldboot_image::{ImageArch, ImageHandle, qcow::Qcow3};
1111
use rand::Rng;
1212
use ron::ser::PrettyConfig;
1313
use serde::{Deserialize, Serialize};
@@ -240,7 +240,7 @@ impl Foundry {
240240
}
241241
}
242242

243-
/// Manages the image casting process. Multiple workers can run in parallel
243+
/// Manages the image build process. Multiple workers can run in parallel
244244
/// to speed up multiboot configurations.
245245
pub struct FoundryWorker {
246246
pub arch: ImageArch,
@@ -277,12 +277,12 @@ pub struct FoundryWorker {
277277
}
278278

279279
impl FoundryWorker {
280-
/// Run the image casting/building process.
280+
/// Run the image building process.
281281
pub fn run(&mut self) -> Result<()> {
282282
self.start_time = Some(SystemTime::now());
283283
Qcow3::create(&self.qcow_path, self.qcow_size)?;
284284

285-
self.element.os.cast(&self)?;
285+
self.element.os.build(&self)?;
286286
info!(
287287
duration = ?self.start_time.unwrap().elapsed()?,
288288
"Build completed",

goldboot/src/foundry/os/alpine_linux/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ use crate::{
1010
cli::prompt::{Prompt, PromptNew},
1111
enter,
1212
foundry::{
13+
Foundry, FoundryWorker,
1314
options::{hostname::Hostname, unix_account::RootPassword},
1415
qemu::{OsCategory, QemuBuilder},
1516
sources::ImageSource,
16-
Foundry, FoundryWorker,
1717
},
1818
wait, wait_screen_rect,
1919
};
2020

21-
use super::{CastImage, DefaultSource};
21+
use super::{BuildImage, DefaultSource};
2222

2323
/// Produces [Alpine Linux](https://www.alpinelinux.org) images.
2424
#[derive(Clone, Serialize, Deserialize, Validate, Debug, Default)]
@@ -47,8 +47,8 @@ impl Prompt for AlpineLinux {
4747
}
4848
}
4949

50-
impl CastImage for AlpineLinux {
51-
fn cast(&self, worker: &FoundryWorker) -> Result<()> {
50+
impl BuildImage for AlpineLinux {
51+
fn build(&self, worker: &FoundryWorker) -> Result<()> {
5252
let mut qemu = QemuBuilder::new(&worker, OsCategory::Linux)
5353
.source(&worker.element.source)?
5454
.prepare_ssh()?

goldboot/src/foundry/os/arch_linux/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
use super::{CastImage, DefaultSource};
1+
use super::{BuildImage, DefaultSource};
22
use crate::cli::prompt::Prompt;
33
use crate::cli::prompt::PromptNew;
4+
use crate::foundry::Foundry;
45
use crate::foundry::fabricators::Fabricate;
56
use crate::foundry::http::HttpServer;
67
use crate::foundry::options::hostname::Hostname;
78
use crate::foundry::options::unix_account::RootPassword;
89
use crate::foundry::os::arch_linux::archinstall::ArchinstallConfig;
910
use crate::foundry::os::arch_linux::archinstall::ArchinstallCredentials;
1011
use crate::foundry::qemu::{OsCategory, QemuBuilder};
11-
use crate::foundry::Foundry;
1212
use crate::wait;
1313
use crate::{
14-
foundry::{sources::ImageSource, FoundryWorker},
14+
foundry::{FoundryWorker, sources::ImageSource},
1515
wait_screen_rect,
1616
};
17-
use anyhow::bail;
1817
use anyhow::Result;
18+
use anyhow::bail;
1919
use dialoguer::theme::Theme;
2020
use goldboot_image::ImageArch;
2121
use serde::{Deserialize, Serialize};
@@ -55,8 +55,8 @@ impl DefaultSource for ArchLinux {
5555
}
5656
}
5757

58-
impl CastImage for ArchLinux {
59-
fn cast(&self, worker: &FoundryWorker) -> Result<()> {
58+
impl BuildImage for ArchLinux {
59+
fn build(&self, worker: &FoundryWorker) -> Result<()> {
6060
let mut qemu = QemuBuilder::new(&worker, OsCategory::Linux)
6161
.source(&worker.element.source)?
6262
.prepare_ssh()?

0 commit comments

Comments
 (0)