Skip to content

Commit

Permalink
Added import missed in rebase, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Oct 10, 2024
1 parent 4be2271 commit ad42960
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions rust/agama-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use std::{

use crate::show_progress;
use agama_lib::{
base_http_client::BaseHTTPClient, install_settings::InstallSettings,
Store as SettingsStore,
base_http_client::BaseHTTPClient, install_settings::InstallSettings, Store as SettingsStore,
};
use anyhow::anyhow;
use clap::Subcommand;
Expand Down
20 changes: 9 additions & 11 deletions rust/agama-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod progress;
mod questions;

use crate::error::CliError;
use agama_lib::base_http_client::BaseHTTPClient;
use agama_lib::{
error::ServiceError, manager::ManagerClient, progress::ProgressMonitor, transfer::Transfer,
};
Expand All @@ -50,7 +51,7 @@ use std::{

/// Agama's CLI global options
#[derive(Args)]
struct GlobalOpts {
pub struct GlobalOpts {
#[clap(long, default_value = "http://localhost/api")]
/// uri pointing to agama's remote api. If not provided, default https://localhost/api is
/// used
Expand Down Expand Up @@ -154,10 +155,10 @@ async fn build_manager<'a>() -> anyhow::Result<ManagerClient<'a>> {

#[derive(PartialEq)]
enum InsecureApi {
Secure, // Remote api is secure
Insecure, // Remote api is insecure - e.g. self-signed certificate
Forbidden, // Remote api is insecure and its use is forbidden (e.g. user decided not to use it)
Unreachable // Remote api is unrecheable
Secure, // Remote api is secure
Insecure, // Remote api is insecure - e.g. self-signed certificate
Forbidden, // Remote api is insecure and its use is forbidden (e.g. user decided not to use it)
Unreachable, // Remote api is unrecheable
}

/// Returns if insecure connection to remote api server is required and user allowed that
Expand All @@ -181,7 +182,8 @@ async fn check_remote_api(api_url: String) -> Result<InsecureApi, ServiceError>
if Confirm::new("Remote API uses self-signed certificate. Do you want to continue?")
.with_default(false)
.prompt()
.map_err(|_| err)? {
.map_err(|_| err)?
{
Ok(InsecureApi::Insecure)
} else {
Ok(InsecureApi::Forbidden)
Expand All @@ -192,11 +194,7 @@ async fn check_remote_api(api_url: String) -> Result<InsecureApi, ServiceError>

pub async fn run_command(cli: Cli) -> Result<(), ServiceError> {
// somehow check whether we need to ask user for self-signed certificate acceptance
let api_url = cli
.opts
.api
.trim_end_matches('/')
.to_string();
let api_url = cli.opts.api.trim_end_matches('/').to_string();
let insecure = check_remote_api(api_url.clone()).await? == InsecureApi::Insecure;

// we need to distinguish commands on those which assume that authentication JWT is already
Expand Down
3 changes: 2 additions & 1 deletion rust/agama-lib/src/base_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ impl BaseHTTPClient {
Self {
client: reqwest::Client::builder()
.danger_accept_invalid_certs(insecure)
.build().unwrap_or(default_client),
.build()
.unwrap_or(default_client),
base_url: API_URL.to_owned(),
}
}
Expand Down
4 changes: 1 addition & 3 deletions rust/agama-lib/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ pub struct Store {
}

impl Store {
pub async fn new(
http_client: BaseHTTPClient,
) -> Result<Store, ServiceError> {
pub async fn new(http_client: BaseHTTPClient) -> Result<Store, ServiceError> {
Ok(Self {
localization: LocalizationStore::new(http_client.clone())?,
users: UsersStore::new(http_client.clone())?,
Expand Down
2 changes: 1 addition & 1 deletion service/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
agama-yast (10)
agama-yast (10.devel153)
cfa (~> 1.0.2)
cfa_grub2 (~> 2.0.0)
cheetah (~> 1.0.0)
Expand Down

0 comments on commit ad42960

Please sign in to comment.