Skip to content

Commit

Permalink
fix: minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pxseu committed Nov 19, 2022
1 parent 70ee372 commit 2bfb314
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/commands/ignite/types.rs
Expand Up @@ -96,7 +96,7 @@ impl From<TierResources> for Resources {
fn from(tier: TierResources) -> Self {
Self {
vcpu: tier.cpu,
ram: format!("{}B", tier.memory),
ram: format!("{}M", tier.memory),
vgpu: vec![],
}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ impl Display for Tier {
} else {
write!(
f,
"{} - {} ({} CPU, {}B ram)",
"{} - {} ({} CPU, {}MB ram)",
self.name, self.description, self.resources.cpu, self.resources.memory
)
}
Expand Down
23 changes: 20 additions & 3 deletions src/commands/ignite/utils.rs
Expand Up @@ -373,8 +373,14 @@ async fn update_config_args(
deployment_config.entrypoint = Some(get_entrypoint_array(&entry));
}

if let Some(policy) = options.config.restart_policy {
deployment_config.restart_policy = Some(policy);
if deployment_config.type_ != Some(ContainerType::Ephemeral) {
if let Some(policy) = options.config.restart_policy {
deployment_config.restart_policy = Some(policy);
} else {
deployment_config.restart_policy = Some(RestartPolicy::OnFailure);
}
} else {
deployment_config.restart_policy = None;
}

Ok((deployment_config.clone(), container_options.clone()))
Expand Down Expand Up @@ -425,6 +431,13 @@ async fn update_config_visual(
.with_prompt("Image name")
.default(deployment_config.image.name.clone())
.show_default(!deployment_config.image.name.is_empty())
.validate_with(|image: &String| -> Result<(), &str> {
if image.is_empty() {
Err("Please specify an image")
} else {
Ok(())
}
})
.interact_text()?
};

Expand Down Expand Up @@ -522,7 +535,9 @@ async fn update_config_visual(

if dialoguer::Confirm::new()
.with_prompt("Do you want to change advanced settings?")
.interact()?
.default(false)
.interact_opt()?
.unwrap_or(false)
{
if deployment_config.type_ != Some(ContainerType::Stateful)
&& dialoguer::Confirm::new()
Expand Down Expand Up @@ -566,6 +581,8 @@ async fn update_config_visual(
deployment_config.restart_policy.clone(),
)?);
}
} else {
deployment_config.restart_policy = Some(RestartPolicy::OnFailure);
}

Ok((deployment_config.clone(), container_options.clone()))
Expand Down

0 comments on commit 2bfb314

Please sign in to comment.