Spwan test minio instance

This commit is contained in:
2023-05-06 13:15:17 +02:00
parent 76c22150c0
commit 11d2ba5312
10 changed files with 462 additions and 17 deletions

View File

@@ -1,4 +1,3 @@
use std::collections::BTreeMap;
use futures::TryStreamExt;
use k8s_openapi::api::core::v1::Secret;
use kube::runtime::{watcher, WatchStreamExt};
@@ -10,6 +9,7 @@ use minio_operator::constants::{
use minio_operator::crd::{MinioBucket, MinioInstance};
use minio_operator::minio::{MinioService, MinioUser};
use minio_operator::secrets::{create_secret, read_secret_str};
use std::collections::BTreeMap;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@@ -58,14 +58,29 @@ async fn apply_bucket(b: &MinioBucket, client: &Client) -> anyhow::Result<()> {
let user_secret = match secrets.get_opt(&b.spec.secret).await? {
Some(s) => s,
None => {
log::info!("Needs to create the secret {} for the bucket {}", b.spec.secret, b.spec.name);
log::info!(
"Needs to create the secret {} for the bucket {}",
b.spec.secret,
b.spec.name
);
// The secret needs to be created
let new_user = MinioUser::gen_random();
create_secret(&secrets, &b.spec.secret, BTreeMap::from([
(SECRET_MINIO_BUCKET_ACCESS_KEY.to_string(), new_user.username),
(SECRET_MINIO_BUCKET_SECRET_KEY.to_string(), new_user.password)
])).await?
create_secret(
&secrets,
&b.spec.secret,
BTreeMap::from([
(
SECRET_MINIO_BUCKET_ACCESS_KEY.to_string(),
new_user.username,
),
(
SECRET_MINIO_BUCKET_SECRET_KEY.to_string(),
new_user.password,
),
]),
)
.await?
}
};
let user = MinioUser {