Skip to content
Merged
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
8 changes: 7 additions & 1 deletion .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
- name: Install required packages
run: zypper --non-interactive install --allow-downgrade
clang-devel
findutils
gcc-c++
git
libopenssl-3-devel
Expand Down Expand Up @@ -117,8 +118,13 @@ jobs:
rust/target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}

- name: Run Clang Format check for the C/C++ zypp bindings
run: make check
working-directory: ./rust/zypp-agama/zypp-agama-sys/c-layer

- name: Run clippy linter
run: cargo clippy
# deny warnings: clippy or rustc warnings will fail the build
run: cargo clippy -- -D warnings
working-directory: ./rust

tests:
Expand Down
1 change: 0 additions & 1 deletion rust/agama-network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ impl NetworkSystemClient {
}

/// Copies the persistent network connections to the target system.

pub async fn install(&self) -> Result<(), NetworkSystemError> {
let (tx, rx) = oneshot::channel();
self.actions.send(Action::Install(tx))?;
Expand Down
43 changes: 20 additions & 23 deletions rust/agama-s390/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,26 @@ impl Starter {

pub async fn start(self) -> Result<Handler<Service>, Error> {
// Create storage_client only if needed.
let (service, storage_client) = if self.dasd.is_none() || self.zfcp.is_none() {
let storage_client = storage_client::service::Starter::new(self.connection.clone())
.start()
.await?;

let dasd = self
.dasd
.unwrap_or(Box::new(dasd::Client::new(storage_client.clone())));

let zfcp = self
.zfcp
.unwrap_or(Box::new(zfcp::Client::new(storage_client.clone())));

let service = Service { dasd, zfcp };

(service, Some(storage_client))
} else {
// Note that unwrap is secure here because the if branch covers any case of None.
let service = Service {
dasd: self.dasd.unwrap(),
zfcp: self.zfcp.unwrap(),
};
(service, None)
let (service, storage_client) = match (self.dasd, self.zfcp) {
(Some(dasd), Some(zfcp)) => {
let service = Service { dasd, zfcp };
(service, None)
}
(dasd_opt, zfcp_opt) => {
let storage_client = storage_client::service::Starter::new(self.connection.clone())
.start()
.await?;

let dasd =
dasd_opt.unwrap_or_else(|| Box::new(dasd::Client::new(storage_client.clone())));

let zfcp =
zfcp_opt.unwrap_or_else(|| Box::new(zfcp::Client::new(storage_client.clone())));

let service = Service { dasd, zfcp };

(service, Some(storage_client))
}
};

let handler = actor::spawn(service);
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-users/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Model {
)));
}

self.set_user_group(user_name);
self.set_user_group(user_name)?;
self.set_user_password(user_name, user_password)?;
self.update_user_fullname(user)
}
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-users/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use agama_utils::{
issue,
};
use async_trait::async_trait;
use gettextrs::{gettext, LocaleCategory};
use gettextrs::gettext;
use tokio::sync::broadcast;

#[derive(thiserror::Error, Debug)]
Expand Down
8 changes: 2 additions & 6 deletions rust/agama-utils/src/api/network/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,10 @@ impl TryFrom<&str> for Status {
}

/// Bond mode
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, utoipa::ToSchema)]
#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq, Clone, Copy, utoipa::ToSchema)]
pub enum BondMode {
#[serde(rename = "balance-rr")]
#[default]
RoundRobin = 0,
#[serde(rename = "active-backup")]
ActiveBackup = 1,
Expand All @@ -643,11 +644,6 @@ pub enum BondMode {
#[serde(rename = "balance-alb")]
BalanceALB = 6,
}
impl Default for BondMode {
fn default() -> Self {
Self::RoundRobin
}
}

impl std::fmt::Display for BondMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion rust/zypp-agama/zypp-agama-sys/c-layer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ clean:

check:
git ls-files | grep -E '\.(c|h|cxx|hxx)$$' | \
xargs --verbose clang-format --style=llvm --dry-run
xargs --verbose clang-format --style=llvm -Werror --dry-run

libagama-zypp.a: $(OBJ)
$(AR) -crs $@ $^
Expand Down
5 changes: 3 additions & 2 deletions rust/zypp-agama/zypp-agama-sys/c-layer/lib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ struct Zypp {
zypp::RepoManager *repo_manager;
};

static struct Zypp the_zypp {
.zypp_pointer = NULL, .repo_manager = NULL,
static struct Zypp the_zypp{
.zypp_pointer = NULL,
.repo_manager = NULL,
};

// formatter which actually logs the messages to the systemd journal,
Expand Down
2 changes: 1 addition & 1 deletion rust/zypp-agama/zypp-agama-sys/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ unsafe extern "C" {
) -> bool;
#[doc = " Runs solver\n @param zypp see \\ref init_target\n @param only_required if true, only required packages are installed (ignoring\n recommended packages)\n @param[out] status (will overwrite existing contents)\n @return true if solver pass and false if it found some dependency issues"]
pub fn run_solver(zypp: *mut Zypp, only_required: bool, status: *mut Status) -> bool;
#[doc = " Create a solver testcase, dumps all all solver data (repositories, loaded packages...) to disk\n @param zypp see \\ref init_target\n @param dir directory path where the solver testcase is saved\n @return true if the solver testcase was successfully created"]
#[doc = " Create a solver testcase, dumps all all solver data (repositories, loaded\n packages...) to disk\n @param zypp see \\ref init_target\n @param dir directory path where the solver testcase is saved\n @return true if the solver testcase was successfully created"]
pub fn create_solver_testcase(zypp: *mut Zypp, dir: *const ::std::os::raw::c_char) -> bool;
#[doc = " the last call that will free all pointers to zypp holded by agama"]
pub fn free_zypp(zypp: *mut Zypp);
Expand Down
Loading