Skip to content

Commit 9bcd30b

Browse files
committed
fix(ci): restore or remove env var from tests
1 parent 751683a commit 9bcd30b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

sysdig/resource_sysdig_secure_accept_vulnerability_risk_test.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,28 @@ import (
1212
)
1313

1414
func TestAcceptSecureVulnerabilityRisk(t *testing.T) {
15-
resource.ParallelTest(t, resource.TestCase{
15+
// Temporal hack to validate the resource in the CI.
16+
// The endpoint https://secure.sysdig.com cannot be used for this, and is the default if the env var is not provided.
17+
// It works in all other regions but US1, in US1 you need to specify https://api.us1.sysdig.com. The fix is on it's way.
18+
// We only need this for the tests to pass. A workaround for this bug can be applied by users by specifying a new alias
19+
// provider and specifying the concrete url for this alias provider.
20+
url, urlSet := os.LookupEnv("SYSDIG_SECURE_URL")
21+
if url == "https://secure.sysdig.com" || url == "" {
22+
os.Setenv("SYSDIG_SECURE_URL", "https://api.us1.sysdig.com")
23+
}
24+
25+
defer func() {
26+
if urlSet {
27+
os.Setenv("SYSDIG_SECURE_URL", url)
28+
} else {
29+
os.Unsetenv("SYSDIG_SECURE_URL")
30+
}
31+
}()
32+
33+
resource.Test(t, resource.TestCase{
1634
PreCheck: preCheckAnyEnv(t, SysdigSecureApiTokenEnv),
1735
ProviderFactories: map[string]func() (*schema.Provider, error){
1836
"sysdig": func() (*schema.Provider, error) {
19-
// Temporal hack to validate the resource in the CI.
20-
// The endpoint https://secure.sysdig.com cannot be used for this, and is the default if the env var is not provided.
21-
// It works in all other regions but US1, in US1 you need to specify https://api.us1.sysdig.com. The fix is on it's way.
22-
// We only need this for the tests to pass. A workaround for this bug can be applied by users by specifying a new alias
23-
// provider and specifying the concrete url for this alias provider.
24-
if url := os.Getenv("SYSDIG_SECURE_URL"); url == "https://secure.sysdig.com" || url == "" {
25-
os.Setenv("SYSDIG_SECURE_URL", "https://api.us1.sysdig.com")
26-
}
2737
return sysdig.Provider(), nil
2838
},
2939
},

0 commit comments

Comments
 (0)