Skip to content
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
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn get_security_url() -> String {
Environment::Staging => "railway-staging.com",
Environment::Dev => "railway-develop.com",
};
format!("https://{}/account/security", host)
format!("https://{host}/account/security")
}

pub(crate) fn auth_failure_error() -> RailwayError {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ pub async fn command(args: Args) -> Result<()> {
}
};
if verbose {
println!("{:?}", type_of_create);
println!("{type_of_create:?}");
}
match type_of_create {
CreateKind::Database(databases) => {
let is_single_db = databases.len() == 1;
for db in databases {
if verbose {
println!("iterating through databases to add: {:?}", db)
println!("iterating through databases to add: {db:?}")
}
deploy::fetch_and_create(
&client,
Expand All @@ -147,7 +147,7 @@ pub async fn command(args: Args) -> Result<()> {
)
.await?;
if verbose {
println!("successfully created {:?}", db)
println!("successfully created {db:?}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub async fn fetch_and_create(
"templateName": details.template.name,
})
};
println!("{}", output);
println!("{output}");
} else if let Some(spinner) = spinner {
let mut msg = format!("🎉 Added {} to project", template_name.green().bold());
if options.should_link && linked_project.service.is_none() && new_service.is_some() {
Expand Down
37 changes: 14 additions & 23 deletions src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,7 @@ async fn configure_command(args: ConfigureArgs) -> Result<()> {
local_dev_config.save(&project_id)?;
println!("{} Removed configuration for '{}'", "✓".green(), name);
} else {
println!(
"{}",
format!("Service '{}' is not configured", name).yellow()
);
println!("{}", format!("Service '{name}' is not configured").yellow());
}
}

Expand Down Expand Up @@ -403,7 +400,7 @@ async fn configure_command(args: ConfigureArgs) -> Result<()> {
);
let suggested = generate_random_port();
let port_input =
prompt_text(&format!("Choose a different port [{}]:", suggested))?;
prompt_text(&format!("Choose a different port [{suggested}]:"))?;
new_config.port = Some(if port_input.is_empty() {
suggested
} else {
Expand Down Expand Up @@ -453,7 +450,7 @@ async fn configure_command(args: ConfigureArgs) -> Result<()> {
.unwrap_or_else(|_| existing.directory.clone());

let input_path = prompt_path_with_default(
&format!("Directory for '{}' (relative to cwd):", name),
&format!("Directory for '{name}' (relative to cwd):"),
&default_dir,
)?;

Expand All @@ -476,8 +473,7 @@ async fn configure_command(args: ConfigureArgs) -> Result<()> {
let railway_port = svc.get_ports().first().map(|&p| p as u16);
let current_port = existing.port.or(railway_port).unwrap_or(DEFAULT_PORT);

let port_input =
prompt_text(&format!("Port for '{}' [{}]:", name, current_port))?;
let port_input = prompt_text(&format!("Port for '{name}' [{current_port}]:"))?;

let mut new_port = if port_input.is_empty() {
current_port
Expand All @@ -501,7 +497,7 @@ async fn configure_command(args: ConfigureArgs) -> Result<()> {
);
let suggested = generate_random_port();
let port_input =
prompt_text(&format!("Choose a different port [{}]:", suggested))?;
prompt_text(&format!("Choose a different port [{suggested}]:"))?;
new_port = if port_input.is_empty() {
suggested
} else {
Expand Down Expand Up @@ -564,7 +560,7 @@ fn show_service_config_menu(name: &str, config: &CodeServiceConfig) -> Result<Co
Err(_) => config.directory.clone(),
};

println!("\n{}", format!("Service '{}'", name).cyan().bold());
println!("\n{}", format!("Service '{name}'").cyan().bold());
println!(" {}: {}", "command".dimmed(), config.command);
println!(" {}: {}", "directory".dimmed(), display_dir);
if let Some(port) = config.port {
Expand All @@ -588,17 +584,13 @@ fn prompt_service_config(
svc: &ServiceInstance,
existing: Option<&CodeServiceConfig>,
) -> Result<CodeServiceConfig> {
println!("\n{}", format!("Configure '{}'", name).cyan().bold());
println!("\n{}", format!("Configure '{name}'").cyan().bold());

let default_command = existing.map(|e| e.command.as_str()).unwrap_or("");
let command = if default_command.is_empty() {
prompt_text(&format!("Dev command for '{}':", name))?
prompt_text(&format!("Dev command for '{name}':"))?
} else {
prompt_text(&format!(
"Dev command for '{}' [{}]:",
name, default_command
))
.map(|s| {
prompt_text(&format!("Dev command for '{name}' [{default_command}]:")).map(|s| {
if s.is_empty() {
default_command.to_string()
} else {
Expand All @@ -618,7 +610,7 @@ fn prompt_service_config(
.unwrap_or_else(|| ".".to_string());

let input_path = prompt_path_with_default(
&format!("Directory for '{}' (relative to current directory):", name),
&format!("Directory for '{name}' (relative to current directory):"),
&default_dir,
)?;

Expand All @@ -635,7 +627,7 @@ fn prompt_service_config(
let default_port = existing.and_then(|e| e.port).or(inferred_port);

let port = if let Some(default) = default_port {
let port_input = prompt_text(&format!("Port for '{}' [{}]:", name, default))?;
let port_input = prompt_text(&format!("Port for '{name}' [{default}]:"))?;
if port_input.is_empty() {
Some(default)
} else {
Expand Down Expand Up @@ -702,7 +694,7 @@ fn prompt_initial_service_setup(
conflicts.join(", ")
);
let suggested = generate_random_port();
let port_input = prompt_text(&format!("Choose a different port [{}]:", suggested))?;
let port_input = prompt_text(&format!("Choose a different port [{suggested}]:"))?;
new_config.port = Some(if port_input.is_empty() {
suggested
} else {
Expand Down Expand Up @@ -799,8 +791,7 @@ fn resolve_port_conflicts(
if let Some(service_id) = service_id {
let suggested = generate_random_port();
let port_input = prompt_text(&format!(
"New port for '{}' (currently {}) [{}]:",
service_name, port, suggested
"New port for '{service_name}' (currently {port}) [{suggested}]:"
))?;

let new_port = if port_input.is_empty() {
Expand Down Expand Up @@ -1306,7 +1297,7 @@ fn build_image_service_compose(
for (vol_id, vol_mount) in &svc.volume_mounts {
if let Some(mount_path) = &vol_mount.mount_path {
let vol_name = volume_name(environment_id, vol_id);
service_volumes.push(format!("{}:{}", vol_name, mount_path));
service_volumes.push(format!("{vol_name}:{mount_path}"));
compose_volumes.insert(vol_name, DockerComposeVolume {});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/environment/changes/build_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn parse_interactive(
}

Ok(vec![(
format!("services.{}.build.buildCommand", service_id),
format!("services.{service_id}.build.buildCommand"),
serde_json::json!(build_command),
)])
}
8 changes: 4 additions & 4 deletions src/commands/environment/changes/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub fn parse_interactive(
};

let mut entries: Vec<PatchEntry> = Vec::new();
let base_path = format!("services.{}.build", service_id);
let base_path = format!("services.{service_id}.build");

match builder_type {
BuilderType::Dockerfile => {
entries.push((
format!("{}.builder", base_path),
format!("{base_path}.builder"),
serde_json::json!("DOCKERFILE"),
));

Expand All @@ -66,15 +66,15 @@ pub fn parse_interactive(
)? {
if !dockerfile_path.is_empty() {
entries.push((
format!("{}.dockerfilePath", base_path),
format!("{base_path}.dockerfilePath"),
serde_json::json!(dockerfile_path),
));
}
}
}
BuilderType::Railpack => {
entries.push((
format!("{}.builder", base_path),
format!("{base_path}.builder"),
serde_json::json!("RAILPACK"),
));
// Railpack doesn't have a config path option
Expand Down
6 changes: 3 additions & 3 deletions src/commands/environment/changes/healthcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn parse_interactive(
let existing_healthcheck_timeout = existing_deploy.and_then(|d| d.healthcheck_timeout);

let mut entries: Vec<PatchEntry> = Vec::new();
let base_path = format!("services.{}.deploy", service_id);
let base_path = format!("services.{service_id}.deploy");

// Health check path
let path_placeholder = existing_healthcheck_path.unwrap_or("None");
Expand All @@ -31,7 +31,7 @@ pub fn parse_interactive(
}

entries.push((
format!("{}.healthcheckPath", base_path),
format!("{base_path}.healthcheckPath"),
serde_json::json!(path),
));

Expand All @@ -57,7 +57,7 @@ pub fn parse_interactive(
match timeout_str.parse::<i64>() {
Ok(timeout) if timeout > 0 => {
entries.push((
format!("{}.healthcheckTimeout", base_path),
format!("{base_path}.healthcheckTimeout"),
serde_json::json!(timeout),
));
break;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/environment/changes/regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ pub fn parse_interactive(

// Convert to patch entries
let mut entries: Vec<PatchEntry> = Vec::new();
let base_path = format!("services.{}.deploy.multiRegionConfig", service_id);
let base_path = format!("services.{service_id}.deploy.multiRegionConfig");

for (region, config) in region_map {
entries.push((format!("{}.{}", base_path, region), config));
entries.push((format!("{base_path}.{region}"), config));
}

Ok(entries)
Expand Down
10 changes: 5 additions & 5 deletions src/commands/environment/changes/restart_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ pub fn parse_interactive(
return Ok(vec![]);
};

let base_path = format!("services.{}.deploy", service_id);
let base_path = format!("services.{service_id}.deploy");

let result = match policy_type {
RestartPolicyType::Never => vec![(
format!("{}.restartPolicyType", base_path),
format!("{base_path}.restartPolicyType"),
serde_json::json!("NEVER"),
)],
RestartPolicyType::Always => vec![(
format!("{}.restartPolicyType", base_path),
format!("{base_path}.restartPolicyType"),
serde_json::json!("ALWAYS"),
)],
RestartPolicyType::OnFailure => {
Expand All @@ -84,11 +84,11 @@ pub fn parse_interactive(
Ok(max_retries) => {
break vec![
(
format!("{}.restartPolicyType", base_path),
format!("{base_path}.restartPolicyType"),
serde_json::json!("ON_FAILURE"),
),
(
format!("{}.restartPolicyMaxRetries", base_path),
format!("{base_path}.restartPolicyMaxRetries"),
serde_json::json!(max_retries),
),
];
Expand Down
14 changes: 7 additions & 7 deletions src/commands/environment/changes/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn parse_interactive(
return Ok(vec![]);
};

let base_path = format!("services.{}.source", service_id);
let base_path = format!("services.{service_id}.source");

let mut entries: Vec<PatchEntry> = Vec::new();

Expand All @@ -72,12 +72,12 @@ pub fn parse_interactive(
break image;
};

entries.push((format!("{}.image", base_path), serde_json::json!(image)));
entries.push((format!("{base_path}.image"), serde_json::json!(image)));
}
SourceType::GitHub => {
// GitHub repo (required)
let repo_placeholder = match (existing_repo, existing_branch) {
(Some(repo), Some(branch)) => format!("{}/{}", repo, branch),
(Some(repo), Some(branch)) => format!("{repo}/{branch}"),
_ => "<owner/repo/branch>".to_string(),
};
let (repo, branch) = loop {
Expand Down Expand Up @@ -106,8 +106,8 @@ pub fn parse_interactive(
break (format!("{}/{}", parts[0], parts[1]), parts[2].to_string());
};

entries.push((format!("{}.repo", base_path), serde_json::json!(repo)));
entries.push((format!("{}.branch", base_path), serde_json::json!(branch)));
entries.push((format!("{base_path}.repo"), serde_json::json!(repo)));
entries.push((format!("{base_path}.branch"), serde_json::json!(branch)));

// Root directory (monorepos)
let root_dir_placeholder = existing_root_dir.unwrap_or("/packages/backend");
Expand All @@ -117,7 +117,7 @@ pub fn parse_interactive(
)? {
if !root_dir.is_empty() {
entries.push((
format!("{}.rootDirectory", base_path),
format!("{base_path}.rootDirectory"),
serde_json::json!(root_dir),
));
}
Expand All @@ -130,7 +130,7 @@ pub fn parse_interactive(
check_suites_default,
)? {
entries.push((
format!("{}.checkSuites", base_path),
format!("{base_path}.checkSuites"),
serde_json::json!(check_suites),
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/environment/changes/start_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn parse_interactive(
}

Ok(vec![(
format!("services.{}.deploy.startCommand", service_id),
format!("services.{service_id}.deploy.startCommand"),
serde_json::json!(start_command),
)])
}
2 changes: 1 addition & 1 deletion src/commands/environment/changes/watch_patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn parse_interactive(
}

Ok(vec![(
format!("services.{}.build.watchPatterns", service_id),
format!("services.{service_id}.build.watchPatterns"),
serde_json::json!(patterns_vec),
)])
}
2 changes: 1 addition & 1 deletion src/commands/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl EnvironmentConfigOptions {

if let Some((key, value)) = key_value.split_once('=') {
configs.push(service.clone());
configs.push(format!("variables.{}.value", key));
configs.push(format!("variables.{key}.value"));
configs.push(value.to_string());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/environment/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn parse_non_interactive_configs(
configured_fields.insert(display_field);

// Build full path with service ID
let full_path = format!("services.{}.{}", service_id, normalized_path);
let full_path = format!("services.{service_id}.{normalized_path}");
entries.push((full_path, json_value));
}

Expand Down Expand Up @@ -230,7 +230,7 @@ pub async fn parse_interactive_configs(
.and_then(|c| c.services.get(service_id));

let selected_changes = prompt_multi_options(
&format!("What do you want to configure for {}?", service_name),
&format!("What do you want to configure for {service_name}?"),
Change::iter().collect(),
)?;

Expand Down
Loading