cargo fmt

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-07-21 13:33:37 +02:00
parent 03bba92a8b
commit 95e5e59fd0
2 changed files with 12 additions and 9 deletions

View File

@ -104,7 +104,10 @@ pub mod export {
); );
} }
if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path)) { if let Some(file) = files
.iter_mut()
.find(|file| file.path.as_ref() == Some(&path))
{
file.repositories.push(repo); file.repositories.push(repo);
file.write()?; file.write()?;
@ -145,7 +148,10 @@ pub mod export {
bail!("unable to parse file {} - {}", error.path, error.error); bail!("unable to parse file {} - {}", error.path, error.error);
} }
if let Some(file) = files.iter_mut().find(|file| file.path.as_ref() == Some(&path.to_string())) { if let Some(file) = files
.iter_mut()
.find(|file| file.path.as_ref() == Some(&path.to_string()))
{
if let Some(repo) = file.repositories.get_mut(index) { if let Some(repo) = file.repositories.get_mut(index) {
if let Some(enabled) = options.enabled { if let Some(enabled) = options.enabled {
repo.set_enabled(enabled); repo.set_enabled(enabled);

View File

@ -1,13 +1,13 @@
#[perlmod::package(name = "PVE::RS::OpenId", lib = "pve_rs")] #[perlmod::package(name = "PVE::RS::OpenId", lib = "pve_rs")]
mod export { mod export {
use std::sync::Mutex;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::sync::Mutex;
use anyhow::Error; use anyhow::Error;
use perlmod::{to_value, Value}; use perlmod::{to_value, Value};
use proxmox_openid::{OpenIdConfig, OpenIdAuthenticator, PrivateAuthState}; use proxmox_openid::{OpenIdAuthenticator, OpenIdConfig, PrivateAuthState};
const CLASSNAME: &str = "PVE::RS::OpenId"; const CLASSNAME: &str = "PVE::RS::OpenId";
@ -44,7 +44,6 @@ mod export {
config: OpenIdConfig, config: OpenIdConfig,
redirect_url: &str, redirect_url: &str,
) -> Result<Value, Error> { ) -> Result<Value, Error> {
let open_id = OpenIdAuthenticator::discover(&config, redirect_url)?; let open_id = OpenIdAuthenticator::discover(&config, redirect_url)?;
bless( bless(
class, class,
@ -60,7 +59,6 @@ mod export {
state_dir: &str, state_dir: &str,
realm: &str, realm: &str,
) -> Result<String, Error> { ) -> Result<String, Error> {
let open_id = this.inner.lock().unwrap(); let open_id = this.inner.lock().unwrap();
open_id.authorize_url(state_dir, realm) open_id.authorize_url(state_dir, realm)
} }
@ -69,17 +67,16 @@ mod export {
pub fn verify_public_auth_state( pub fn verify_public_auth_state(
state_dir: &str, state_dir: &str,
state: &str, state: &str,
) -> Result<(String, PrivateAuthState), Error> { ) -> Result<(String, PrivateAuthState), Error> {
OpenIdAuthenticator::verify_public_auth_state(state_dir, state) OpenIdAuthenticator::verify_public_auth_state(state_dir, state)
} }
#[export(raw_return)] #[export(raw_return)]
pub fn verify_authorization_code( pub fn verify_authorization_code(
#[try_from_ref] this: &OpenId, #[try_from_ref] this: &OpenId,
code: &str, code: &str,
private_auth_state: PrivateAuthState, private_auth_state: PrivateAuthState,
) -> Result<Value, Error> { ) -> Result<Value, Error> {
let open_id = this.inner.lock().unwrap(); let open_id = this.inner.lock().unwrap();
let claims = open_id.verify_authorization_code_simple(code, &private_auth_state)?; let claims = open_id.verify_authorization_code_simple(code, &private_auth_state)?;