Skip to content

Commit

Permalink
Merge pull request #1766 from golemfactory/0.9-presetname
Browse files Browse the repository at this point in the history
[golemsp] Fix settings set
  • Loading branch information
jiivan authored Dec 16, 2021
2 parents bacecba + b745f72 commit d722a0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
11 changes: 5 additions & 6 deletions golem_cli/src/command/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use serde::Deserialize;
use std::{collections::BTreeMap, process::Stdio};
use tokio::process::{Child, Command};

use ya_core_model::payment::local::NetworkName;
pub use ya_provider::GlobalsState as ProviderConfig;

use crate::command::NETWORK_GROUP_MAP;
use crate::command::{NetworkGroup, NETWORK_GROUP_MAP};
use crate::setup::RunConfig;

const CLASSIC_RUNTIMES: &'static [&'static str] = &["wasmtime", "vm"];
Expand Down Expand Up @@ -50,7 +49,7 @@ impl YaProviderCommand {
pub async fn set_config(
self,
config: &ProviderConfig,
networks: &Vec<NetworkName>,
network_group: &NetworkGroup,
) -> anyhow::Result<()> {
let mut cmd = self.cmd;

Expand All @@ -66,7 +65,7 @@ impl YaProviderCommand {
if let Some(account) = &config.account {
cmd.args(&["--account", &account.to_string()]);
}
for n in networks.iter() {
for n in NETWORK_GROUP_MAP[&network_group].iter() {
cmd.args(&["--payment-network", &n.to_string()]);
}

Expand Down Expand Up @@ -151,7 +150,7 @@ impl YaProviderCommand {
disk: Option<f64>,
) -> anyhow::Result<()> {
let cmd = &mut self.cmd;
cmd.arg("profile").arg("update").arg(name);
cmd.arg("profile").arg("update").arg("--name").arg(name);
if let Some(cores) = cores {
cmd.arg("--cpu-threads").arg(cores.to_string());
}
Expand Down Expand Up @@ -183,7 +182,7 @@ impl YaProviderCommand {
cmd.arg("--price").arg(format!("Init price={}", initial));
}
for runtime_name in CLASSIC_RUNTIMES {
cmd.arg(format!("--name {}", runtime_name));
cmd.arg("--name").arg(runtime_name);
}
self.exec_no_output().await
}
Expand Down
13 changes: 7 additions & 6 deletions golem_cli/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::command::{ProviderConfig, YaCommand};
use crate::{
command::{ProviderConfig, YaCommand},
setup::ConfigAccount,
};
use anyhow::Result;
use byte_unit::{Byte as Bytes, ByteUnit};
use structopt::StructOpt;

use ya_provider::ReceiverAccount;

/// Manage settings
#[derive(StructOpt, Debug)]
pub struct Settings {
Expand Down Expand Up @@ -36,7 +37,7 @@ pub struct Settings {
cpu_per_hour: Option<f64>,

#[structopt(flatten)]
pub account: ReceiverAccount,
pub account: ConfigAccount,
}

pub async fn run(settings: Settings) -> Result</*exit code*/ i32> {
Expand All @@ -50,7 +51,7 @@ pub async fn run(settings: Settings) -> Result</*exit code*/ i32> {
node_name: settings.node_name,
..ProviderConfig::default()
},
&settings.account.networks,
&settings.account.network,
)
.await?;
}
Expand All @@ -62,7 +63,7 @@ pub async fn run(settings: Settings) -> Result</*exit code*/ i32> {
account: settings.account.account,
..ProviderConfig::default()
},
&settings.account.networks,
&settings.account.network,
)
.await?;
}
Expand Down
4 changes: 2 additions & 2 deletions golem_cli/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use strum::VariantNames;

use ya_core_model::NodeId;

use crate::command::NetworkGroup;
use crate::command::UsageDef;
use crate::command::{NetworkGroup, NETWORK_GROUP_MAP};
use crate::terminal::clear_stdin;

const OLD_DEFAULT_SUBNETS: &[&'static str] = &["community", "community.3", "community.4"];
Expand Down Expand Up @@ -147,7 +147,7 @@ pub async fn setup(run_config: &RunConfig, force: bool) -> Result<i32> {
config.node_name = Some(node_name);
config.subnet = Some(subnet);
cmd.ya_provider()?
.set_config(&config, &NETWORK_GROUP_MAP[&run_config.account.network])
.set_config(&config, &run_config.account.network)
.await?;
}

Expand Down

0 comments on commit d722a0f

Please sign in to comment.