Skip to content

Commit

Permalink
Prepare 0.3.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sebt3 committed Mar 9, 2025
1 parent a29dc95 commit 55d9b12
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 25 deletions.
21 changes: 10 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async fn main() {
.write_style_or("LOG_STYLE", "auto"),
);
let args = Parameters::parse();
common::context::init_k8s();
match &args.command {
Commands::Version(args) => version::run(args).await.unwrap_or_else(|e| {
tracing::error!("Version failed with: {e:}");
Expand Down
2 changes: 1 addition & 1 deletion agent/src/tenant/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Parameters {
long = "agent-image",
env = "AGENT_IMAGE",
value_name = "AGENT_IMAGE",
default_value = "docker.io/sebt3/vynil-agent:0.3.3"
default_value = "docker.io/sebt3/vynil-agent:0.3.4"
)]
agent_image: String,
/// version
Expand Down
2 changes: 1 addition & 1 deletion agent/src/tenant/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Parameters {
long = "agent-image",
env = "AGENT_IMAGE",
value_name = "AGENT_IMAGE",
default_value = "docker.io/sebt3/vynil-agent:0.3.3"
default_value = "docker.io/sebt3/vynil-agent:0.3.4"
)]
agent_image: String,
/// Configuration directory
Expand Down
2 changes: 1 addition & 1 deletion agent/src/tenant/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Parameters {
long = "agent-image",
env = "AGENT_IMAGE",
value_name = "AGENT_IMAGE",
default_value = "docker.io/sebt3/vynil-agent:0.3.3"
default_value = "docker.io/sebt3/vynil-agent:0.3.4"
)]
agent_image: String,
/// version
Expand Down
2 changes: 1 addition & 1 deletion agent/src/tenant/reconfigure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Parameters {
long = "agent-image",
env = "AGENT_IMAGE",
value_name = "AGENT_IMAGE",
default_value = "docker.io/sebt3/vynil-agent:0.3.3"
default_value = "docker.io/sebt3/vynil-agent:0.3.4"
)]
agent_image: String,
/// version
Expand Down
2 changes: 1 addition & 1 deletion agent/src/tenant/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Parameters {
long = "agent-image",
env = "AGENT_IMAGE",
value_name = "AGENT_IMAGE",
default_value = "docker.io/sebt3/vynil-agent:0.3.3"
default_value = "docker.io/sebt3/vynil-agent:0.3.4"
)]
agent_image: String,
/// version
Expand Down
20 changes: 17 additions & 3 deletions common/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::sync::Mutex;
#[derive(Clone)]
pub struct Context {
pub client: Client,
pub reporter: Reporter,
}

pub enum VynilContext {
Expand All @@ -17,6 +16,7 @@ pub enum VynilContext {

lazy_static::lazy_static! {
pub static ref CONTEXT: Mutex<VynilContext> = Mutex::new(VynilContext::None);
pub static ref KUBERNETES: Mutex<Option<Context>> = Mutex::new(None);
}
pub fn set_tenant(i: TenantInstance) {
*CONTEXT.lock().unwrap() = VynilContext::TenantInstance(i);
Expand Down Expand Up @@ -128,9 +128,23 @@ pub fn get_short_name() -> String {
}
}

pub fn init_k8s() {
*KUBERNETES.lock().unwrap() = Some(Context {
client: tokio::task::block_in_place(|| {
tokio::runtime::Handle::current()
.block_on(async move { Client::try_default().await.expect("create client") })
}),
});
}

pub fn get_client() -> Client {
tokio::runtime::Handle::current()
.block_on(async move { Client::try_default().await.expect("create client") })
match (*KUBERNETES.lock().unwrap()).clone() {
Some(ctx) => ctx.client,
None => tokio::task::block_in_place(|| {
tokio::runtime::Handle::current()
.block_on(async move { Client::try_default().await.expect("create client") })
}),
}
}
pub async fn get_client_async() -> Client {
Client::try_default().await.expect("create client")
Expand Down
8 changes: 3 additions & 5 deletions common/src/passwordhandler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rand::{
distr::{Distribution, uniform::Uniform, weighted::WeightedIndex},
distr::{uniform::Uniform, weighted::WeightedIndex, Distribution},
rng, RngCore,
};

Expand Down Expand Up @@ -28,9 +28,7 @@ impl Default for Passwords {
impl Passwords {
#[must_use]
pub fn new() -> Passwords {
Passwords {
rng: Box::new(rng()),
}
Passwords { rng: Box::new(rng()) }
}

pub fn generate(&mut self, length: i64, alpha: u32, numbers: u32, symbols: u32) -> String {
Expand All @@ -51,7 +49,7 @@ impl Passwords {
let mut password = String::with_capacity(length as usize);
for _ in 0..length {
let selected_set = character_sets.get(weighted_dist.sample(&mut self.rng)).unwrap();
let dist_char = Uniform::new_inclusive(0,selected_set.len()).unwrap();
let dist_char = Uniform::new_inclusive(0, selected_set.len() - 1).unwrap();
let index = dist_char.sample(&mut self.rng);
password.push(selected_set[index]);
}
Expand Down
1 change: 1 addition & 0 deletions operator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async fn main() -> Result<()> {
// Initialize tracing
tracing::subscriber::set_global_default(collector).unwrap();

common::context::init_k8s();
// Start kubernetes controller
let (manager, controller_jbs, controller_tnts, controller_stms) = Manager::new().await;

Expand Down
2 changes: 1 addition & 1 deletion operator/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::Serialize;
use serde_json::{json, Value};
use std::{collections::BTreeMap, path::PathBuf, sync::Arc};
use tokio::sync::RwLock;
static DEFAULT_AGENT_IMAGE: &str = "docker.io/sebt3/vynil-agent:0.3.3";
static DEFAULT_AGENT_IMAGE: &str = "docker.io/sebt3/vynil-agent:0.3.4";

pub struct JukeCacheItem {
pub pull_secret: Option<String>,
Expand Down

0 comments on commit 55d9b12

Please sign in to comment.