Skip to content

Commit 7b14ddd

Browse files
authored
Merge branch 'master' into SMPROD-17327
2 parents 79a6138 + 67f37a1 commit 7b14ddd

14 files changed

+1684
-1093
lines changed

sysdig/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@ const (
8989
SchemaCloudProviderAlias = "provider_alias"
9090
SchemaAccountId = "account_id"
9191
SchemaFeatureFlags = "flags"
92+
SchemaProviderPartition = "provider_partition"
9293
)

sysdig/data_source_sysdig_secure_onboarding.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,62 @@ func dataSourceSysdigSecureCloudIngestionAssetsRead(ctx context.Context, d *sche
400400
return nil
401401
}
402402

403+
func dataSourceSysdigSecureTrustedOracleApp() *schema.Resource {
404+
timeout := 5 * time.Minute
405+
406+
return &schema.Resource{
407+
ReadContext: dataSourceSysdigSecureTrustedOracleAppRead,
408+
409+
Timeouts: &schema.ResourceTimeout{
410+
Read: schema.DefaultTimeout(timeout),
411+
},
412+
413+
Schema: map[string]*schema.Schema{
414+
"name": {
415+
Type: schema.TypeString,
416+
Required: true,
417+
ValidateFunc: validation.StringInSlice([]string{"config_posture", "onboarding"}, false),
418+
},
419+
"tenancy_ocid": {
420+
Type: schema.TypeString,
421+
Computed: true,
422+
},
423+
"group_ocid": {
424+
Type: schema.TypeString,
425+
Computed: true,
426+
},
427+
"user_ocid": {
428+
Type: schema.TypeString,
429+
Computed: true,
430+
},
431+
},
432+
}
433+
}
434+
435+
// Retrieves the information of a resource from the file and loads it in Terraform
436+
func dataSourceSysdigSecureTrustedOracleAppRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
437+
client, err := getSecureOnboardingClient(meta.(SysdigClients))
438+
if err != nil {
439+
return diag.FromErr(err)
440+
}
441+
442+
app := d.Get("name").(string)
443+
trustedIdentityGroup, err := client.GetTrustedOracleAppSecure(ctx, app)
444+
if err != nil {
445+
return diag.FromErr(err)
446+
}
447+
d.SetId(app)
448+
for k, v := range trustedIdentityGroup {
449+
fmt.Printf("%s, %s\n", k, snakeCase(k))
450+
err = d.Set(snakeCase(k), v)
451+
if err != nil {
452+
return diag.FromErr(err)
453+
}
454+
}
455+
456+
return nil
457+
}
458+
403459
var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
404460
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
405461

sysdig/data_source_sysdig_secure_onboarding_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,44 @@ func TestAccCloudIngestionAssetsDataSource(t *testing.T) {
191191
},
192192
})
193193
}
194+
195+
func TestAccTrustedOracleAppDataSource(t *testing.T) {
196+
resource.ParallelTest(t, resource.TestCase{
197+
PreCheck: func() {
198+
if v := os.Getenv("SYSDIG_SECURE_API_TOKEN"); v == "" {
199+
t.Fatal("SYSDIG_SECURE_API_TOKEN must be set for acceptance tests")
200+
}
201+
},
202+
ProviderFactories: map[string]func() (*schema.Provider, error){
203+
"sysdig": func() (*schema.Provider, error) {
204+
return sysdig.Provider(), nil
205+
},
206+
},
207+
Steps: []resource.TestStep{
208+
{
209+
Config: `data "sysdig_secure_trusted_oracle_app" "invalid" { name = "invalid" }`,
210+
ExpectError: regexp.MustCompile(`.*expected name to be one of.*`),
211+
},
212+
{
213+
Config: `data "sysdig_secure_trusted_oracle_app" "config_posture" { name = "config_posture" }`,
214+
Check: resource.ComposeTestCheckFunc(
215+
resource.TestCheckResourceAttr("data.sysdig_secure_trusted_oracle_app.config_posture", "name", "config_posture"),
216+
// not asserting the oci exported fields because not every backend environment is oci supported yet and thus will have empty values
217+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.config_posture", "tenancy_ocid"), // uncomment to assert a non empty value
218+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.config_posture", "group_ocid"), // uncomment to assert a non empty value
219+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.config_posture", "user_ocid"), // uncomment to assert a non empty value
220+
),
221+
},
222+
{
223+
Config: `data "sysdig_secure_trusted_oracle_app" "onboarding" { name = "onboarding" }`,
224+
Check: resource.ComposeTestCheckFunc(
225+
resource.TestCheckResourceAttr("data.sysdig_secure_trusted_oracle_app.onboarding", "name", "onboarding"),
226+
// not asserting the oci exported fields because not every backend environment is oci supported yet and thus will have empty values
227+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.onboarding", "tenancy_ocid"), // uncomment to assert a non empty value
228+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.onboarding", "group_ocid"), // uncomment to assert a non empty value
229+
// resource.TestCheckResourceAttrSet("data.sysdig_secure_trusted_oracle_app.onboarding", "user_ocid"), // uncomment to assert a non empty value
230+
),
231+
},
232+
},
233+
})
234+
}

sysdig/data_source_sysdig_secure_rule_falco_count_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
func TestAccRuleFalcoCountDataSource(t *testing.T) {
1818
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
1919

20-
resource.ParallelTest(t, resource.TestCase{
20+
resource.Test(t, resource.TestCase{
2121
PreCheck: func() {
2222
if v := os.Getenv("SYSDIG_SECURE_API_TOKEN"); v == "" {
2323
t.Fatal("SYSDIG_SECURE_API_TOKEN must be set for acceptance tests")

sysdig/data_source_sysdig_secure_rule_falco_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestAccRuleFalcoDataSource(t *testing.T) {
1818
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
1919
rTextForAppendTest := rText()
2020

21-
resource.ParallelTest(t, resource.TestCase{
21+
resource.Test(t, resource.TestCase{
2222
PreCheck: func() {
2323
if v := os.Getenv("SYSDIG_SECURE_API_TOKEN"); v == "" {
2424
t.Fatal("SYSDIG_SECURE_API_TOKEN must be set for acceptance tests")

0 commit comments

Comments
 (0)