diff options
| author | Cheng Fang <cfang@redhat.com> | 2024-09-06 10:33:15 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-06 10:33:15 -0400 |
| commit | 79de6d5df9c0ebee010a5410a32d3f69daea7b66 (patch) | |
| tree | 3a9f7a5556d9bb279244d3daa355c1294c46a364 /pkg/argocd/update.go | |
| parent | 5990a9b49ca3e09bd91477bf6730c792c4d3cdf2 (diff) | |
fix: failed to process a full image-spec annotation with git writeback to helmvalues (#843)
Signed-off-by: Cheng Fang <cfang@redhat.com>
Diffstat (limited to 'pkg/argocd/update.go')
| -rw-r--r-- | pkg/argocd/update.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/pkg/argocd/update.go b/pkg/argocd/update.go index 8520410..d239514 100644 --- a/pkg/argocd/update.go +++ b/pkg/argocd/update.go @@ -451,8 +451,23 @@ func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]by if helmAnnotationParamName == "" { return nil, fmt.Errorf("could not find an image-name annotation for image %s", c.ImageName) } + // for image-spec annotation, helmAnnotationParamName holds image-spec annotation value, + // and helmAnnotationParamVersion is empty if helmAnnotationParamVersion == "" { - return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageName) + if c.GetParameterHelmImageSpec(app.Annotations) == "" { + // not a full image-spec, so image-tag is required + return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageName) + } + } else { + // image-tag annotation is present, so continue to process image-tag + helmParamVersion := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamVersion) + if helmParamVersion == nil { + return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamVersion) + } + err = setHelmValue(&helmNewValues, helmAnnotationParamVersion, helmParamVersion.Value) + if err != nil { + return nil, fmt.Errorf("failed to set image parameter version value: %v", err) + } } helmParamName := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamName) @@ -460,19 +475,10 @@ func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]by return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamName) } - helmParamVersion := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamVersion) - if helmParamVersion == nil { - return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamVersion) - } - err = setHelmValue(&helmNewValues, helmAnnotationParamName, helmParamName.Value) if err != nil { return nil, fmt.Errorf("failed to set image parameter name value: %v", err) } - err = setHelmValue(&helmNewValues, helmAnnotationParamVersion, helmParamVersion.Value) - if err != nil { - return nil, fmt.Errorf("failed to set image parameter version value: %v", err) - } } override, err = yaml.Marshal(helmNewValues) |
