feat: add basic
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
commit
94244cf937
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
target/
|
||||
.cuddle/
|
2041
Cargo.lock
generated
Normal file
2041
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[workspace]
|
||||
members = ["crates/*", "ci"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
anyhow = { version = "1.0.79" }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
tracing-subscriber = { version = "0.3.18" }
|
||||
clap = { version = "4.4.18", features = ["derive", "env"] }
|
||||
dotenv = { version = "0.15.0" }
|
16
ci/Cargo.toml
Normal file
16
ci/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "ci"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio.workspace = true
|
||||
|
||||
dagger-sdk = {git = "https://github.com/kjuulh/dagger.git", branch = "feat/with-send-sync"}
|
||||
eyre = { version = "0.6.11" }
|
||||
|
||||
dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
32
ci/src/main.rs
Normal file
32
ci/src/main.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use cuddle_ci::rust_service::architecture::{Architecture, Os};
|
||||
use cuddle_ci::rust_service::{extensions::*, RustService};
|
||||
use cuddle_ci::CuddleCI;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let service = RustService::from(client)
|
||||
.with_arch(Architecture::Amd64)
|
||||
.with_os(Os::Linux)
|
||||
.with_apt(&["clang", "libssl-dev", "libz-dev", "libgit2-dev"])
|
||||
.with_apt_ca_certificates()
|
||||
.with_crates(["ci", "crates/*"])
|
||||
.with_mold("2.3.3")
|
||||
.with_bin_name("cuddle-rust-service-plan")
|
||||
.with_deployment(false)
|
||||
.to_owned();
|
||||
|
||||
let service = Arc::new(Mutex::new(service));
|
||||
|
||||
CuddleCI::default()
|
||||
.with_pull_request(service.clone())
|
||||
.with_main(service.clone())
|
||||
.execute(std::env::args())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
1
crates/cuddle-rust-service-plan/.gitignore
vendored
Normal file
1
crates/cuddle-rust-service-plan/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
15
crates/cuddle-rust-service-plan/Cargo.toml
Normal file
15
crates/cuddle-rust-service-plan/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "cuddle-rust-service-plan"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
tokio.workspace = true
|
||||
|
||||
dagger-sdk = {git = "https://github.com/kjuulh/dagger.git", branch = "feat/with-send-sync"}
|
||||
eyre = { version = "0.6.11" }
|
||||
|
||||
dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
|
||||
async-trait = "0.1.77"
|
62
crates/cuddle-rust-service-plan/src/main.rs
Normal file
62
crates/cuddle-rust-service-plan/src/main.rs
Normal file
@ -0,0 +1,62 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use cuddle_ci::cuddle_releaser::CuddleReleaser;
|
||||
use cuddle_ci::rust_service::architecture::{Architecture, Os};
|
||||
use cuddle_ci::rust_service::RustService;
|
||||
use cuddle_ci::rust_service::{extensions::*, RustServiceContext};
|
||||
use cuddle_ci::{Context, CuddleCI, MainAction};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let service = RustService::from(client.clone())
|
||||
.with_arch(Architecture::Amd64)
|
||||
.with_os(Os::Linux)
|
||||
.with_apt(&["libssl-dev", "libz-dev", "libpq-dev"])
|
||||
.with_apt_release(&["libssl-dev", "libz-dev", "libpq-dev"])
|
||||
.with_apt_ca_certificates()
|
||||
.with_crates(["ci", "crates/*"])
|
||||
.with_mold("2.3.3")
|
||||
.with_bin_name("cuddle-rust-service-plan")
|
||||
.with_deployment(false)
|
||||
.to_owned();
|
||||
|
||||
let service = Arc::new(Mutex::new(service));
|
||||
|
||||
let render = Arc::new(Mutex::new(RustServiceRender::default()));
|
||||
|
||||
let deployment = Arc::new(Mutex::new(CuddleReleaser::new(client).await?));
|
||||
CuddleCI::default()
|
||||
.with_main(service.clone())
|
||||
.with_main(render.clone())
|
||||
.with_main(deployment.clone())
|
||||
.execute(std::env::args())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct RustServiceRender {}
|
||||
|
||||
#[async_trait]
|
||||
impl MainAction for RustServiceRender {
|
||||
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||
let image_tag = ctx
|
||||
.get_image_tag()?
|
||||
.ok_or(eyre::anyhow!("failed to find image_tag"))?;
|
||||
|
||||
cuddle_ci::cuddle_x::well_known::render(vec![
|
||||
"--cluster",
|
||||
"clank-prod",
|
||||
"--image_tag",
|
||||
&image_tag,
|
||||
])
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
24
cuddle.yaml
Normal file
24
cuddle.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||
|
||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
||||
|
||||
vars:
|
||||
service: "cuddle-rust-service-plan"
|
||||
registry: kasperhermansen
|
||||
|
||||
clusters:
|
||||
clank-prod:
|
||||
replicas: "3"
|
||||
namespace: prod
|
||||
|
||||
scripts:
|
||||
render:
|
||||
type: shell
|
||||
args:
|
||||
cluster:
|
||||
name: cluster
|
||||
type: flag
|
||||
image_tag:
|
||||
name: image_tag
|
||||
type: flag
|
||||
|
19
scripts/render.sh
Executable file
19
scripts/render.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
echo "rendering folder"
|
||||
|
||||
cuddle render folder \
|
||||
--source $TMP/kustomize \
|
||||
--destination $TMP/rendered/kustomize \
|
||||
--extra-var cluster=$CLUSTER \
|
||||
--extra-var image_tag=$IMAGE_TAG
|
||||
|
||||
echo "rendering kustomize"
|
||||
|
||||
cuddle render kustomize \
|
||||
--kustomize-folder $TMP/rendered/kustomize/base \
|
||||
--destination $TMP/k8s
|
||||
|
||||
echo "done"
|
Loading…
Reference in New Issue
Block a user