fluxcd / image-automation-controller

GitOps Toolkit controller that patches container image tags in Git
https://fluxcd.io
Apache License 2.0
178 stars 72 forks source link

Regression in available data in commit message templating #771

Open tun0 opened 1 month ago

tun0 commented 1 month ago

Given the following template (we basically dump all available information in a machine-parsable format):

      messageTemplate: |
        Image Update Automation:{{ range $images := .Updated.Images }} {{ $images }}{{ end }}

        ---
        automation: {{ .AutomationObject }}
        files:
        {{- range $file, $fileresult := .Updated.Files }}
        -
          filename: {{ $file }}
          objects:
        {{- range $object, $imagerefs := $fileresult.Objects }}
          -
            apiVersion: {{ $object.APIVersion }}
            kind: {{ $object.Kind }}
            name: {{ $object.Name }}
            namespace: {{ $object.Namespace }}
            images:
        {{- range $imageref := $imagerefs }}
            -
              shortName: {{ $imageref }}
              fullName: {{ $imageref.Name }}
              registry: {{ $imageref.Registry }}
              repository: {{ $imageref.Repository }}
              identifier: {{ $imageref.Identifier }}
              policy: {{ $imageref.Policy }}
        {{- end -}}
        {{- end -}}
        {{- end }}
        fileChanges:
        {{- range $file, $objectChanges := .Changed.FileChanges }}
        -
          filename: {{ $file }}
          changes:
        {{- range $object, $changes := $objectChanges }}
          -
            apiVersion: {{ $object.APIVersion }}
            kind: {{ $object.Kind }}
            name: {{ $object.Name }}
            namespace: {{ $object.Namespace }}
            changes:
        {{- range $change := $changes }}
            -
              oldValue: {{ $change.OldValue }}
              newValue: {{ $change.NewValue }}
              setter: {{ $change.Setter }}
        {{- end }}
        {{- end }}
        {{- end }}
        ...

It yields the following commit message:

---
automation: flux-system/cluster
files:
-
  filename: flux-system/kustomization.yaml
  objects:
  -
    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    name: 
    namespace: 
    images:
    -
      shortName: europe-west4-docker.pkg.dev/treehouse-devops/team--devops--containers/flux-event-handler:v2-8109fd4-20241017114458
      fullName: europe-west4-docker.pkg.dev/treehouse-devops/team--devops--containers/flux-event-handler:v2-8109fd4-20241017114458
      registry: europe-west4-docker.pkg.dev
      repository: treehouse-devops/team--devops--containers/flux-event-handler
      identifier: v2-8109fd4-20241017114458
      policy: flux-system/devops-flux-event-handler-v2
fileChanges:
-
  filename: flux-system/kustomization.yaml
  changes:
  -
    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    name: 
    namespace: 
    changes:
    -
      oldValue: v2-8109fd4-20241017114306
      newValue: v2-8109fd4-20241017114458
      setter: flux-system:devops-flux-event-handler-v2:tag
...

In the new .Changed based data we no longer know which image it is about. The .Updated based data does have that information.

Also, is it expected that there's no additional information on the Kustomization itself?

tun0 commented 1 month ago

For non-kustomized changes, the message does contain the full image name+tag. As well as the additional info for the resource(s) affected.