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

First-pass at improving template system. #147

Merged
merged 2 commits into from
Nov 18, 2015
Merged

First-pass at improving template system. #147

merged 2 commits into from
Nov 18, 2015

Conversation

brian-brazil
Copy link
Contributor

  • Cut back to bare minimum to make the rest simpler
  • Consistency in config naming
  • Have one data strucutre that's the same for all templates
  • Pass in common labels to templates
  • Support templates almost everywhere
  • Support multiple SMTP recipients
  • Support non-ASCII SMTP headers
  • Handle colour logic via templates
  • Make $subjects have consistent output, go maps aren't sorted.
  • Make tests pass when v6 is disabled

@fabxc

Fixes #135 #126 #74

Still needs improvement, but this should be a good base.

)

var (
// DefaultHipchatConfig defines default values for Hipchat configurations.
DefaultHipchatConfig = HipchatConfig{
ColorFiring: "purple",
ColorResolved: "green",
Color: `{{ if eq .Status "firing" }}purple{{ else }}green{{ end }}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the mix of template files and inlined templating I'm not yet sure about.
Then again, this is one of a bunch of configs taken from the old implementation that are not backed by an implementation.

Maybe it makes sense to remove these as well to start unbiased by the old structure when adding new integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with kicking this one down to the default.tmpl. For things this brief I was thinking it may make sense to do it inline.

There's a few other equivalents that can be replaced by an if in templates, mostly color related.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually fine with that. This was just the first one I saw. But it's consistent what is happening in other places below 👍

@fabxc
Copy link
Contributor

fabxc commented Nov 18, 2015

Needs rebase.

@brian-brazil
Copy link
Contributor Author

Needs rebase.

I've already done so, I suspect you accidentally --forced over #144 so the datadir change is coming up again.

- Cut back to bare minimum to make the rest simpler
- Consistency in config naming
- Have one data strucutre that's the same for all templates
- Pass in common labels to templates
- Support templates almost everywhere
- Support multiple SMTP recipients
- Support non-ASCII SMTP headers
- Handle colour logic via templates
- Make $subjects have consistent output, go maps aren't sorted.
- Make tests pass when v6 is disabled
Status string
Alerts []TemplateAlert
AlertCommonLabels map[string]string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't see any use for common annotations? Both suffer from the problem of changing as more alerts are sorted into the group. But if for example summary is common across all of them, that can be useful for some templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the use case is as strong as for labels, I can see potential use but only in a similar way to what I'm doing to subject which won't tend to have space to fit a summary. I figure a wait and see approach is best, we can always add it in later.

@fabxc
Copy link
Contributor

fabxc commented Nov 18, 2015

Okay, let's merge so we have the base in place 🚢

fabxc added a commit that referenced this pull request Nov 18, 2015
First-pass at improving template system.
@fabxc fabxc merged commit a94c0f4 into dev Nov 18, 2015
@fabxc fabxc deleted the new-email branch November 18, 2015 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants