Skip to content
Merged

2.3.3 #1605

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
930 changes: 118 additions & 812 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
]

[workspace.package]
version = "2.3.2"
version = "0.0.0"
edition = "2024"
license = "GPL-3.0-or-later"
repository = "https://github.com/moghtech/komodo"
Expand Down Expand Up @@ -41,7 +41,7 @@ mogh_rate_limit = "1.0.1"
partial_derive2 = "0.5.0"
mongo_indexed = "2.1.0"
mogh_resolver = "1.0.0"
mogh_config = "1.1.0"
mogh_config = "1.4.2"
mogh_logger = "1.3.4"
mogh_server = "1.5.0"
toml_pretty = "2.0.0"
Expand Down Expand Up @@ -96,7 +96,7 @@ dotenvy = "0.15.7"
envy = "0.4.2"

# CRYPTO / AUTH
uuid = { version = "1.24.0", features = ["v4", "fast-rng", "serde"] }
uuid = { version = "1.25.0", features = ["v4", "fast-rng", "serde"] }
rustls = { version = "0.23.43", features = ["aws-lc-rs"] }
data-encoding = "2.11.1"
urlencoding = "2.1.3"
Expand All @@ -112,20 +112,20 @@ hickory-resolver = "0.26.1"
portable-pty = "0.9.0"
shell-escape = "0.1.5"
crossterm = "0.29.0"
bollard = "0.21.0"
bollard = "0.21.1"
sysinfo = "0.39.6"
shlex = "2.0.1"

# CLOUD
aws-config = "1.10.1"
aws-sdk-ec2 = "1.246.0"
aws-config = "1.11.0"
aws-sdk-ec2 = "1.252.0"
aws-credential-types = "1.3.0"

## CRON
english-to-cron = "0.1.7"
chrono-tz = "0.10.4"
chrono = "0.4.45"
croner = "3.0.1"
croner = "4.0.0"

# MISC
async-compression = { version = "0.4.43", features = ["tokio", "gzip"] }
Expand Down
6 changes: 1 addition & 5 deletions action/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"imports": {
"@std/toml": "jsr:@std/toml"
}
}
{}
43 changes: 1 addition & 42 deletions action/run.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,11 @@
import * as TOML from "@std/toml";

export const run = async (action: string) => {
const branch = await new Deno.Command("bash", {
args: ["-c", "git rev-parse --abbrev-ref HEAD"],
})
.output()
.then((r) => new TextDecoder("utf-8").decode(r.stdout).trim());

const cargo_toml_str = await Deno.readTextFile("Cargo.toml");
const prev_version = (
TOML.parse(cargo_toml_str) as {
workspace: { package: { version: string } };
}
).workspace.package.version;

const [version, tag, count] = prev_version.split("-");
const next_count = Number(count) + 1;

const next_version = `${version}-${tag}-${next_count}`;

await Deno.writeTextFile(
"Cargo.toml",
cargo_toml_str.replace(
`version = "${prev_version}"`,
`version = "${next_version}"`
)
);

// Cargo check first here to make sure lock file is updated before commit.
const cmd = `
cargo check
echo ""

git add --all
git commit --all --message "deploy ${version}-${tag}-${next_count}"

echo ""
git push
echo ""

km run -y action ${action} "KOMODO_BRANCH=${branch}&KOMODO_VERSION=${version}&KOMODO_TAG=${tag}-${next_count}"
`
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("//"))
.join(" && ");

new Deno.Command("bash", {
args: ["-c", cmd],
args: ["-c", `km run -y action ${action} "BRANCH=${branch}"`],
}).spawn();
};
9 changes: 7 additions & 2 deletions bin/binaries.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Builds the Komodo Core, Periphery, and Util binaries
## for a specific architecture. Requires OpenSSL 3 or later.

FROM rust:1.97.1-bookworm AS builder
RUN cargo install cargo-strip
FROM rust:1.98.0-bookworm AS builder
RUN cargo install cargo-strip cargo-edit

WORKDIR /builder
COPY Cargo.toml Cargo.lock ./
Expand All @@ -14,6 +14,11 @@ COPY ./bin/periphery ./bin/periphery
COPY ./bin/cli ./bin/cli
COPY ./xtask ./xtask

# Set Version
ARG VERSION="0.0.0"
ARG IMAGE_TAG=""
RUN cargo set-version -p komodo_core ${VERSION}${IMAGE_TAG:+-${IMAGE_TAG}}

# Compile bin
RUN \
cargo build -p komodo_core --release && \
Expand Down
16 changes: 12 additions & 4 deletions bin/chef.binaries.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Uses chef for dependency caching to help speed up back-to-back builds.

FROM lukemathwalker/cargo-chef:latest-rust-1.97.1-bookworm AS chef
FROM lukemathwalker/cargo-chef:latest-rust-1.98.0-bookworm AS chef
WORKDIR /builder

# Plan just the RECIPE to see if things have changed
Expand All @@ -12,12 +12,20 @@ COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
RUN cargo install cargo-strip
COPY --from=planner /builder/recipe.json recipe.json
RUN cargo install cargo-strip cargo-edit

# Build JUST dependencies - cached layer
COPY --from=planner /builder/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# NOW copy again (this time into builder) and build app

# NOW copy again (this time into builder), set version, and build app
COPY . .

# Set Version
ARG VERSION="0.0.0"
ARG IMAGE_TAG=""
RUN cargo set-version -p komodo_core ${VERSION}${IMAGE_TAG:+-${IMAGE_TAG}}

RUN \
cargo build --release --bin core && \
cargo build --release --bin periphery && \
Expand Down
9 changes: 7 additions & 2 deletions bin/cli/aio.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM rust:1.97.1-trixie AS builder
RUN cargo install cargo-strip
FROM rust:1.98.0-trixie AS builder
RUN cargo install cargo-strip cargo-edit

WORKDIR /builder
COPY Cargo.toml Cargo.lock ./
Expand All @@ -8,6 +8,11 @@ COPY ./client/core/rs ./client/core/rs
COPY ./client/periphery ./client/periphery
COPY ./bin/cli ./bin/cli

# Set Version
ARG VERSION="0.0.0"
ARG IMAGE_TAG=""
RUN cargo set-version -p komodo_cli ${VERSION}${IMAGE_TAG:+-${IMAGE_TAG}}

# Compile bin
RUN cargo build -p komodo_cli --release && cargo strip

Expand Down
9 changes: 7 additions & 2 deletions bin/core/aio.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## All in one, multi stage compile + runtime Docker build for your architecture.

# Build Core
FROM rust:1.97.1-trixie AS core-builder
RUN cargo install cargo-strip
FROM rust:1.98.0-trixie AS core-builder
RUN cargo install cargo-strip cargo-edit

WORKDIR /builder
COPY Cargo.toml Cargo.lock ./
Expand All @@ -13,6 +13,11 @@ COPY ./bin/core ./bin/core
COPY ./bin/cli ./bin/cli
COPY ./xtask ./xtask

# Set Version
ARG VERSION="0.0.0"
ARG IMAGE_TAG=""
RUN cargo set-version -p komodo_core ${VERSION}${IMAGE_TAG:+-${IMAGE_TAG}}

# Compile app
RUN cargo build -p komodo_core --release && \
cargo build -p komodo_cli --release && \
Expand Down
141 changes: 50 additions & 91 deletions bin/core/src/helpers/procedure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use komodo_client::{
permission::PermissionLevel,
procedure::{Procedure, ProcedureStage},
repo::Repo,
resource::ResourceQuery,
stack::Stack,
update::Update,
user::procedure_user,
Expand All @@ -33,7 +34,10 @@ use crate::{
state::{all_resources_cache, db_client},
};

use super::update::{init_execution_update, update_update};
use super::{
query::get_all_tags,
update::{init_execution_update, update_update},
};

pub async fn execute_procedure(
procedure: &Procedure,
Expand Down Expand Up @@ -109,95 +113,41 @@ async fn execute_procedure_stage(
update: &Mutex<Update>,
) -> anyhow::Result<()> {
let mut executions = Vec::with_capacity(_executions.capacity());
for execution in _executions {
match execution {
Execution::BatchRunAction(exec) => {
extend_batch_exection::<BatchRunAction>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchRunProcedure(exec) => {
extend_batch_exection::<BatchRunProcedure>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchRunBuild(exec) => {
extend_batch_exection::<BatchRunBuild>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchCloneRepo(exec) => {
extend_batch_exection::<BatchCloneRepo>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchPullRepo(exec) => {
extend_batch_exection::<BatchPullRepo>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchBuildRepo(exec) => {
extend_batch_exection::<BatchBuildRepo>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchDeploy(exec) => {
extend_batch_exection::<BatchDeploy>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchDestroyDeployment(exec) => {
extend_batch_exection::<BatchDestroyDeployment>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchDeployStack(exec) => {
extend_batch_exection::<BatchDeployStack>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchDeployStackIfChanged(exec) => {
extend_batch_exection::<BatchDeployStackIfChanged>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchPullStack(exec) => {
extend_batch_exection::<BatchPullStack>(
&exec.pattern,
&mut executions,
)
.await?;
}
Execution::BatchDestroyStack(exec) => {
extend_batch_exection::<BatchDestroyStack>(
&exec.pattern,
&mut executions,
)
.await?;
// Expands the batch executions into their matching
// single executions, and passes through the rest.
macro_rules! expand_batch_executions {
($($Variant:ident),* $(,)?) => {
for execution in _executions {
match execution {
$(
Execution::$Variant(exec) => {
extend_batch_execution::<$Variant>(
&exec.pattern,
&exec.tags,
&mut executions,
)
.await?;
}
)*
execution => executions.push(execution),
}
}
execution => executions.push(execution),
}
};
}
expand_batch_executions!(
BatchRunAction,
BatchRunProcedure,
BatchRunBuild,
BatchCloneRepo,
BatchPullRepo,
BatchBuildRepo,
BatchDeploy,
BatchDestroyDeployment,
BatchDeployStack,
BatchDeployStackIfChanged,
BatchPullStack,
BatchDestroyStack,
);
let futures = executions.into_iter().map(|execution| async move {
let now = Instant::now();
add_line_to_update(
Expand Down Expand Up @@ -550,18 +500,27 @@ async fn add_line_to_update(update: &Mutex<Update>, line: &str) {
};
}

async fn extend_batch_exection<E: ExtendBatch>(
async fn extend_batch_execution<E: ExtendBatch>(
pattern: &str,
tags: &[String],
executions: &mut Vec<Execution>,
) -> anyhow::Result<()> {
let all_tags = if tags.is_empty() {
Vec::new()
} else {
get_all_tags(None).await?
};
let more = list_full_for_user_using_pattern::<E::Resource>(
pattern,
Default::default(),
ResourceQuery {
tags: tags.to_vec(),
..Default::default()
},
None,
None,
procedure_user(),
PermissionLevel::Read.into(),
&[],
&all_tags,
)
.await?
.into_iter()
Expand Down
Loading
Loading