@@ -174,6 +174,23 @@ https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles`
174174 },
175175 },
176176 },
177+ "binary_authorization" : {
178+ Type : schema .TypeList ,
179+ Computed : true ,
180+ Optional : true ,
181+ Description : `Binary Authorization configuration.` ,
182+ MaxItems : 1 ,
183+ Elem : & schema.Resource {
184+ Schema : map [string ]* schema.Schema {
185+ "evaluation_mode" : {
186+ Type : schema .TypeString ,
187+ Optional : true ,
188+ ValidateFunc : verify .ValidateEnum ([]string {"DISABLED" , "PROJECT_SINGLETON_POLICY_ENFORCE" , "" }),
189+ Description : `Configure Binary Authorization evaluation mode. Possible values: ["DISABLED", "PROJECT_SINGLETON_POLICY_ENFORCE"]` ,
190+ },
191+ },
192+ },
193+ },
177194 "description" : {
178195 Type : schema .TypeString ,
179196 Optional : true ,
@@ -400,6 +417,12 @@ func resourceContainerAttachedClusterCreate(d *schema.ResourceData, meta interfa
400417 } else if v , ok := d .GetOkExists ("monitoring_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (monitoringConfigProp )) && (ok || ! reflect .DeepEqual (v , monitoringConfigProp )) {
401418 obj ["monitoringConfig" ] = monitoringConfigProp
402419 }
420+ binaryAuthorizationProp , err := expandContainerAttachedClusterBinaryAuthorization (d .Get ("binary_authorization" ), d , config )
421+ if err != nil {
422+ return err
423+ } else if v , ok := d .GetOkExists ("binary_authorization" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (binaryAuthorizationProp )) && (ok || ! reflect .DeepEqual (v , binaryAuthorizationProp )) {
424+ obj ["binaryAuthorization" ] = binaryAuthorizationProp
425+ }
403426
404427 url , err := tpgresource .ReplaceVars (d , config , "{{ContainerAttachedBasePath}}projects/{{project}}/locations/{{location}}/attachedClusters?attached_cluster_id={{name}}" )
405428 if err != nil {
@@ -572,6 +595,9 @@ func resourceContainerAttachedClusterRead(d *schema.ResourceData, meta interface
572595 if err := d .Set ("monitoring_config" , flattenContainerAttachedClusterMonitoringConfig (res ["monitoringConfig" ], d , config )); err != nil {
573596 return fmt .Errorf ("Error reading Cluster: %s" , err )
574597 }
598+ if err := d .Set ("binary_authorization" , flattenContainerAttachedClusterBinaryAuthorization (res ["binaryAuthorization" ], d , config )); err != nil {
599+ return fmt .Errorf ("Error reading Cluster: %s" , err )
600+ }
575601
576602 return nil
577603}
@@ -640,6 +666,12 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa
640666 } else if v , ok := d .GetOkExists ("monitoring_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , monitoringConfigProp )) {
641667 obj ["monitoringConfig" ] = monitoringConfigProp
642668 }
669+ binaryAuthorizationProp , err := expandContainerAttachedClusterBinaryAuthorization (d .Get ("binary_authorization" ), d , config )
670+ if err != nil {
671+ return err
672+ } else if v , ok := d .GetOkExists ("binary_authorization" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , binaryAuthorizationProp )) {
673+ obj ["binaryAuthorization" ] = binaryAuthorizationProp
674+ }
643675
644676 url , err := tpgresource .ReplaceVars (d , config , "{{ContainerAttachedBasePath}}projects/{{project}}/locations/{{location}}/attachedClusters/{{name}}" )
645677 if err != nil {
@@ -680,6 +712,10 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa
680712 if d .HasChange ("monitoring_config" ) {
681713 updateMask = append (updateMask , "monitoringConfig" )
682714 }
715+
716+ if d .HasChange ("binary_authorization" ) {
717+ updateMask = append (updateMask , "binaryAuthorization" )
718+ }
683719 // updateMask is a URL parameter but not present in the schema, so ReplaceVars
684720 // won't set it
685721 url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -697,9 +733,12 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa
697733 if d .HasChange ("monitoring_config" ) {
698734 newUpdateMask = append (newUpdateMask , "monitoring_config.managed_prometheus_config.enabled" )
699735 }
736+ if d .HasChange ("binary_authorization" ) {
737+ newUpdateMask = append (newUpdateMask , "binary_authorization.evaluation_mode" )
738+ }
700739 // Pull out any other set fields from the generated mask.
701740 for _ , mask := range updateMask {
702- if mask == "authorization" || mask == "loggingConfig" || mask == "monitoringConfig" {
741+ if mask == "authorization" || mask == "loggingConfig" || mask == "monitoringConfig" || mask == "binaryAuthorization" {
703742 continue
704743 }
705744 newUpdateMask = append (newUpdateMask , mask )
@@ -1058,6 +1097,20 @@ func flattenContainerAttachedClusterMonitoringConfigManagedPrometheusConfigEnabl
10581097 return v
10591098}
10601099
1100+ func flattenContainerAttachedClusterBinaryAuthorization (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1101+ if v == nil {
1102+ return nil
1103+ }
1104+ original := v .(map [string ]interface {})
1105+ transformed := make (map [string ]interface {})
1106+ transformed ["evaluation_mode" ] =
1107+ flattenContainerAttachedClusterBinaryAuthorizationEvaluationMode (original ["evaluationMode" ], d , config )
1108+ return []interface {}{transformed }
1109+ }
1110+ func flattenContainerAttachedClusterBinaryAuthorizationEvaluationMode (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1111+ return v
1112+ }
1113+
10611114func expandContainerAttachedClusterName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
10621115 return v , nil
10631116}
@@ -1290,3 +1343,31 @@ func expandContainerAttachedClusterMonitoringConfigManagedPrometheusConfig(v int
12901343func expandContainerAttachedClusterMonitoringConfigManagedPrometheusConfigEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
12911344 return v , nil
12921345}
1346+
1347+ func expandContainerAttachedClusterBinaryAuthorization (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1348+ l := v .([]interface {})
1349+ if len (l ) == 0 {
1350+ return nil , nil
1351+ }
1352+
1353+ if l [0 ] == nil {
1354+ transformed := make (map [string ]interface {})
1355+ return transformed , nil
1356+ }
1357+ raw := l [0 ]
1358+ original := raw .(map [string ]interface {})
1359+ transformed := make (map [string ]interface {})
1360+
1361+ transformedEvaluationMode , err := expandContainerAttachedClusterBinaryAuthorizationEvaluationMode (original ["evaluation_mode" ], d , config )
1362+ if err != nil {
1363+ return nil , err
1364+ } else if val := reflect .ValueOf (transformedEvaluationMode ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1365+ transformed ["evaluationMode" ] = transformedEvaluationMode
1366+ }
1367+
1368+ return transformed , nil
1369+ }
1370+
1371+ func expandContainerAttachedClusterBinaryAuthorizationEvaluationMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1372+ return v , nil
1373+ }
0 commit comments