잘못 매핑된 image path 정리 / tag regex오류 수정

This commit is contained in:
Sangbum Kim 2025-01-04 05:00:01 +09:00
parent 1b67cbbb1d
commit 57081a6cc9
1 changed files with 8 additions and 10 deletions

View File

@ -29,7 +29,7 @@ fn main() {
if let Ok(value) = env::var("KANIKO_IMAGE_TAGS") { if let Ok(value) = env::var("KANIKO_IMAGE_TAGS") {
env::remove_var("KANIKO_IMAGE_TAGS"); env::remove_var("KANIKO_IMAGE_TAGS");
let pattern = Regex::new(r"^[a-zA-Z0-9_\\-.]+$").unwrap(); let pattern = Regex::new(r"^[-a-zA-Z0-9_\.]+$").unwrap();
for tag in value.split(',') { for tag in value.split(',') {
let tag = tag.trim(); let tag = tag.trim();
if !pattern.is_match(tag) { if !pattern.is_match(tag) {
@ -39,15 +39,13 @@ fn main() {
} }
} }
let image = match (repository.chars().last(), name.chars().last()) { let image = format!(
(Some('/'), Some('/')) => format!("{}{}", repository.trim_end_matches("/"), name), "{}/{}",
(Some('/'), Some(_)) => format!("{}{}", repository, name), repository.trim_end_matches("/"),
(Some(_), Some('/')) => format!("{}{}", repository, name), name.trim_start_matches("/")
(Some(_), Some(_)) => format!("{}/{}", repository, name), )
(None, Some(_)) => name, .trim_matches(&['/'] as &[_])
(Some(_), None) => repository, .to_string();
(None, None) => "".to_string(),
};
let mut args: Vec<_> = env::args().skip(1).collect(); let mut args: Vec<_> = env::args().skip(1).collect();
if !image.is_empty() { if !image.is_empty() {