Skip to content

Commit 73f8893

Browse files
Fix separator with no value caught (#4069)
1 parent cafb4f7 commit 73f8893

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

magefile.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ func FixDRADockerArtifacts() error {
466466
log.Printf("--- Found artifacts to rename %s %d", distributionsPath, len(matches))
467467
}
468468
// Match the artifact name and break down into groups so that we can reconstruct the names as its expected by the DRA DSL
469-
artifactRegexp, err := regexp.Compile(`([\w+-]+)-(([0-9]+)\.([0-9]+)\.([0-9]+))-?([\w]+)?-([\w]+)-([\w]+)\.([\w]+)\.([\w.]+)`)
469+
// As SNAPSHOT keyword or BUILDID are optional, capturing the separator - or + with the value.
470+
artifactRegexp, err := regexp.Compile(`([\w+-]+)-(([0-9]+)\.([0-9]+)\.([0-9]+))([-|\+][\w]+)?-([\w]+)-([\w]+)\.([\w]+)\.([\w.]+)`)
470471
if err != nil {
471472
return err
472473
}
@@ -480,7 +481,8 @@ func FixDRADockerArtifacts() error {
480481
}
481482
match := artifactRegexp.FindAllStringSubmatch(artifactFile.Name(), -1)
482483
// The groups here is tightly coupled with the regexp above.
483-
targetName := fmt.Sprintf("%s-%s-%s-%s-image-%s-%s.%s", match[0][1], match[0][2], match[0][6], match[0][9], match[0][7], match[0][8], match[0][10])
484+
// match[0][6] already contains the separator so no need to add before the variable
485+
targetName := fmt.Sprintf("%s-%s%s-%s-image-%s-%s.%s", match[0][1], match[0][2], match[0][6], match[0][9], match[0][7], match[0][8], match[0][10])
484486
if mg.Verbose() {
485487
fmt.Printf("%#v\n", match)
486488
fmt.Printf("Artifact: %s \n", artifactFile.Name())

0 commit comments

Comments
 (0)