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

WATCHTOWER_NOTIFICATION_TEMPLATE wierd behavior #1478

Closed
leruaa opened this issue Nov 16, 2022 · 3 comments · Fixed by #1542
Closed

WATCHTOWER_NOTIFICATION_TEMPLATE wierd behavior #1478

leruaa opened this issue Nov 16, 2022 · 3 comments · Fixed by #1542

Comments

@leruaa
Copy link

leruaa commented Nov 16, 2022

Describe the bug

When I use {{- toJson .Entries -}} in WATCHTOWER_NOTIFICATION_TEMPLATE, the output doesn't actually look like json.

the first output I get is:

Watchtower 1.5.1
Using notifications: generic+https
Checking all containers (except explicitly disabled with label)
Scheduling first run: 2022-11-16 19:20:00 +0100 CET
Note that the first check will be performed in 3 minutes, 11 seconds

Wich is not a json object.

Steps to reproduce

My conf is:

 environment:
      TZ: Europe/Paris
      WATCHTOWER_CLEANUP: true
      WATCHTOWER_NOTIFICATIONS_HOSTNAME: watchtower
      WATCHTOWER_NO_STARTUP_MESSAGE: false
      WATCHTOWER_SCHEDULE: "* */5 * * * *"
      WATCHTOWER_NOTIFICATION_URL: generic+https://XXXXXXXX.x.pipedream.net
      WATCHTOWER_NOTIFICATION_REPORT: true
      WATCHTOWER_NOTIFICATION_TEMPLATE: >
        {{- if .Report -}}
          {{- toJson .Report -}}
         {{- else -}}
          {{- toJson .Entries -}}
        {{- end -}}

Expected behavior

I should get a valid json object I guess

Screenshots

No response

Environment

Watchtower 1.5.1 on Linux Docker

Your logs

N/A

Additional context

No response

@github-actions
Copy link

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! 🙏

@leruaa
Copy link
Author

leruaa commented Nov 17, 2022

After a deeper look, it seems toJson is not a standard function in Go templates, but a part of something called "Sprig", so when my template is parsed, there is an error and the default template is returned... Am I right?

If so, is it possible to include Sprig?

@piksel
Copy link
Member

piksel commented Nov 18, 2022

Adding a toJSON function is absolutely a good suggestion. Not sure if we want to bring in a dependency for it though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants