Skip to content

Commit 072e084

Browse files
committed
fix: add regex tag pattern match
Signed-off-by: chansuke <[email protected]>
1 parent 5954a02 commit 072e084

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pkg/argocd/argocd.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"regexp"
89
"strings"
910
"time"
1011

@@ -747,13 +748,24 @@ func getImageFromSpec(app *v1alpha1.Application, targetImage *image.ContainerIma
747748
switch appType {
748749
case ApplicationTypeHelm:
749750
if source.Helm != nil && source.Helm.Parameters != nil {
751+
// Define regex patterns for tag/version parameters
752+
tagPatterns := []*regexp.Regexp{
753+
regexp.MustCompile(`^(.+\.)?(tag|version|imageTag)$`),
754+
regexp.MustCompile(`^(image|container)\.(.+\.)?(tag|version)$`),
755+
}
756+
750757
for _, param := range source.Helm.Parameters {
751-
if param.Name == "image.tag" || param.Name == "image.version" {
752-
foundImage := image.NewFromIdentifier(fmt.Sprintf("%s:%s", targetImage.ImageName, param.Value))
753-
if foundImage != nil && foundImage.ImageName == targetImage.ImageName {
754-
return foundImage
758+
// Check if parameter matches tag/version patterns
759+
for _, pattern := range tagPatterns {
760+
if pattern.MatchString(param.Name) {
761+
foundImage := image.NewFromIdentifier(fmt.Sprintf("%s:%s", targetImage.ImageName, param.Value))
762+
if foundImage != nil && foundImage.ImageName == targetImage.ImageName {
763+
return foundImage
764+
}
765+
break
755766
}
756767
}
768+
757769
if param.Name == "image" || param.Name == "image.repository" {
758770
foundImage := image.NewFromIdentifier(param.Value)
759771
if foundImage != nil && foundImage.ImageName == targetImage.ImageName {

0 commit comments

Comments
 (0)