sensu / sensu-plugin-sdk

A framework for creating Sensu plugins
MIT License
7 stars 8 forks source link

Add a template helper for converting slice of bytes to UUID representation #44

Closed cwjohnston closed 4 years ago

cwjohnston commented 4 years ago

I want to include event IDs in notifications, e.g. providing the uuid form of the ID in an email for debugging purposes.

Using the email handler template capability, I can create emails using the template Event ID: {{ .ID }} but this is a slice of bytes and is rendered in the resulting email as Event ID: [209 148 75 68 153 63 79 30 190 227 200 57 207 112 180 28]

I believe the UUID representation can be created from a slice of bytes using https://godoc.org/github.com/google/uuid#FromBytes .

The SDK implements some helpers for rendering templates, e.g. UnixTime template function. I propose we add a UUIDFromBytes template function which would make the above linked function available to handlers using the SDK.