Skip to content

Commit

Permalink
SYN-4475: Adds chrome flags to provider (#66)
Browse files Browse the repository at this point in the history
* SYN-4475: Adds chrome flags to provider

* SYN-4475: go mod vendor
  • Loading branch information
sangn-splunk authored Nov 13, 2024
1 parent ddbe58e commit c3b4941
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/splunk/syntheticsclient v1.0.3
github.com/splunk/syntheticsclient/v2 v2.0.10
github.com/splunk/syntheticsclient/v2 v2.0.12
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ github.com/splunk/syntheticsclient/v2 v2.0.9 h1:bqc43RIZzYOL5IajdJmmw4ck3clHuVy3
github.com/splunk/syntheticsclient/v2 v2.0.9/go.mod h1:xP4ikfSyA0eVyI72sa11hi9yUDBaQhB5mtW6QSClaWw=
github.com/splunk/syntheticsclient/v2 v2.0.10 h1:Hv8nlP2WIXDNQzhRz0L6gcsUDoB5mKptdOHQyakAkEw=
github.com/splunk/syntheticsclient/v2 v2.0.10/go.mod h1:xP4ikfSyA0eVyI72sa11hi9yUDBaQhB5mtW6QSClaWw=
github.com/splunk/syntheticsclient/v2 v2.0.12 h1:GfWNnpNxkgBYmkXghpo6IkbcInnKgZeaMMfqufgvaKQ=
github.com/splunk/syntheticsclient/v2 v2.0.12/go.mod h1:xP4ikfSyA0eVyI72sa11hi9yUDBaQhB5mtW6QSClaWw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down
16 changes: 16 additions & 0 deletions synthetics/data_source_browsercheck_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ func dataSourceBrowserCheckV2() *schema.Resource {
},
},
},
"chrome_flags": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"value": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"cookies": {
Type: schema.TypeSet,
Computed: true,
Expand Down
16 changes: 16 additions & 0 deletions synthetics/resource_browser_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ func resourceBrowserCheckV2() *schema.Resource {
},
},
},
"chrome_flags": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
},
"value": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"cookies": {
Type: schema.TypeSet,
Optional: true,
Expand Down
24 changes: 24 additions & 0 deletions synthetics/resource_browser_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
domain = "zodiak.com"
path = "/Edlesley"
}
chrome_flags {
name = "--proxy-server"
value = "my-proxy-server:80"
}
chrome_flags {
name = "--proxy-bypass-list"
value = "127.0.0.1:8080"
}
host_overrides {
source = "asdasd.com"
target = "whost.com"
Expand Down Expand Up @@ -200,6 +208,14 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
domain = "zodiak.com"
path = "/Edlesley"
}
chrome_flags {
name = "--proxy-server"
value = "foo:80"
}
chrome_flags {
name = "--proxy-bypass-list"
value = "*google.com"
}
host_overrides {
source = "asdasd.com"
target = "whost.com"
Expand Down Expand Up @@ -329,6 +345,10 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.value", "no"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.domain", "zodiak.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.path", "/Edlesley"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.0.name", "--proxy-bypass-list"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.0.value", "127.0.0.1:8080"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.1.name", "--proxy-server"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.1.value", "my-proxy-server:80"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.source", "asdasd.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.target", "whost.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.keep_host_header", "false"),
Expand Down Expand Up @@ -419,6 +439,10 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.value", "no"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.domain", "zodiak.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.cookies.1.path", "/Edlesley"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.0.name", "--proxy-bypass-list"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.0.value", "*google.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.1.name", "--proxy-server"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.chrome_flags.1.value", "foo:80"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.source", "asdasd.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.target", "whost.com"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.advanced_settings.0.host_overrides.0.keep_host_header", "false"),
Expand Down
34 changes: 34 additions & 0 deletions synthetics/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,23 @@ func flattenStepsData(checkSteps *[]sc2.StepsV2) []interface{} {
return make([]interface{}, 0)
}

func flattenChromeFlagsData(chromeFlags []sc2.ChromeFlag) []interface{} {
if chromeFlags == nil {
return []interface{}{}
}

var result []interface{}
for _, flag := range chromeFlags {
flagData := map[string]interface{}{
"name": flag.Name,
"value": flag.Value,
}
result = append(result, flagData)
}

return result
}

func flattenSetupData(checkSetup *[]sc2.Setup) []interface{} {
if checkSetup != nil {
cls := make([]interface{}, len(*checkSetup))
Expand Down Expand Up @@ -1285,6 +1302,9 @@ func flattenAdvancedSettingsData(advSettings *sc2.Advancedsettings) []interface{
HostOverRides := flattenHostOverridesData(&advSettings.HostOverrides)
advancedSettings["host_overrides"] = HostOverRides

ChromeFlags := flattenChromeFlagsData(advSettings.ChromeFlags)
advancedSettings["chrome_flags"] = ChromeFlags

return []interface{}{advancedSettings}
}

Expand Down Expand Up @@ -1607,6 +1627,8 @@ func buildAdvancedSettingsData(advancedSettings *schema.Set) sc2.Advancedsetting
advancedSettingsData.BrowserHeaders = buildBrowserHeadersData(as_map["headers"].(*schema.Set))
advancedSettingsData.Cookiesv2 = buildCookiesData(as_map["cookies"].(*schema.Set))
advancedSettingsData.HostOverrides = buildHostOverridesData(as_map["host_overrides"].(*schema.Set))
advancedSettingsData.ChromeFlags = buildChromeFlagsData(as_map["chrome_flags"].(*schema.Set))

}
return advancedSettingsData
}
Expand All @@ -1627,6 +1649,18 @@ func buildBrowserHeadersData(headers *schema.Set) []sc2.BrowserHeaders {
return headersList
}

func buildChromeFlagsData(d *schema.Set) []sc2.ChromeFlag {
var flags []sc2.ChromeFlag
for _, item := range d.List() {
data := item.(map[string]interface{})
flags = append(flags, sc2.ChromeFlag{
Name: data["name"].(string),
Value: data["value"].(string),
})
}
return flags
}

func buildCookiesData(cookies *schema.Set) []sc2.Cookiesv2 {
cookiesList := make([]sc2.Cookiesv2, len(cookies.List()))

Expand Down

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ github.com/oklog/run
# github.com/splunk/syntheticsclient v1.0.3
## explicit; go 1.14
github.com/splunk/syntheticsclient/syntheticsclient
# github.com/splunk/syntheticsclient/v2 v2.0.10
# github.com/splunk/syntheticsclient/v2 v2.0.12
## explicit; go 1.14
github.com/splunk/syntheticsclient/v2/syntheticsclientv2
# github.com/vmihailenco/msgpack v4.0.4+incompatible
Expand Down

0 comments on commit c3b4941

Please sign in to comment.