Skip to content

Commit

Permalink
Prepare 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebt3 committed Nov 15, 2024
1 parent 5b3ec5b commit f5de489
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 145 deletions.
48 changes: 28 additions & 20 deletions Cargo.lock

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

30 changes: 25 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ version = "0.96.0"


[workspace.package]
version = "0.3.1"
version = "0.3.2"
authors = ["Sébastien Huss <sebastien.huss@gmail.com>"]
edition = "2021"
license = " BSD-3-Clause"
license = "BSD-3-Clause"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -48,15 +48,35 @@ strip = true

# use "cargo install cargo-commander", then "cargo cmd generate"
[package.metadata.commands]
generate = { cmd=[
generate_crd = { cmd=[
"cargo run --bin agent -- crdgen > box/vynil/crds/crd.yaml",
"cp box/vynil/crds/crd.yaml deploy/crd/crd.yaml",
]}
generate = { cmd=[
"cargo cmd generate_crd",
"awk 'BEGIN{p=1}/profile.release/{p=0}p==1&&!/\"operator\",/'<Cargo.toml>agent/parent.toml",
"awk 'BEGIN{p=1}/profile.release/{p=0}p==1&&!/\"agent\",/'<Cargo.toml>operator/parent.toml",
]}
crd = { cmd=[
"cargo run --bin agent -- crdgen > box/vynil/crds/crd.yaml",
"cp box/vynil/crds/crd.yaml deploy/crd/crd.yaml",
"cargo cmd generate_crd",
"kubectl apply -f box/vynil/crds/crd.yaml"
]}
fmt = { cmd=[
"cargo +nightly fmt"
]}
precommit = { cmd=[
"cargo update",
"cargo clippy --fix --allow-dirty",
"cargo cmd generate",
"cargo +nightly fmt"
]}
agent = { cmd=[
"podman build . -f agent/Dockerfile -t docker.io/sebt3/vynil-agent:$(cargo run --bin agent -- version) && podman push docker.io/sebt3/vynil-agent:$(cargo run --bin agent -- version)",
]}
operator = { cmd=[
"podman build . -f operator/Dockerfile -t docker.io/sebt3/vynil-operator:$(cargo run --bin agent -- version) && podman push docker.io/sebt3/vynil-operator:$(cargo run --bin agent -- version)",
]}
box = { cmd=[
"cargo run --bin agent -- package update --source ./box/vynil/",
"cargo run --bin agent -- package build -o ./box/vynil/ --tag $(cargo run --bin agent -- version) -r docker.io -n sebt3/vynil -u $(jq -r '.auths[\"docker.io\"].auth' </run/user/$(id -u)/containers/auth.json |base64 -d|awk -F: '{print $1}') -p $(jq -r '.auths[\"docker.io\"].auth' </run/user/$(id -u)/containers/auth.json |base64 -d|awk -F: '{print $2}')",
]}
10 changes: 4 additions & 6 deletions agent/parent.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ default-members = [
[workspace.dependencies]
k8s-openapi = { version = "0.23.0", features = ["latest"], default-features = false }
tracing = "0.1.37"
serde = { version = "1.0.185", features = ["derive"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.105"
serde_yaml = "0.9.25"
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.41.0", features = ["macros", "rt-multi-thread"] }
chrono = { version = "0.4.38", features = ["serde"] }
schemars = { version = "0.8.12", features = ["chrono"] }
actix-web = "4.9.0"
Expand All @@ -26,10 +26,10 @@ version = "0.96.0"


[workspace.package]
version = "0.3.0"
version = "0.3.2"
authors = ["Sébastien Huss <sebastien.huss@gmail.com>"]
edition = "2021"
license = " BSD-3-Clause"
license = "BSD-3-Clause"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -41,5 +41,3 @@ authors.workspace = true
edition.workspace = true
license.workspace = true

#[profile.release]
#strip = true
10 changes: 5 additions & 5 deletions agent/scripts/lib/wait.rhai
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn workload(lst, duration) {
for wl in lst.filter(|wl| ["Deployment", "DaemonSet", "StatefulSet"].contains(wl.kind)) {
log_info(`Waiting for ${wl.kind} ${wl.namespace} ${wl.name} to be available`);
log_info(`Waiting for ${wl.kind} ${wl.namespace}/${wl.name} to be available`);
if wl.kind == "Deployment" {
let deploy = get_deployment(wl.namespace, wl.name);
deploy.wait_available(duration);
Expand All @@ -19,7 +19,7 @@ fn workload(lst) {

fn job(lst, duration) {
for j in lst.filter(|j| j.kind == "Job") {
log_info(`Waiting for ${j.kind} ${j.namespace} ${j.name} to finish`);
log_info(`Waiting for ${j.kind} ${j.namespace}/${j.name} to finish`);
let job = get_job(j.namespace, j.name);
job.wait_done(duration);
}
Expand All @@ -31,17 +31,17 @@ fn job(lst) {
fn vital(lst, duration) {
for v in lst {
if ["Cluster"].contains(v.kind) {
log_info(`Waiting for ${v.kind} ${v.namespace} ${v.name} to be available`);
log_info(`Waiting for ${v.kind} ${v.namespace}/${v.name} to be available`);
let api = k8s_resource(v.kind, v.namespace);
let obj = api.get_obj(v.name);
obj.wait_condition("Ready", duration);
} else if ["RabbitmqCluster"].contains(v.kind) {
log_info(`Waiting for ${v.kind} ${v.namespace} ${v.name} to be available`);
log_info(`Waiting for ${v.kind} ${v.namespace}/${v.name} to be available`);
let api = k8s_resource(v.kind, v.namespace);
let obj = api.get_obj(v.name);
obj.wait_condition("ClusterAvailable", duration);
} else if ["Redis", "MongoDBCommunity"].contains(v.kind) {
log_info(`Waiting for ${v.kind} ${v.namespace} ${v.name} to be available`);
log_info(`Waiting for ${v.kind} ${v.namespace}/${v.name} to be available`);
let sts = get_statefulset(v.namespace, v.name);
sts.wait_available(duration);
}
Expand Down
6 changes: 3 additions & 3 deletions agent/src/package/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ pub async fn run(args: &Parameters) -> Result<()> {
tracing::error!("{:?} is not a directory", &args.destination);
Err(Error::MissingDestination(args.destination.clone()))
} else {
let mut cli = if args.pull_path == "" {
let mut cli = if args.pull_path.is_empty() {
Registry::new(
args.registry.clone(),
args.username.clone(),
args.password.clone(),
)
} else {
let pull_secret_string = std::fs::read_to_string(format!("{}/.dockerconfigjson", args.pull_path))
.map_err(|e| Error::Stdio(e))?;
.map_err(Error::Stdio)?;
let pull_secret: serde_json::Value =
serde_json::from_str(&pull_secret_string).map_err(|e| Error::SerializationError(e))?;
serde_json::from_str(&pull_secret_string).map_err(Error::SerializationError)?;
let hash = pull_secret["auths"][args.registry.clone()]["auth"].clone();
let user_pass = base64_decode(hash.as_str().unwrap().to_string())?;
let auth = user_pass.split(":").collect::<Vec<&str>>();
Expand Down
4 changes: 2 additions & 2 deletions agent/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::Args;
use common::{Result, vynilpackage::VERSION};
use common::{vynilpackage::VERSION, Result};

#[derive(Args, Debug)]
pub struct Parameters {}

pub async fn run(_args: &Parameters) -> Result<()> {
println!("{}",VERSION);
println!("{}", VERSION);
Ok(())
}
6 changes: 5 additions & 1 deletion box/vynil/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ spec:
description: Registry
type: string
requirements:
description: Requirement
description: Requirements
items:
description: Vynil Package Requirement
oneOf:
Expand Down Expand Up @@ -273,6 +273,10 @@ spec:
tag:
description: Current tag
type: string
value_script:
description: A rhai script that produce a map to be added in the package values
nullable: true
type: string
required:
- image
- metadata
Expand Down
21 changes: 10 additions & 11 deletions box/vynil/package.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
apiVersion: vinyl.solidite.fr/v1beta1
kind: Package
metadata:
type: system
name: vynil
category: core
description: Vynil controller to manage vynil packages installations
features:
- upgrade
- auto_config
app_version: 0.3.1
images:
agent:
registry: docker.io
repository: sebt3/vynil-agent
controller:
registry: docker.io
repository: sebt3/vynil-operator
kind: Package
metadata:
app_version: 0.3.2
category: core
description: Vynil controller to manage vynil packages installations
features:
- upgrade
- auto_config
name: vynil
type: system
resources:
controller:
requests:
Expand Down
2 changes: 1 addition & 1 deletion common/src/handlebarshandler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{passwordhandler::Passwords, hasheshandlers::Argon, rhai_err, Error, Result, RhaiRes};
use crate::{hasheshandlers::Argon, passwordhandler::Passwords, rhai_err, Error, Result, RhaiRes};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use handlebars::{handlebars_helper, Handlebars};
use handlebars_misc_helpers::new_hbs;
Expand Down
Loading

0 comments on commit f5de489

Please sign in to comment.