Skip to content

Commit 95de4f6

Browse files
committed
chore(server): fix clippy lints
1 parent 3c21a4a commit 95de4f6

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

src/server/database.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,23 @@ impl Databases {
114114
.fetch_optional(&default)
115115
.await?;
116116

117-
match pgbouncer {
118-
Some(user) => {
119-
info!(
120-
%user.can_login,
121-
%user.create_db,
122-
%user.create_role,
123-
%user.bypass_rls,
124-
%user.superuser,
125-
"pgbouncer user already exists"
126-
);
127-
if !user.can_login {
128-
warn!("pgbouncer user should be able to login");
129-
}
130-
}
131-
None => {
132-
warn!("pgbouncer user does not exist, creating...");
133-
query!("CREATE USER pgbouncer WITH LOGIN NOSUPERUSER NOCREATEROLE NOCREATEDB NOREPLICATION NOBYPASSRLS")
134-
.execute(&default)
135-
.await?;
117+
if let Some(user) = pgbouncer {
118+
info!(
119+
%user.can_login,
120+
%user.create_db,
121+
%user.create_role,
122+
%user.bypass_rls,
123+
%user.superuser,
124+
"pgbouncer user already exists"
125+
);
126+
if !user.can_login {
127+
warn!("pgbouncer user should be able to login");
136128
}
129+
} else {
130+
warn!("pgbouncer user does not exist, creating...");
131+
query!("CREATE USER pgbouncer WITH LOGIN NOSUPERUSER NOCREATEROLE NOCREATEDB NOREPLICATION NOBYPASSRLS")
132+
.execute(&default)
133+
.await?;
137134
}
138135

139136
// Setup the default database for pgbouncer authentication just in case
@@ -146,7 +143,7 @@ impl Databases {
146143
/// Get a list of all the managed databases
147144
pub fn managed_databases(&self) -> Vec<String> {
148145
let pools = self.0.pools.read();
149-
pools.keys().map(|d| d.to_owned()).collect()
146+
pools.keys().map(Clone::clone).collect()
150147
}
151148

152149
/// Get a connection to the default database
@@ -223,13 +220,10 @@ impl Databases {
223220
return Err(Error::DefaultDatabase);
224221
}
225222

226-
let pool = match {
223+
let Some(pool) = ({
227224
let mut pools = self.0.pools.write();
228225
pools.remove(database)
229-
} {
230-
Some(p) => p,
231-
None => return Ok(()),
232-
};
226+
}) else { return Ok(()) };
233227

234228
pool.close().await;
235229

src/server/operator.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use super::database::{self, Databases};
22
use clap::Args;
33
use futures::StreamExt;
4-
use k8s_openapi::api::core::v1::Secret;
5-
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
4+
use k8s_openapi::{api::core::v1::Secret, apimachinery::pkg::apis::meta::v1::ObjectMeta};
65
use kube::{
7-
api::{Patch, PatchParams},
6+
api::{DeleteParams, ListParams, Patch, PatchParams},
87
client::Client,
98
config::{Config, KubeConfigOptions, Kubeconfig},
109
runtime::{
@@ -192,7 +191,7 @@ impl Operator {
192191
}
193192

194193
let databases = Api::<Database>::all(client.clone());
195-
Controller::new(databases, Default::default())
194+
Controller::new(databases, ListParams::default())
196195
.graceful_shutdown_on(async {
197196
stop.await.unwrap();
198197
debug!("shutdown signal received");
@@ -333,7 +332,9 @@ async fn cleanup(object: Arc<Database>, databases: Databases, client: Client) ->
333332
let secret_name = secret_name_for_database(&object);
334333
for namespace in &object.spec.secret.namespaces {
335334
let secrets = Api::<Secret>::namespaced(client.clone(), namespace);
336-
secrets.delete(&secret_name, &Default::default()).await?;
335+
secrets
336+
.delete(&secret_name, &DeleteParams::default())
337+
.await?;
337338

338339
info!(%namespace, "removed secret from namespace");
339340
}

0 commit comments

Comments
 (0)