Skip to content
Open
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
23 changes: 18 additions & 5 deletions synthetics/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package synthetics
import (
"context"
"regexp"
"strings"

sc2 "github.com/splunk/syntheticsclient/v2/syntheticsclientv2"

Expand Down Expand Up @@ -48,6 +49,12 @@ func Provider() *schema.Provider {
Description: "Splunk Observability Realm (E.G. `us1`). Will pull from `REALM` environment variable if available. For Rigor use realm rigor",
DefaultFunc: schema.EnvDefaultFunc("REALM", nil),
},
"apiurl": {
Type: schema.TypeString,
Optional: true,
Description: "Splunk Observability Realm API Endpoint (E.G. `https://api.<REALM>.signalfx.com`). Will pull from `API_URL` environment variable if available.",
DefaultFunc: schema.EnvDefaultFunc("API_URL", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"synthetics_create_http_check": resourceHttpCheck(),
Expand Down Expand Up @@ -82,28 +89,34 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
token := d.Get("apikey").(string)
realm := d.Get("realm").(string)
product := d.Get("product").(string)
apiurl := d.Get("apiurl").(string)

var diags diag.Diagnostics

if product == "observability" {
if token != "" && realm != "" {
c := sc2.NewClient(token, realm)
if apiurl != "" {
args := sc2.NewClientArgs(
30,
strings.TrimSuffix(apiurl, "/")+"/v2/synthetics",
)
c := sc2.NewConfigurableClient(token, realm, args)
return c, diags
}

// Default client (no apiurl override)
c := sc2.NewClient(token, realm)
return c, diags
}

c := sc2.NewClient(token, realm)

return c, diags
} else {
if product == "rigor" && token != "" {
c := sc.NewClient(token)

return c, diags
}

c := sc.NewClient(token)

return c, diags
}
}

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

Loading