Skip to content

Commit

Permalink
remove container cluster enable_binary_authorization (#8784) (#15868)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 15, 2023
1 parent e2f461c commit 1a700a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .changelog/8784.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
container: removed `enable_binary_authorization` in `google_container_cluster`
```
30 changes: 6 additions & 24 deletions google/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,12 @@ func ResourceContainerCluster() *schema.Resource {
Description: ` Description of the cluster.`,
},

"enable_binary_authorization": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Deprecated: "Deprecated in favor of binary_authorization.",
Description: `Enable Binary Authorization for this cluster. If enabled, all container images will be validated by Google Binary Authorization.`,
ConflictsWith: []string{"enable_autopilot", "binary_authorization"},
},
"binary_authorization": {
Type: schema.TypeList,
Optional: true,
DiffSuppressFunc: BinaryAuthorizationDiffSuppress,
MaxItems: 1,
Description: "Configuration options for the Binary Authorization feature.",
ConflictsWith: []string{"enable_binary_authorization"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Expand Down Expand Up @@ -1891,7 +1882,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
EnableKubernetesAlpha: d.Get("enable_kubernetes_alpha").(bool),
IpAllocationPolicy: ipAllocationBlock,
Autoscaling: expandClusterAutoscaling(d.Get("cluster_autoscaling"), d),
BinaryAuthorization: expandBinaryAuthorization(d.Get("binary_authorization"), d.Get("enable_binary_authorization").(bool)),
BinaryAuthorization: expandBinaryAuthorization(d.Get("binary_authorization")),
Autopilot: &container.Autopilot{
Enabled: d.Get("enable_autopilot").(bool),
WorkloadPolicyConfig: workloadPolicyConfig,
Expand Down Expand Up @@ -2348,17 +2339,8 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
if err := d.Set("cluster_autoscaling", flattenClusterAutoscaling(cluster.Autoscaling)); err != nil {
return err
}
binauthz_enabled := d.Get("binary_authorization.0.enabled").(bool)
legacy_binauthz_enabled := d.Get("enable_binary_authorization").(bool)
if !binauthz_enabled {
if err := d.Set("enable_binary_authorization", cluster.BinaryAuthorization != nil && cluster.BinaryAuthorization.Enabled); err != nil {
return fmt.Errorf("Error setting enable_binary_authorization: %s", err)
}
}
if !legacy_binauthz_enabled {
if err := d.Set("binary_authorization", flattenBinaryAuthorization(cluster.BinaryAuthorization)); err != nil {
return err
}
if err := d.Set("binary_authorization", flattenBinaryAuthorization(cluster.BinaryAuthorization)); err != nil {
return err
}
if autopilot := cluster.Autopilot; autopilot != nil {
if err := d.Set("enable_autopilot", autopilot.Enabled); err != nil {
Expand Down Expand Up @@ -2677,7 +2659,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
if d.HasChange("binary_authorization") {
req := &container.UpdateClusterRequest{
Update: &container.ClusterUpdate{
DesiredBinaryAuthorization: expandBinaryAuthorization(d.Get("binary_authorization"), d.Get("enable_binary_authorization").(bool)),
DesiredBinaryAuthorization: expandBinaryAuthorization(d.Get("binary_authorization")),
},
}

Expand Down Expand Up @@ -4261,11 +4243,11 @@ func expandNotificationConfig(configured interface{}) *container.NotificationCon
}
}

func expandBinaryAuthorization(configured interface{}, legacy_enabled bool) *container.BinaryAuthorization {
func expandBinaryAuthorization(configured interface{}) *container.BinaryAuthorization {
l := configured.([]interface{})
if len(l) == 0 || l[0] == nil {
return &container.BinaryAuthorization{
Enabled: legacy_enabled,
Enabled: false,
ForceSendFields: []string{"Enabled"},
}
}
Expand Down
4 changes: 0 additions & 4 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ per node in this cluster. This doesn't work on "routes-based" clusters, clusters
that don't have IP Aliasing enabled. See the [official documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/flexible-pod-cidr)
for more information.

* `enable_binary_authorization` - (DEPRECATED) Enable Binary Authorization for this cluster.
If enabled, all container images will be validated by Google Binary Authorization.
Deprecated in favor of `binary_authorization`.

* `enable_kubernetes_alpha` - (Optional) Whether to enable Kubernetes Alpha features for
this cluster. Note that when this option is enabled, the cluster cannot be upgraded
and will be automatically deleted after 30 days.
Expand Down

0 comments on commit 1a700a7

Please sign in to comment.