|
| 1 | +//go:build tf_acc_ibm |
| 2 | + |
| 3 | +package sysdig_test |
| 4 | + |
| 5 | +import ( |
| 6 | + "fmt" |
| 7 | + "os" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" |
| 11 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 12 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| 13 | + |
| 14 | + "github.com/draios/terraform-provider-sysdig/sysdig" |
| 15 | +) |
| 16 | + |
| 17 | +func TestAccMonitorIBMTeam(t *testing.T) { |
| 18 | + rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) } |
| 19 | + |
| 20 | + resource.ParallelTest(t, resource.TestCase{ |
| 21 | + PreCheck: func() { |
| 22 | + if v := os.Getenv("SYSDIG_IBM_MONITOR_API_KEY"); v == "" { |
| 23 | + t.Fatal("SYSDIG_IBM_MONITOR_API_KEY must be set for acceptance tests") |
| 24 | + } |
| 25 | + }, |
| 26 | + ProviderFactories: map[string]func() (*schema.Provider, error){ |
| 27 | + "sysdig": func() (*schema.Provider, error) { |
| 28 | + return sysdig.Provider(), nil |
| 29 | + }, |
| 30 | + }, |
| 31 | + Steps: []resource.TestStep{ |
| 32 | + { |
| 33 | + Config: monitorTeamMinimumConfiguration(rText()), |
| 34 | + }, |
| 35 | + { |
| 36 | + Config: monitorTeamWithName(rText()), |
| 37 | + }, |
| 38 | + { |
| 39 | + Config: monitorTeamWithFullConfigIBM(rText()), |
| 40 | + }, |
| 41 | + { |
| 42 | + ResourceName: "sysdig_monitor_team.sample", |
| 43 | + ImportState: true, |
| 44 | + ImportStateVerify: true, |
| 45 | + }, |
| 46 | + }, |
| 47 | + }) |
| 48 | +} |
| 49 | + |
| 50 | +func monitorTeamWithFullConfigIBM(name string) string { |
| 51 | + return fmt.Sprintf(` |
| 52 | +resource "sysdig_monitor_team" "sample" { |
| 53 | + name = "sample-%s" |
| 54 | + description = "%s" |
| 55 | + scope_by = "host" |
| 56 | + filter = "container.image.repo = \"sysdig/agent\"" |
| 57 | + can_use_sysdig_capture = true |
| 58 | + can_see_infrastructure_events = true |
| 59 | + |
| 60 | + entrypoint { |
| 61 | + type = "Dashboards" |
| 62 | + } |
| 63 | +}`, name, name) |
| 64 | +} |
0 commit comments