fix: Lowecase registry and update IMAGE_REGISTRY arg (#49)
This commit is contained in:
parent
8f44bf4ea0
commit
aab4c0038f
3 changed files with 39 additions and 11 deletions
|
|
@ -376,20 +376,24 @@ impl BuildCommand {
|
|||
)
|
||||
} else {
|
||||
match (
|
||||
env::var("CI_REGISTRY").ok(),
|
||||
env::var("CI_PROJECT_NAMESPACE").ok(),
|
||||
env::var("CI_PROJECT_NAME").ok(),
|
||||
env::var("GITHUB_REPOSITORY_OWNER").ok(),
|
||||
self.registry.as_ref(),
|
||||
self.registry_path.as_ref(),
|
||||
env::var("CI_REGISTRY").ok().map(|s| s.to_lowercase()),
|
||||
env::var("CI_PROJECT_NAMESPACE")
|
||||
.ok()
|
||||
.map(|s| s.to_lowercase()),
|
||||
env::var("CI_PROJECT_NAME").ok().map(|s| s.to_lowercase()),
|
||||
env::var("GITHUB_REPOSITORY_OWNER")
|
||||
.ok()
|
||||
.map(|s| s.to_lowercase()),
|
||||
self.registry.as_ref().map(|s| s.to_lowercase()),
|
||||
self.registry_path.as_ref().map(|s| s.to_lowercase()),
|
||||
) {
|
||||
(_, _, _, _, Some(registry), Some(registry_path)) => {
|
||||
trace!("registry={registry}, registry_path={registry_path}");
|
||||
format!(
|
||||
"{}/{}/{}",
|
||||
registry.trim().trim_matches('/').to_lowercase(),
|
||||
registry_path.trim().trim_matches('/').to_lowercase(),
|
||||
recipe.name.trim().to_lowercase()
|
||||
registry.trim().trim_matches('/'),
|
||||
registry_path.trim().trim_matches('/'),
|
||||
recipe.name.trim(),
|
||||
)
|
||||
}
|
||||
(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
fs,
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
process,
|
||||
};
|
||||
|
|
@ -234,3 +234,19 @@ fn get_files_list(module: &Module) -> Option<Vec<(String, String)>> {
|
|||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
fn get_github_repo_owner() -> Option<String> {
|
||||
Some(env::var("GITHUB_REPOSITORY_OWNER").ok()?.to_lowercase())
|
||||
}
|
||||
|
||||
fn get_gitlab_registry_path() -> Option<String> {
|
||||
Some(
|
||||
format!(
|
||||
"{}/{}/{}",
|
||||
env::var("CI_REGISTRY").ok()?,
|
||||
env::var("CI_PROJECT_NAMESPACE").ok()?,
|
||||
env::var("CI_PROJECT_NAME").ok()?,
|
||||
)
|
||||
.to_lowercase(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,16 @@ LABEL io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-
|
|||
LABEL io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4
|
||||
|
||||
ARG RECIPE={{ recipe_path.display() }}
|
||||
|
||||
{%- if let Some(repo_owner) = self::get_github_repo_owner() %}
|
||||
ARG IMAGE_REGISTRY=ghcr.io/{{ repo_owner }}
|
||||
{%- else if let Some(registry) = self::get_gitlab_registry_path() %}
|
||||
ARG IMAGE_REGISTRY={{ registry }}
|
||||
{%- else %}
|
||||
ARG IMAGE_REGISTRY=localhost
|
||||
{%- endif %}
|
||||
|
||||
{%- if self::has_cosign_file() %}
|
||||
ARG IMAGE_REGISTRY=ghcr.io/ublue-os
|
||||
COPY cosign.pub /usr/share/ublue-os/cosign.pub
|
||||
{%- endif %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue