Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch name missing from commit event #580

Closed
tun0 opened this issue Sep 1, 2023 · 8 comments · Fixed by #581
Closed

Branch name missing from commit event #580

tun0 opened this issue Sep 1, 2023 · 8 comments · Fixed by #581
Labels
bug Something isn't working

Comments

@tun0
Copy link

tun0 commented Sep 1, 2023

68ad71b broke our tooling in 2 ways:

  • The first line of the commit message changed format
  • The branch mentioned in the commit message is now empty, for us

Ideally commit hash and branch name (and possibly other information as well) would be available as variables to use in the template, so we have full control of their output and we always know where to find it.

@aryan9600
Copy link
Member

could you share the following:

  • the ImageUpdateAutomation object
  • the commit message before the specified commit
  • the commit message after the specified commit

@tun0
Copy link
Author

tun0 commented Sep 1, 2023

Turns out the change isn't part of the commit, but of the notification about the commit.

apiVersion: image.toolkit.fluxcd.io/v1beta1
kind: ImageUpdateAutomation
metadata:
  creationTimestamp: "2023-03-15T12:29:19Z"
  finalizers:
  - finalizers.fluxcd.io
  generation: 2
  labels:
    app.kubernetes.io/name: cluster
    app.kubernetes.io/part-of: flux-system
    kustomize.toolkit.fluxcd.io/name: flux-system
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: cluster
  namespace: flux-system
  resourceVersion: "1541837579"
  uid: 91d20642-908a-4dad-833a-a014cd8adbdf
spec:
  git:
    checkout:
      ref:
        branch: master
    commit:
      author:
        email: [email protected]
        name: Flux
      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 }}
        ...
    push:
      branch: master
  interval: 1h
  sourceRef:
    kind: GitRepository
    name: rec-cluster
  update:
    path: ./flux/clusters/production
    strategy: Setters
status:
  conditions:
  - lastTransitionTime: "2023-09-01T11:42:09Z"
    message: no updates made; last commit e86ee0b at 2023-09-01T11:41:59Z
    reason: ReconciliationSucceeded
    status: "True"
    type: Ready
  lastAutomationRunTime: "2023-09-01T14:33:28Z"
  lastPushCommit: e86ee0b5de5b59dafa4a2abf59bf91f5e51973ad
  lastPushTime: "2023-09-01T11:41:59Z"
  observedGeneration: 2

Old notification payload:

Committed and pushed change 72d9aea379e4abad985fd139a3f89e28356fa895 to master
Image Update Automation: ...

Current notification payload:

commited and pushed commit '47c55a71bf2366c14a3e5e988b81f692f763c09c' to branch ''
Image Update Automation: ...

@stefanprodan
Copy link
Member

@tun0 where you using Flux 2.0 and this broken when upgrading to 2.1?

@tun0
Copy link
Author

tun0 commented Sep 1, 2023

@tun0 where you using Flux 2.0 and this broken when upgrading to 2.1?

Yeah.

@stefanprodan
Copy link
Member

Ok we'll fix the missing branch name, thanks for reporting.

@stefanprodan stefanprodan changed the title Expose more information commit message template Branch name missing from commit event Sep 1, 2023
@stefanprodan stefanprodan added the bug Something isn't working label Sep 1, 2023
@stefanprodan
Copy link
Member

@tun0 please open a new issue for adding branch/commit to the template args, we'll track this issue as a bug.

@stefanprodan
Copy link
Member

We'll not be able to add the commit to the template, as the template is used for the commit message.

@tun0
Copy link
Author

tun0 commented Sep 1, 2023

We'll not be able to add the commit to the template, as the template is used for the commit message.

Good point, hadn't thought of that. Perhaps an option would be decoupling the commit message template and the notification template? But, I'll create a separate ticket for those wishes👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants