@@ -85,6 +85,12 @@ is required). Updating one will unset the other automatically.
85
85
group is the group, as seen by the kubernetes cluster.` ,
86
86
ExactlyOneOf : []string {"user" , "group" },
87
87
},
88
+ "labels" : {
89
+ Type : schema .TypeMap ,
90
+ Optional : true ,
91
+ Description : `Labels for this ScopeRBACRoleBinding.` ,
92
+ Elem : & schema.Schema {Type : schema .TypeString },
93
+ },
88
94
"user" : {
89
95
Type : schema .TypeString ,
90
96
Optional : true ,
@@ -170,6 +176,12 @@ func resourceGKEHub2ScopeRBACRoleBindingCreate(d *schema.ResourceData, meta inte
170
176
} else if v , ok := d .GetOkExists ("role" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (roleProp )) && (ok || ! reflect .DeepEqual (v , roleProp )) {
171
177
obj ["role" ] = roleProp
172
178
}
179
+ labelsProp , err := expandGKEHub2ScopeRBACRoleBindingLabels (d .Get ("labels" ), d , config )
180
+ if err != nil {
181
+ return err
182
+ } else if v , ok := d .GetOkExists ("labels" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (labelsProp )) && (ok || ! reflect .DeepEqual (v , labelsProp )) {
183
+ obj ["labels" ] = labelsProp
184
+ }
173
185
174
186
url , err := tpgresource .ReplaceVars (d , config , "{{GKEHub2BasePath}}projects/{{project}}/locations/global/scopes/{{scope_id}}/rbacrolebindings/?rbacrolebinding_id={{scope_rbac_role_binding_id}}" )
175
187
if err != nil {
@@ -306,6 +318,9 @@ func resourceGKEHub2ScopeRBACRoleBindingRead(d *schema.ResourceData, meta interf
306
318
if err := d .Set ("role" , flattenGKEHub2ScopeRBACRoleBindingRole (res ["role" ], d , config )); err != nil {
307
319
return fmt .Errorf ("Error reading ScopeRBACRoleBinding: %s" , err )
308
320
}
321
+ if err := d .Set ("labels" , flattenGKEHub2ScopeRBACRoleBindingLabels (res ["labels" ], d , config )); err != nil {
322
+ return fmt .Errorf ("Error reading ScopeRBACRoleBinding: %s" , err )
323
+ }
309
324
310
325
return nil
311
326
}
@@ -344,6 +359,12 @@ func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta inte
344
359
} else if v , ok := d .GetOkExists ("role" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , roleProp )) {
345
360
obj ["role" ] = roleProp
346
361
}
362
+ labelsProp , err := expandGKEHub2ScopeRBACRoleBindingLabels (d .Get ("labels" ), d , config )
363
+ if err != nil {
364
+ return err
365
+ } else if v , ok := d .GetOkExists ("labels" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , labelsProp )) {
366
+ obj ["labels" ] = labelsProp
367
+ }
347
368
348
369
url , err := tpgresource .ReplaceVars (d , config , "{{GKEHub2BasePath}}projects/{{project}}/locations/global/scopes/{{scope_id}}/rbacrolebindings/{{scope_rbac_role_binding_id}}" )
349
370
if err != nil {
@@ -364,6 +385,10 @@ func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta inte
364
385
if d .HasChange ("role" ) {
365
386
updateMask = append (updateMask , "role" )
366
387
}
388
+
389
+ if d .HasChange ("labels" ) {
390
+ updateMask = append (updateMask , "labels" )
391
+ }
367
392
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
368
393
// won't set it
369
394
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -538,6 +563,10 @@ func flattenGKEHub2ScopeRBACRoleBindingRolePredefinedRole(v interface{}, d *sche
538
563
return v
539
564
}
540
565
566
+ func flattenGKEHub2ScopeRBACRoleBindingLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
567
+ return v
568
+ }
569
+
541
570
func expandGKEHub2ScopeRBACRoleBindingUser (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
542
571
return v , nil
543
572
}
@@ -568,3 +597,14 @@ func expandGKEHub2ScopeRBACRoleBindingRole(v interface{}, d tpgresource.Terrafor
568
597
func expandGKEHub2ScopeRBACRoleBindingRolePredefinedRole (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
569
598
return v , nil
570
599
}
600
+
601
+ func expandGKEHub2ScopeRBACRoleBindingLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
602
+ if v == nil {
603
+ return map [string ]string {}, nil
604
+ }
605
+ m := make (map [string ]string )
606
+ for k , val := range v .(map [string ]interface {}) {
607
+ m [k ] = val .(string )
608
+ }
609
+ return m , nil
610
+ }
0 commit comments