diff --git a/rust/agama-cli/src/config.rs b/rust/agama-cli/src/config.rs index ff5ca49eb7..291ea08f0e 100644 --- a/rust/agama-cli/src/config.rs +++ b/rust/agama-cli/src/config.rs @@ -117,7 +117,7 @@ pub async fn run(subcommand: ConfigCommands, opts: GlobalOpts) -> anyhow::Result destination.write(&json)?; eprintln!(); - validate(&http_client, CliInput::Full(json.clone())).await?; + validate(&http_client, CliInput::Full(json.clone()), false).await?; Ok(()) } ConfigCommands::Load { url_or_path } => { @@ -125,7 +125,7 @@ pub async fn run(subcommand: ConfigCommands, opts: GlobalOpts) -> anyhow::Result let store = SettingsStore::new(http_client.clone()).await?; let url_or_path = url_or_path.unwrap_or(CliInput::Stdin); let contents = url_or_path.read_to_string(opts.insecure)?; - let valid = validate(&http_client, CliInput::Full(contents.clone())).await?; + let valid = validate(&http_client, CliInput::Full(contents.clone()), false).await?; if matches!(valid, ValidationOutcome::Valid) { let result = @@ -141,7 +141,7 @@ pub async fn run(subcommand: ConfigCommands, opts: GlobalOpts) -> anyhow::Result ConfigCommands::Validate { url_or_path, local } => { let _ = if !local { let (http_client, _monitor) = build_clients(api_url, opts.insecure).await?; - validate(&http_client, url_or_path).await + validate(&http_client, url_or_path, false).await } else { validate_local(url_or_path, opts.insecure) }; @@ -193,24 +193,19 @@ fn validate_local(url_or_path: CliInput, insecure: bool) -> anyhow::Result anyhow::Result { let request = url_or_path.to_map(); let validity = ProfileHTTPClient::new(client.clone()) .validate(&request) .await?; - Ok(validity) -} - -async fn validate( - client: &BaseHTTPClient, - url_or_path: CliInput, -) -> anyhow::Result { - let validity = validate_silently(client, url_or_path).await?; - let _ = validation_msg(&validity); + if !silent { + let _ = validation_msg(&validity); + } Ok(validity) } @@ -284,7 +279,7 @@ async fn generate( from_json_or_jsonnet(client, url_or_path, insecure).await? }; - let validity = validate_silently(client, CliInput::Full(profile_json.clone())).await?; + let validity = validate(client, CliInput::Full(profile_json.clone()), true).await?; if matches!(validity, ValidationOutcome::NotValid(_)) { println!("{}", &profile_json); @@ -298,7 +293,7 @@ async fn generate( let config_json = serde_json::to_string_pretty(&model)?; println!("{}", &config_json); - let validity = validate(client, CliInput::Full(config_json.clone())).await?; + let validity = validate(client, CliInput::Full(config_json.clone()), false).await?; if matches!(validity, ValidationOutcome::NotValid(_)) { eprintln!( @@ -365,7 +360,7 @@ async fn edit( // FIXME: invalid profile still gets loaded let contents = std::fs::read_to_string(&path).context(format!("Reading from file {:?}", path))?; - validate(&http_client, CliInput::Full(contents)).await?; + validate(&http_client, CliInput::Full(contents), false).await?; return Ok(InstallSettings::from_file( path, &InstallationContext::from_env()?, diff --git a/rust/agama-lib/src/profile/http_client.rs b/rust/agama-lib/src/profile/http_client.rs index 3cddc02fc9..be05f1d464 100644 --- a/rust/agama-lib/src/profile/http_client.rs +++ b/rust/agama-lib/src/profile/http_client.rs @@ -52,7 +52,9 @@ impl ProfileHTTPClient { /// to our web backend. /// Return well-formed Agama JSON on success. pub async fn from_autoyast(&self, url: &Uri) -> anyhow::Result { - let map = HashMap::new().insert(String::from("url"), url.to_string()); + let mut map = HashMap::new(); + + map.insert(String::from("url"), url.to_string()); // FIXME: how to escape it? let output: Box = diff --git a/rust/agama-server/src/profile/web.rs b/rust/agama-server/src/profile/web.rs index 1e3304fcd5..4535d8d57d 100644 --- a/rust/agama-server/src/profile/web.rs +++ b/rust/agama-server/src/profile/web.rs @@ -111,7 +111,7 @@ impl ProfileBody { /// Expected format is a HashMap, expecte keys are /// path, url or profile fn from_string(string: String) -> Self { - let map: HashMap = serde_json::from_str(&string).unwrap(); + let map: HashMap = serde_json::from_str(&string).unwrap_or_default(); Self { path: map.get("path").cloned(), diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 361eeb49ee..49634866a2 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Nov 18 08:47:11 UTC 2025 - Michal Filka + +- Fixed passing arguments when "agama config generate" with an + AutoYast profile. +- Removed unhandled unwrap, reorganized validation result reporting + (gh#agama-project/agama#2893). + ------------------------------------------------------------------- Wed Nov 12 15:42:27 UTC 2025 - Imobach Gonzalez Sosa