image-automation-controller icon indicating copy to clipboard operation
image-automation-controller copied to clipboard

Regression in available data in commit message templating

Open tun0 opened this issue 1 year ago • 1 comments

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 avatar Oct 17 '24 12:10 tun0