Skip to content

Commit

Permalink
fix(synthetics): allow new -> legacy runtime downgrade until Oct 22 f…
Browse files Browse the repository at this point in the history
…or simple browser, scripted monitors
  • Loading branch information
pranav-new-relic committed Aug 30, 2024
1 parent d415d1d commit cf76c2e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions newrelic/structures_newrelic_synthetics_script_api_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ func buildSyntheticsScriptAPIMonitorInput(d *schema.ResourceData) synthetics.Syn
_, runtimeTypeOk := d.GetOk("runtime_type")
_, runtimeVersionOk := d.GetOk("runtime_type_version")

input.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeVersionOk {
input.Runtime = &synthetics.SyntheticsRuntimeInput{}

if v, ok := d.GetOk("script_language"); ok {
input.Runtime.ScriptLanguage = v.(string)
}
Expand All @@ -39,6 +38,9 @@ func buildSyntheticsScriptAPIMonitorInput(d *schema.ResourceData) synthetics.Syn
if v, ok := d.GetOk("runtime_type_version"); ok {
input.Runtime.RuntimeTypeVersion = synthetics.SemVer(v.(string))
}
} else {
input.Runtime.RuntimeType = ""
input.Runtime.RuntimeTypeVersion = ""
}

return input
Expand Down Expand Up @@ -66,9 +68,8 @@ func buildSyntheticsScriptAPIMonitorUpdateInput(d *schema.ResourceData) syntheti
_, runtimeTypeOk := d.GetOk("runtime_type")
_, runtimeVersionOk := d.GetOk("runtime_type_version")

input.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeVersionOk {
input.Runtime = &synthetics.SyntheticsRuntimeInput{}

if v, ok := d.GetOk("script_language"); ok {
input.Runtime.ScriptLanguage = v.(string)
}
Expand All @@ -78,6 +79,9 @@ func buildSyntheticsScriptAPIMonitorUpdateInput(d *schema.ResourceData) syntheti
if v, ok := d.GetOk("runtime_type_version"); ok {
input.Runtime.RuntimeTypeVersion = synthetics.SemVer(v.(string))
}
} else {
input.Runtime.RuntimeType = ""
input.Runtime.RuntimeTypeVersion = ""
}

return input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ func buildSyntheticsScriptBrowserMonitorInput(d *schema.ResourceData) synthetics
runtimeType, runtimeTypeOk := d.GetOk("runtime_type")
runtimeTypeVersion, runtimeTypeVersionOk := d.GetOk("runtime_type_version")

input.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeTypeVersionOk {
input.Runtime = &synthetics.SyntheticsRuntimeInput{}

if scriptLangOk {
input.Runtime.ScriptLanguage = sciptLang.(string)
}
Expand All @@ -43,6 +42,9 @@ func buildSyntheticsScriptBrowserMonitorInput(d *schema.ResourceData) synthetics
if runtimeTypeVersionOk {
input.Runtime.RuntimeTypeVersion = synthetics.SemVer(runtimeTypeVersion.(string))
}
} else {
input.Runtime.RuntimeType = ""
input.Runtime.RuntimeTypeVersion = ""
}

enableScreenshot := d.Get("enable_screenshot_on_failure_and_script").(bool)
Expand Down Expand Up @@ -90,9 +92,8 @@ func buildSyntheticsScriptBrowserUpdateInput(d *schema.ResourceData) synthetics.
sciptLang, scriptLangOk := d.GetOk("script_language")
runtimeType, runtimeTypeOk := d.GetOk("runtime_type")
runtimeTypeVersion, runtimeTypeVersionOk := d.GetOk("runtime_type_version")
input.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeTypeVersionOk {
input.Runtime = &synthetics.SyntheticsRuntimeInput{}

if scriptLangOk {
input.Runtime.ScriptLanguage = sciptLang.(string)
}
Expand All @@ -104,6 +105,9 @@ func buildSyntheticsScriptBrowserUpdateInput(d *schema.ResourceData) synthetics.
if runtimeTypeVersionOk {
input.Runtime.RuntimeTypeVersion = synthetics.SemVer(runtimeTypeVersion.(string))
}
} else {
input.Runtime.RuntimeType = ""
input.Runtime.RuntimeTypeVersion = ""
}

enableScreenshot := d.Get("enable_screenshot_on_failure_and_script").(bool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ func buildSyntheticsSimpleBrowserMonitorRuntimeAndDeviceEmulation(d *schema.Reso
runtimeType, runtimeTypeOk := d.GetOk("runtime_type")
runtimeTypeVersion, runtimeTypeVersionOk := d.GetOk("runtime_type_version")

simpleBrowserMonitorInput.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeTypeVersionOk {
simpleBrowserMonitorInput.Runtime = &synthetics.SyntheticsRuntimeInput{}

if scriptLangOk {
simpleBrowserMonitorInput.Runtime.ScriptLanguage = scriptLang.(string)
}
Expand All @@ -74,6 +73,9 @@ func buildSyntheticsSimpleBrowserMonitorRuntimeAndDeviceEmulation(d *schema.Reso
if runtimeTypeVersionOk {
simpleBrowserMonitorInput.Runtime.RuntimeTypeVersion = synthetics.SemVer(runtimeTypeVersion.(string))
}
} else {
simpleBrowserMonitorInput.Runtime.RuntimeType = ""
simpleBrowserMonitorInput.Runtime.RuntimeTypeVersion = ""
}

do, doOk := d.GetOk("device_orientation")
Expand Down Expand Up @@ -150,9 +152,8 @@ func buildSyntheticsSimpleBrowserMonitorRuntimeAndDeviceEmulationUpdateStruct(d
runtimeType, runtimeTypeOk := d.GetOk("runtime_type")
runtimeTypeVersion, runtimeTypeVersionOk := d.GetOk("runtime_type_version")

simpleBrowserMonitorUpdateInput.Runtime = &synthetics.SyntheticsRuntimeInput{}
if scriptLangOk || runtimeTypeOk || runtimeTypeVersionOk {
simpleBrowserMonitorUpdateInput.Runtime = &synthetics.SyntheticsRuntimeInput{}

if scriptLangOk {
simpleBrowserMonitorUpdateInput.Runtime.ScriptLanguage = scriptLang.(string)
}
Expand All @@ -164,6 +165,9 @@ func buildSyntheticsSimpleBrowserMonitorRuntimeAndDeviceEmulationUpdateStruct(d
if runtimeTypeVersionOk {
simpleBrowserMonitorUpdateInput.Runtime.RuntimeTypeVersion = synthetics.SemVer(runtimeTypeVersion.(string))
}
} else {
simpleBrowserMonitorUpdateInput.Runtime.RuntimeType = ""
simpleBrowserMonitorUpdateInput.Runtime.RuntimeTypeVersion = ""
}

do, doOk := d.GetOk("device_orientation")
Expand Down

0 comments on commit cf76c2e

Please sign in to comment.