Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
new release 1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
betorvs committed Aug 3, 2021
1 parent 6f413b1 commit 0bc48c2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

## [1.0.6] - 2021-08-03
### Added
- flag `--aliasTemplate` to make opsgenie alias as Template.

## [1.0.5] - 2021-05-30
### Changed
- flag `--team` and `--schedule-team` and `--escalation-team` now can be used with multiple values splited by comma. This limit still existing from Opsgenie documentation ` If the API Key belongs to a team integration, this field will be overwritten with the owner team. ` [opsgenie api docs](https://docs.opsgenie.com/docs/alert-api#create-alert) This [issue](https://github.com/opsgenie/opsgenie-go-sdk-v2/issues/81) is about how to handle with this.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Available Commands:

Flags:
--addHooksToDetails Include the checks.hooks in details to send to OpsGenie
-A, --aliasTemplate string The template for the alias to be sent (default "{{.Entity.Name}}/{{.Check.Name}}")
-a, --auth string The OpsGenie API authentication token, use default from OPSGENIE_AUTHTOKEN env var
-L, --descriptionLimit int The maximum length of the description field (default 15000)
-d, --descriptionTemplate string The template for the description to be sent (default "{{.Check.Output}}")
Expand Down
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Config struct {
VisibilityTeams string
Priority string
SensuDashboard string
AliasTemplate string
MessageTemplate string
MessageLimit int
DescriptionTemplate string
Expand Down Expand Up @@ -132,6 +133,15 @@ var (
Usage: "The OpsGenie Handler will use it to create a source Sensu Dashboard URL. Use OPSGENIE_SENSU_DASHBOARD. Example: http://sensu-dashboard.example.local/c/~/n",
Value: &plugin.SensuDashboard,
},
{
Path: "aliasTemplate",
Env: "OPSGENIE_ALIAS_TEMPLATE",
Argument: "aliasTemplate",
Shorthand: "A",
Default: "{{.Entity.Name}}/{{.Check.Name}}",
Usage: "The template for the alias to be sent",
Value: &plugin.AliasTemplate,
},
{
Path: "messageTemplate",
Env: "OPSGENIE_MESSAGE_TEMPLATE",
Expand Down Expand Up @@ -325,7 +335,12 @@ func parseActions(event *types.Event) (output []string) {
// second string contains Entity.Name/Check.Name to use in alias
// []string contains Entity.Name Check.Name Entity.Namespace, event.Entity.EntityClass to use as tags in Opsgenie
func parseEventKeyTags(event *types.Event) (title string, alias string, tags []string) {
alias = fmt.Sprintf("%s/%s", event.Entity.Name, event.Check.Name)
alias, err1 := templates.EvalTemplate("title", plugin.AliasTemplate, event)
if err1 != nil {
return "", "", []string{}
}

// alias = fmt.Sprintf("%s/%s", event.Entity.Name, event.Check.Name)
title, err := templates.EvalTemplate("title", plugin.MessageTemplate, event)
if err != nil {
return "", "", []string{}
Expand Down
1 change: 1 addition & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func TestParseEventKeyTags(t *testing.T) {
_, err := json.Marshal(event)
assert.NoError(t, err)
plugin.MessageTemplate = "{{.Entity.Name}}/{{.Check.Name}}"
plugin.AliasTemplate = "{{.Entity.Name}}/{{.Check.Name}}"
plugin.MessageLimit = 100
plugin.TagsTemplates = []string{"{{.Entity.Name}}", "{{.Check.Name}}", "{{.Entity.Namespace}}", "{{.Entity.EntityClass}}"}
title, alias, tags := parseEventKeyTags(event)
Expand Down

0 comments on commit 0bc48c2

Please sign in to comment.