Skip to content
Merged
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
32 changes: 16 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
]

[workspace.package]
version = "1.19.4"
version = "1.19.5"
edition = "2024"
authors = ["mbecker20 <[email protected]>"]
license = "GPL-3.0-or-later"
Expand Down
12 changes: 5 additions & 7 deletions bin/core/src/api/execute/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use komodo_client::{
build::{Build, BuildConfig},
builder::{Builder, BuilderConfig},
deployment::DeploymentState,
komodo_timestamp,
komodo_timestamp, optional_string,
permission::PermissionLevel,
repo::Repo,
update::{Log, Update},
Expand Down Expand Up @@ -290,12 +290,10 @@ impl Resolve<ExecuteArgs> for RunBuild {
repo,
registry_tokens,
replacers: secret_replacers.into_iter().collect(),
// Push a commit hash tagged image
additional_tags: if update.commit_hash.is_empty() {
Default::default()
} else {
vec![update.commit_hash.clone()]
},
// To push a commit hash tagged image
commit_hash: optional_string(&update.commit_hash),
// Unused for now
additional_tags: Default::default(),
}) => res.context("failed at call to periphery to build"),
_ = cancel.cancelled() => {
info!("build cancelled during build, cleaning up builder");
Expand Down
6 changes: 3 additions & 3 deletions bin/core/src/api/execute/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use komodo_client::{
deployment::{
Deployment, DeploymentImage, extract_registry_domain,
},
get_image_names, komodo_timestamp, optional_string,
komodo_timestamp, optional_string,
permission::PermissionLevel,
server::Server,
update::{Log, Update},
Expand Down Expand Up @@ -115,7 +115,7 @@ impl Resolve<ExecuteArgs> for Deploy {
let (version, registry_token) = match &deployment.config.image {
DeploymentImage::Build { build_id, version } => {
let build = resource::get::<Build>(build_id).await?;
let image_names = get_image_names(&build);
let image_names = build.get_image_names();
let image_name = image_names
.first()
.context("No image name could be created")
Expand Down Expand Up @@ -249,7 +249,7 @@ pub async fn pull_deployment_inner(
let (image, account, token) = match deployment.config.image {
DeploymentImage::Build { build_id, version } => {
let build = resource::get::<Build>(&build_id).await?;
let image_names = get_image_names(&build);
let image_names = build.get_image_names();
let image_name = image_names
.first()
.context("No image name could be created")
Expand Down
19 changes: 7 additions & 12 deletions bin/periphery/src/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use interpolate::Interpolator;
use komodo_client::entities::{
EnvironmentVar, all_logs_success,
build::{Build, BuildConfig},
environment_vars_from_str, get_image_names, optional_string,
environment_vars_from_str, optional_string,
to_path_compatible_name,
update::Log,
};
Expand All @@ -25,9 +25,7 @@ use resolver_api::Resolve;
use tokio::fs;

use crate::{
build::{
image_tags, parse_build_args, parse_secret_args, write_dockerfile,
},
build::{parse_build_args, parse_secret_args, write_dockerfile},
config::periphery_config,
docker::docker_login,
helpers::{parse_extra_args, parse_labels},
Expand Down Expand Up @@ -126,8 +124,9 @@ impl Resolve<super::Args> for build::Build {
mut build,
repo: linked_repo,
registry_tokens,
additional_tags,
mut replacers,
commit_hash,
additional_tags,
} = self;

let mut logs = Vec::new();
Expand All @@ -145,8 +144,6 @@ impl Resolve<super::Args> for build::Build {
name,
config:
BuildConfig {
version,
image_tag,
build_path,
dockerfile_path,
build_args,
Expand Down Expand Up @@ -265,8 +262,6 @@ impl Resolve<super::Args> for build::Build {

// Get command parts

let image_names = get_image_names(&build);

// Add VERSION to build args (if not already there)
let mut build_args = environment_vars_from_str(build_args)
.context("Invalid build_args")?;
Expand All @@ -291,9 +286,9 @@ impl Resolve<super::Args> for build::Build {

let buildx = if *use_buildx { " buildx" } else { "" };

let image_tags =
image_tags(&image_names, image_tag, version, &additional_tags)
.context("Failed to parse image tags into command")?;
let image_tags = build
.get_image_tags_as_arg(commit_hash.as_deref(), &additional_tags)
.context("Failed to parse image tags into command")?;

let maybe_push = if should_push { " --push" } else { "" };

Expand Down
30 changes: 1 addition & 29 deletions bin/periphery/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use anyhow::{Context, anyhow};
use formatting::format_serror;
use komodo_client::{
entities::{EnvironmentVar, Version, update::Log},
entities::{EnvironmentVar, update::Log},
parsers::QUOTE_PATTERN,
};

Expand Down Expand Up @@ -52,34 +52,6 @@ pub async fn write_dockerfile(
}
}

pub fn image_tags(
image_names: &[String],
custom_tag: &str,
version: &Version,
additional: &[String],
) -> anyhow::Result<String> {
let Version { major, minor, .. } = version;
let custom_tag = if custom_tag.is_empty() {
String::new()
} else {
format!("-{custom_tag}")
};

let mut res = String::new();

for image_name in image_names {
write!(
&mut res,
" -t {image_name}:latest{custom_tag} -t {image_name}:{version}{custom_tag} -t {image_name}:{major}.{minor}{custom_tag} -t {image_name}:{major}{custom_tag}"
)?;
for tag in additional {
write!(&mut res, " -t {image_name}:{tag}{custom_tag}")?;
}
}

Ok(res)
}

pub fn parse_build_args(build_args: &[EnvironmentVar]) -> String {
build_args
.iter()
Expand Down
Loading