Spwan test minio instance
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user