-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathdata_source_sysdig_monitor_teams.go
More file actions
59 lines (52 loc) · 1.25 KB
/
data_source_sysdig_monitor_teams.go
File metadata and controls
59 lines (52 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package sysdig
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceSysdigMonitorTeams() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceSysdigMonitorTeamsRead,
Schema: map[string]*schema.Schema{
"teams": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}
func dataSourceSysdigMonitorTeamsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
clients := meta.(SysdigClients)
client, err := getMonitorTeamClient(clients)
if err != nil {
return diag.FromErr(err)
}
teams, err := client.ListTeams(ctx)
if err != nil {
return diag.FromErr(err)
}
var result []map[string]interface{}
for _, team := range teams {
result = append(result, map[string]interface{}{
"id": team.ID,
"name": team.Name,
})
}
d.SetId("sysdig_monitor_teams")
if err := d.Set("teams", result); err != nil {
return diag.FromErr(err)
}
return nil
}