Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from facility to metro lingo #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@

config = lib.mkOption {
type = lib.types.submodule {
options.facilities = lib.mkOption {
type = with lib.types; listOf str;
options.metro = lib.mkOption {
type = lib.types.str;
description = lib.mdDoc ''
The facilities the instances are allowed to be created in.
Metro code or ID of where the instance should be provisioned in.
'';
example = "any";
};
options.tags = lib.mkOption {
type = with lib.types; listOf str;
Expand Down
6 changes: 3 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct Device {
#[derive(Serialize, Debug)]
struct CreateDeviceRequest {
always_pxe: bool,
facility: Vec<String>,
metro: String,
hostname: String,
ipxe_script_url: String,
operating_system: String,
Expand All @@ -62,7 +62,7 @@ pub async fn create_device(
equinix_project_id: &str,
plan: HardwarePlan,
tags: &[String],
facilities: &[String],
metro: &str,
) -> Result<Device> {
let raw = http_client
.post(format!(
Expand All @@ -78,7 +78,7 @@ pub async fn create_device(
spot_instance: true,
spot_price_max: plan.bid,
tags: tags.to_vec(),
facility: facilities.to_vec(),
metro: metro.into(),
})
.header(ACCEPT, "application/json")
.header(CONTENT_TYPE, "application/json")
Expand Down
8 changes: 3 additions & 5 deletions src/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ type CategoryMap = HashMap<System, HashMap<JobSize, HardwareCategory>>;
pub struct Config {
categories: CategoryMap,
tags: Vec<String>,
facilities: Vec<String>,
metro: String,
}

pub struct DesiredHardwareConfig {
pub plans: Vec<HardwarePlan>,
pub tags: Vec<String>,
pub facilities: Vec<String>,
pub metro: String,
}

pub fn parse_config_file(file: &Path) -> Result<Config> {
Expand Down Expand Up @@ -119,12 +119,10 @@ pub async fn get_desired_hardware(

let mut tags = config.tags;
tags.dedup();
let mut facilities = config.facilities;
facilities.dedup();

Ok(DesiredHardwareConfig {
plans: desired_hardware,
tags,
facilities,
metro: config.metro,
})
}
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Cli {
prometheus_root: String,

/// A JSON description of machines and their Nix system types and job sizes, and the tags and
/// facilities with which to create the machines.
/// metro with which to create the machines.
#[clap(long, required = true)]
config_file: PathBuf,
}
Expand Down Expand Up @@ -111,7 +111,7 @@ async fn real_main(
&equinix_project_id,
desired.clone(),
&desired_hardware.tags,
&desired_hardware.facilities,
&desired_hardware.metro,
)
.await?;
}
Expand Down
Loading