Skip to content

Commit

Permalink
Merge pull request #372 from cbgbt/publish-override
Browse files Browse the repository at this point in the history
publish-kit: allow overridding image repository
  • Loading branch information
cbgbt authored Sep 16, 2024
2 parents b94c8f8 + 46e63b1 commit d812e8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/pubsys/src/kit/publish_kit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ pub(crate) struct PublishKitArgs {
#[arg(long)]
vendor: String,

/// Optionally push the kit a different repository name
#[arg(long)]
repo: Option<String>,

/// The version of the kit that should be published
#[arg(long)]
version: String,
Expand Down Expand Up @@ -66,6 +70,11 @@ async fn publish_kit(
let kit_version = publish_kit_args.version.clone();
let build_id = publish_kit_args.build_id.clone();

let repository_target = match publish_kit_args.repo.as_ref() {
Some(repo) => repo.clone(),
None => kit_name.to_string(),
};

let mut platform_images = Vec::new();
for arch in ["aarch64", "x86_64"] {
let docker_arch =
Expand All @@ -81,7 +90,7 @@ async fn publish_kit(

let arch_specific_target_uri = format!(
"{}/{}:{}-{}-{}",
vendor_registry_uri, kit_name, &kit_version, &build_id, arch
vendor_registry_uri, repository_target, &kit_version, &build_id, arch
);

info!(
Expand Down
1 change: 1 addition & 0 deletions twoliter/embedded/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,7 @@ pubsys \
publish-kit \
--kit-path "${BUILDSYS_BUILD_DIR}/kits/${BUILDSYS_KIT}" \
--vendor "${PUBLISH_VENDOR}" \
--repo "${PUBLISH_KIT_REPO}" \
--version "v${BUILDSYS_VERSION_IMAGE}" \
--build-id "${BUILDSYS_VERSION_BUILD}"
'''
Expand Down
8 changes: 8 additions & 0 deletions twoliter/src/cmd/publish_kit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub(crate) struct PublishKit {

/// Vendor to publish to
vendor: String,

/// Publish kit image to a different repository than the kit's name
kit_repo: Option<String>,
}

impl PublishKit {
Expand All @@ -41,11 +44,16 @@ impl PublishKit {
install_tools(&toolsdir).await?;
let makefile_path = toolsdir.join("Makefile.toml");

let publish_kit_repo = match &self.kit_repo {
Some(kit_repo) => kit_repo,
None => &self.kit_name,
};
CargoMake::new(project.sdk_image().project_image_uri().to_string().as_str())?
.env("TWOLITER_TOOLS_DIR", toolsdir.display().to_string())
.env("BUILDSYS_KIT", &self.kit_name)
.env("BUILDSYS_VERSION_IMAGE", project.release_version())
.env("PUBLISH_VENDOR", &self.vendor)
.env("PUBLISH_KIT_REPO", publish_kit_repo)
.makefile(makefile_path)
.project_dir(project.project_dir())
.exec("publish-kit")
Expand Down

0 comments on commit d812e8f

Please sign in to comment.