Skip to content

Commit

Permalink
fix: Add creation/updation of synthetic(simple/browser) monitor with …
Browse files Browse the repository at this point in the history
…empty custom headers (#2725)
  • Loading branch information
vagrawal-newrelic authored Aug 7, 2024
1 parent 2380cf8 commit fc00727
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/newrelic/go-agent/v3 v3.30.0
github.com/newrelic/go-insights v1.0.3
github.com/newrelic/newrelic-client-go/v2 v2.42.0
github.com/newrelic/newrelic-client-go/v2 v2.42.1
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ github.com/newrelic/go-agent/v3 v3.30.0 h1:ZXHCT/Cot4iIPwcegCZURuRQOsfmGA6wilW+S
github.com/newrelic/go-agent/v3 v3.30.0/go.mod h1:9utrgxlSryNqRrTvII2XBL+0lpofXbqXApvVWPpbzUg=
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/v2 v2.42.0 h1:XWZWKF9bjYG8TXuBNwNosG+QnZaltnJahgsfcQxvdDo=
github.com/newrelic/newrelic-client-go/v2 v2.42.0/go.mod h1:pDFY24/6iIMEbPIdowTRrRn9YYwkXc3j+B+XpTb4oF4=
github.com/newrelic/newrelic-client-go/v2 v2.42.1 h1:IztJJ2coZaU87y1MZfKueGO/setV/zIYC5Yamg7Mxi0=
github.com/newrelic/newrelic-client-go/v2 v2.42.1/go.mod h1:pDFY24/6iIMEbPIdowTRrRn9YYwkXc3j+B+XpTb4oF4=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
Expand Down
2 changes: 1 addition & 1 deletion newrelic/resource_newrelic_synthetics_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func TestSyntheticsSimpleBrowserMonitor_PeriodInMinutes(t *testing.T) {
AdvancedOptions: synthetics.SyntheticsSimpleBrowserMonitorAdvancedOptionsInput{
EnableScreenshotOnFailureAndScript: &tv,
ResponseValidationText: "SUCCESS",
CustomHeaders: []synthetics.SyntheticsCustomHeaderInput{
CustomHeaders: &[]synthetics.SyntheticsCustomHeaderInput{
{
Name: "Monitor",
Value: "Synthetics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func buildSyntheticsSimpleBrowserMonitor(d *schema.ResourceData) (synthetics.Syn
AdvancedOptions: synthetics.SyntheticsSimpleBrowserMonitorAdvancedOptionsInput{},
}

if v, ok := d.GetOk("custom_header"); ok {
simpleBrowserMonitorInput.AdvancedOptions.CustomHeaders = expandSyntheticsCustomHeaders(v.(*schema.Set).List())
}
//Initializing an empty slice of CustomHeader if no custom headers block is provided in TF config.
t := expandSyntheticsCustomHeaders(d.Get("custom_header").(*schema.Set).List())
simpleBrowserMonitorInput.AdvancedOptions.CustomHeaders = &t

if v, ok := d.GetOk("uri"); ok {
simpleBrowserMonitorInput.Uri = v.(string)
Expand Down Expand Up @@ -107,9 +107,9 @@ func buildSyntheticsSimpleBrowserMonitorUpdateStruct(d *schema.ResourceData) (sy
AdvancedOptions: synthetics.SyntheticsSimpleBrowserMonitorAdvancedOptionsInput{},
}

if v, ok := d.GetOk("custom_header"); ok {
simpleBrowserMonitorUpdateInput.AdvancedOptions.CustomHeaders = expandSyntheticsCustomHeaders(v.(*schema.Set).List())
}
//Initializing an empty slice of CustomHeader if no custom headers block is provided in TF config.
t := expandSyntheticsCustomHeaders(d.Get("custom_header").(*schema.Set).List())
simpleBrowserMonitorUpdateInput.AdvancedOptions.CustomHeaders = &t

if v, ok := d.GetOk("uri"); ok {
simpleBrowserMonitorUpdateInput.Uri = v.(string)
Expand Down
12 changes: 6 additions & 6 deletions newrelic/structures_newrelic_synthetics_simple_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func buildSyntheticsSimpleMonitor(d *schema.ResourceData) synthetics.SyntheticsC
simpleMonitorInput.Status = inputBase.Status
simpleMonitorInput.Tags = inputBase.Tags

if v, ok := d.GetOk("custom_header"); ok {
simpleMonitorInput.AdvancedOptions.CustomHeaders = expandSyntheticsCustomHeaders(v.(*schema.Set).List())
}
//Initializing an empty slice of CustomHeader if no custom headers block is provided in TF config.
t := expandSyntheticsCustomHeaders(d.Get("custom_header").(*schema.Set).List())
simpleMonitorInput.AdvancedOptions.CustomHeaders = &t

if v, ok := d.GetOk("uri"); ok {
simpleMonitorInput.Uri = v.(string)
Expand Down Expand Up @@ -63,9 +63,9 @@ func buildSyntheticsSimpleMonitorUpdateStruct(d *schema.ResourceData) synthetics
simpleMonitorUpdateInput.Status = inputBase.Status
simpleMonitorUpdateInput.Tags = inputBase.Tags

if v, ok := d.GetOk("custom_header"); ok {
simpleMonitorUpdateInput.AdvancedOptions.CustomHeaders = expandSyntheticsCustomHeaders(v.(*schema.Set).List())
}
//Initializing an empty slice of CustomHeader if no custom headers block is provided in TF config.
t := expandSyntheticsCustomHeaders(d.Get("custom_header").(*schema.Set).List())
simpleMonitorUpdateInput.AdvancedOptions.CustomHeaders = &t

if v, ok := d.GetOk("uri"); ok {
simpleMonitorUpdateInput.Uri = v.(string)
Expand Down

0 comments on commit fc00727

Please sign in to comment.