Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove container cluster enable_binary_authorization #6285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-beta/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,21 +767,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 @@ -2115,7 +2106,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
IpAllocationPolicy: ipAllocationBlock,
PodSecurityPolicyConfig: expandPodSecurityPolicyConfig(d.Get("pod_security_policy_config")),
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 @@ -2589,17 +2580,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 @@ -2944,7 +2926,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 @@ -4750,11 +4732,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
51 changes: 3 additions & 48 deletions google-beta/services/container/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3046,10 +3046,9 @@ func TestAccContainerCluster_withBinaryAuthorizationEnabledBool(t *testing.T) {
Config: testAccContainerCluster_withBinaryAuthorizationEnabledBool(clusterName, true),
},
{
ResourceName: "google_container_cluster.with_binary_authorization_enabled_bool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enable_binary_authorization"},
ResourceName: "google_container_cluster.with_binary_authorization_enabled_bool",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerCluster_withBinaryAuthorizationEnabledBool(clusterName, false),
Expand All @@ -3063,38 +3062,6 @@ func TestAccContainerCluster_withBinaryAuthorizationEnabledBool(t *testing.T) {
})
}

func TestAccContainerCluster_withBinaryAuthorizationEnabledBoolLegacy(t *testing.T) {
t.Parallel()

clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withBinaryAuthorizationEnabledBoolLegacy(clusterName, true),
},
{
ResourceName: "google_container_cluster.with_binary_authorization_enabled_bool_legacy",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enable_binary_authorization", "binary_authorization.#", "binary_authorization.0.%", "binary_authorization.0.enabled", "binary_authorization.0.evaluation_mode"},
},
{
Config: testAccContainerCluster_withBinaryAuthorizationEnabledBoolLegacy(clusterName, false),
},
{
ResourceName: "google_container_cluster.with_binary_authorization_enabled_bool_legacy",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enable_binary_authorization"},
},
},
})
}

func TestAccContainerCluster_withBinaryAuthorizationEvaluationModeAutopilot(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -7147,18 +7114,6 @@ resource "google_container_cluster" "with_binary_authorization_enabled_bool" {
`, clusterName, enabled)
}

func testAccContainerCluster_withBinaryAuthorizationEnabledBoolLegacy(clusterName string, enabled bool) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_binary_authorization_enabled_bool_legacy" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1

enable_binary_authorization = %v
}
`, clusterName, enabled)
}

func testAccContainerCluster_withBinaryAuthorizationEvaluationMode(clusterName string, autopilot_enabled bool, evaluation_mode string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_binary_authorization_evaluation_mode" {
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