Skip to content

Commit

Permalink
Only set enabled bool if evaluation mode is unspecified (#9629)
Browse files Browse the repository at this point in the history
* Only set enabled bool if evaluation mode is unspecified

* Only trigger one cluster update event if both both legacy  and  struct blocks have diffs.

* remove inadvertant modifications

* Pass legacy bool to expandBinaryAuthorization fn

* move fn for diff readability

* reformat

* reformat

* Only get enable_binary_authorization if its been changed

* remove commas

* fix logic

* Remove enable_binary_authorization condition

* Add upgrade path docs

* Add comma

* Update mmv1/third_party/terraform/website/docs/guides/version_5_upgrade.html.markdown

---------

Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
  • Loading branch information
rmoriar1 and melinath authored Dec 20, 2023
1 parent 9baa61f commit c1e45b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3044,26 +3044,6 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
log.Printf("[INFO] GKE cluster %s's autopilot workload policy config allow_net_admin has been set to %v", d.Id(), allowed)
}

if d.HasChange("enable_binary_authorization") {
enabled := d.Get("enable_binary_authorization").(bool)
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredBinaryAuthorization: &container.BinaryAuthorization{
Enabled: enabled,
ForceSendFields: []string{"Enabled"},
},
},
}

updateF := updateFunc(req, "updating GKE binary authorization")
// Call update serially.
if err := transport_tpg.LockedCall(lockKey, updateF); err != nil {
return err
}

log.Printf("[INFO] GKE cluster %s's binary authorization has been updated to %v", d.Id(), enabled)
}

if d.HasChange("private_cluster_config.0.enable_private_endpoint") {
enabled := d.Get("private_cluster_config.0.enable_private_endpoint").(bool)
req := &container.UpdateClusterRequest{
Expand Down Expand Up @@ -3102,7 +3082,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
log.Printf("[INFO] GKE cluster %s's master global access config has been updated to %v", d.Id(), config)
}

if d.HasChange("binary_authorization") {
if d.HasChange("binary_authorization") {
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredBinaryAuthorization: expandBinaryAuthorization(d.Get("binary_authorization")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,15 @@ resource "google_container_cluster" "primary" {

### `enable_binary_authorization` is now removed

`enable_binary_authorization` has been removed in favor of `binary_authorization.enabled`.
`enable_binary_authorization` has been removed in favor of `binary_authorization.evaluation_mode`.
To enable Binary Authorization, set evaluation mode to "PROJECT_SINGLETON_POLICY_ENFORCE"
as shown in the example below. To disable it, set evaluation mode to "DISABLED".

```
binary_authorization {
evaluation_mode = "PROJECT_SINGLETON_POLICY_ENFORCE"
}
```

### Default value of `network_policy.provider` is now removed

Expand Down

0 comments on commit c1e45b1

Please sign in to comment.