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

fix(alert_channels): handle more complex JSON structures in payload or headers #361

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk v1.5.0
github.com/newrelic/go-agent/v3 v3.1.0
github.com/newrelic/go-insights v1.0.3
github.com/newrelic/newrelic-client-go v0.6.0
github.com/newrelic/newrelic-client-go v0.7.1
github.com/paultyng/go-newrelic/v4 v4.10.0
github.com/stretchr/testify v1.4.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ github.com/newrelic/go-agent/v3 v3.1.0 h1:fd3ILrFgoLOrVrCo9ZGrQ7JwGC/cw8eh7yEbOu
github.com/newrelic/go-agent/v3 v3.1.0/go.mod h1:H28zDNUC0U/b7kLoY4EFOhuth10Xu/9dchozUiOseQQ=
github.com/newrelic/go-insights v1.0.3 h1:zSNp1CEZnXktzSIEsbHJk8v6ZihdPFP2WsO/fzau3OQ=
github.com/newrelic/go-insights v1.0.3/go.mod h1:A20BoT8TNkqPGX2nS/Z2fYmKl3Cqa3iKZd4whzedCY4=
github.com/newrelic/newrelic-client-go v0.6.0 h1:aZvGQTwMUH8mj0oIfXktL/ETlZJRbNOXPIL7k1JxMMQ=
github.com/newrelic/newrelic-client-go v0.6.0/go.mod h1:cy6GDp11OfIj8Wfg0jfzDycso91NcojANZUqnjU9+QM=
github.com/newrelic/newrelic-client-go v0.7.1 h1:sW9mvTHfkEqVfuVd2apPR4Xk6xvjymPJTwxleH95HvU=
github.com/newrelic/newrelic-client-go v0.7.1/go.mod h1:cy6GDp11OfIj8Wfg0jfzDycso91NcojANZUqnjU9+QM=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
Expand Down
13 changes: 2 additions & 11 deletions newrelic/structures_newrelic_alert_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ func expandAlertChannel(d *schema.ResourceData) (*alerts.Channel, error) {
return &channel, nil
}

func convertToStringMap(orig map[string]interface{}) map[string]string {
conv := make(map[string]string, len(orig))
for k, v := range orig {
conv[k] = v.(string)
}

return conv
}

func expandAlertChannelConfiguration(cfg map[string]interface{}) alerts.ChannelConfiguration {
config := alerts.ChannelConfiguration{}

Expand Down Expand Up @@ -71,7 +62,7 @@ func expandAlertChannelConfiguration(cfg map[string]interface{}) alerts.ChannelC

if headers, ok := cfg["headers"]; ok {
h := headers.(map[string]interface{})
config.Headers = convertToStringMap(h)
config.Headers = h
}

if includeJSONAttachment, ok := cfg["include_json_attachment"]; ok {
Expand All @@ -80,7 +71,7 @@ func expandAlertChannelConfiguration(cfg map[string]interface{}) alerts.ChannelC

if payload, ok := cfg["payload"]; ok {
p := payload.(map[string]interface{})
config.Payload = convertToStringMap(p)
config.Payload = p
}

if payloadType, ok := cfg["payload_type"]; ok {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 72 additions & 2 deletions vendor/github.com/newrelic/newrelic-client-go/newrelic/newrelic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading