watchtower icon indicating copy to clipboard operation
watchtower copied to clipboard

Add notification (resp. notification filter) for monitored-only containers

Open passibe15 opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

I have some containers that are set to monitor only (via com.centurylinklabs.watchtower.monitor-only: "true" label). I have configured the following notification template.

        {{- if .Report -}}
          {{- with .Report -}}
            {{- if ( or .Updated .Skipped .Failed ) -}}
        {{len .Updated}} Updated, {{len .Skipped}} Skipped, {{len .Failed}} Failed
              {{- range .Updated}}
        - {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}}
              {{- end -}}
              {{- range .Skipped}}
        - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}
              {{- end -}}
              {{- range .Failed}}
        - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}
              {{- end -}}
            {{- end -}}
          {{- end -}}
        {{- else -}}
          {{range .Entries -}}{{.Message}}{{"\n"}}{{- end -}}
        {{- end -}}

However, I do not get a notification for monitored-only containers. Using {{- if ( or .Fresh .Updated .Skipped .Failed ) -}} in combination with {{- range .Fresh}} is not an option as this spits out all containers that were checked by watchtower regardless of whether there is a new version available or not.

Describe the solution you'd like

It would be nice if there was a .MonitoredOnly property (or something like that) for containers where {{- if ne .CurrentImageID.ShortID .LatestImageID.ShortID }} is true, but the container is not part of {{- range .Updated}}.

Describe alternatives you've considered

I tried using {{- if ne .CurrentImageID.ShortID .LatestImageID.ShortID }}, to print out notifications, and while that works in e.g. telling me which containers received a new version, it does not allow me to filter only the containers that are not part of {{- range .Updated}} and – more importantly – with this I cannot modify the {{- if ( or .Updated .Skipped .Failed ) -}} part of the template. Thus I only get a notification either when watchtower also made updates or – if I add .Fresh as described above – every time watchtower runs.

Additional context

No response

passibe15 avatar Feb 26 '24 14:02 passibe15

Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏

github-actions[bot] avatar Feb 26 '24 14:02 github-actions[bot]