@@ -53,6 +53,14 @@ func resourceSysdigSecureTeam() *schema.Resource {
5353 Type : schema .TypeString ,
5454 Optional : true ,
5555 },
56+ "enable_ibm_platform_metrics" : {
57+ Type : schema .TypeBool ,
58+ Optional : true ,
59+ },
60+ "ibm_platform_metrics" : {
61+ Type : schema .TypeString ,
62+ Optional : true ,
63+ },
5664 "use_sysdig_capture" : {
5765 Type : schema .TypeBool ,
5866 Optional : true ,
@@ -90,13 +98,32 @@ func resourceSysdigSecureTeam() *schema.Resource {
9098 }
9199}
92100
101+ func getSecureTeamClient (c SysdigClients ) (v2.TeamInterface , error ) {
102+ var client v2.TeamInterface
103+ var err error
104+ switch c .GetClientType () {
105+ case IBMSecure :
106+ client , err = c .ibmSecureClient ()
107+ if err != nil {
108+ return nil , err
109+ }
110+ default :
111+ client , err = c .sysdigSecureClientV2 ()
112+ if err != nil {
113+ return nil , err
114+ }
115+ }
116+ return client , nil
117+ }
118+
93119func resourceSysdigSecureTeamCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
94- client , err := meta .(SysdigClients ).sysdigSecureClientV2 ()
120+ clients := meta .(SysdigClients )
121+ client , err := getSecureTeamClient (clients )
95122 if err != nil {
96123 return diag .FromErr (err )
97124 }
98125
99- team := secureTeamFromResourceData (d )
126+ team := secureTeamFromResourceData (d , clients . GetClientType () )
100127 team .Products = []string {"SDS" }
101128
102129 team , err = client .CreateTeam (ctx , team )
@@ -106,13 +133,15 @@ func resourceSysdigSecureTeamCreate(ctx context.Context, d *schema.ResourceData,
106133
107134 d .SetId (strconv .Itoa (team .ID ))
108135 _ = d .Set ("version" , team .Version )
136+ resourceSysdigSecureTeamRead (ctx , d , meta )
109137
110138 return nil
111139}
112140
113141// Retrieves the information of a resource form the file and loads it in Terraform
114142func resourceSysdigSecureTeamRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
115- client , err := meta .(SysdigClients ).sysdigSecureClientV2 ()
143+ clients := meta .(SysdigClients )
144+ client , err := getSecureTeamClient (clients )
116145 if err != nil {
117146 return diag .FromErr (err )
118147 }
@@ -135,6 +164,10 @@ func resourceSysdigSecureTeamRead(ctx context.Context, d *schema.ResourceData, m
135164 _ = d .Set ("default_team" , t .DefaultTeam )
136165 _ = d .Set ("user_roles" , userSecureRolesToSet (t .UserRoles ))
137166
167+ if clients .GetClientType () == IBMSecure {
168+ resourceSysdigTeamReadIBM (d , & t )
169+ }
170+
138171 return nil
139172}
140173
@@ -153,12 +186,13 @@ func userSecureRolesToSet(userRoles []v2.UserRoles) (res []map[string]interface{
153186}
154187
155188func resourceSysdigSecureTeamUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
156- client , err := meta .(SysdigClients ).sysdigSecureClientV2 ()
189+ clients := meta .(SysdigClients )
190+ client , err := getSecureTeamClient (clients )
157191 if err != nil {
158192 return diag .FromErr (err )
159193 }
160194
161- t := secureTeamFromResourceData (d )
195+ t := secureTeamFromResourceData (d , clients . GetClientType () )
162196 t .Products = []string {"SDS" }
163197
164198 t .Version = d .Get ("version" ).(int )
@@ -169,11 +203,12 @@ func resourceSysdigSecureTeamUpdate(ctx context.Context, d *schema.ResourceData,
169203 return diag .FromErr (err )
170204 }
171205
206+ resourceSysdigSecureTeamRead (ctx , d , meta )
172207 return nil
173208}
174209
175210func resourceSysdigSecureTeamDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
176- client , err := meta .(SysdigClients ). sysdigSecureClientV2 ( )
211+ client , err := getSecureTeamClient ( meta .(SysdigClients ))
177212 if err != nil {
178213 return diag .FromErr (err )
179214 }
@@ -187,15 +222,17 @@ func resourceSysdigSecureTeamDelete(ctx context.Context, d *schema.ResourceData,
187222 return nil
188223}
189224
190- func secureTeamFromResourceData (d * schema.ResourceData ) v2.Team {
225+ func secureTeamFromResourceData (d * schema.ResourceData , clientType ClientType ) v2.Team {
191226 canUseSysdigCapture := d .Get ("use_sysdig_capture" ).(bool )
227+ canUseAwsMetrics := new (bool )
192228 t := v2.Team {
193229 Theme : d .Get ("theme" ).(string ),
194230 Name : d .Get ("name" ).(string ),
195231 Description : d .Get ("description" ).(string ),
196232 Show : d .Get ("scope_by" ).(string ),
197233 Filter : d .Get ("filter" ).(string ),
198234 CanUseSysdigCapture : & canUseSysdigCapture ,
235+ CanUseAwsMetrics : canUseAwsMetrics ,
199236 DefaultTeam : d .Get ("default_team" ).(bool ),
200237 }
201238
@@ -209,5 +246,9 @@ func secureTeamFromResourceData(d *schema.ResourceData) v2.Team {
209246 }
210247 t .UserRoles = userRoles
211248
249+ if clientType == IBMSecure {
250+ teamFromResourceDataIBM (d , & t )
251+ }
252+
212253 return t
213254}
0 commit comments