Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,13 @@ func ResourceContainerCluster() *schema.Resource {
Computed: true,
Description: `Location of the fleet membership, for example "us-central1".`,
},
"membership_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"MEMBERSHIP_TYPE_UNSPECIFIED", "LIGHTWEIGHT"}, false),
Description: `The type of the cluster's fleet membership.`,
DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("MEMBERSHIP_TYPE_UNSPECIFIED"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, is this meant that the API will return MEMBERSHIP_TYPE_UNSPECIFIED when the field is unset? I know our validation already blocks explicitly setting this value in the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it should return the field as unset. Is this DiffSuppressFunc overkill?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then we can remove this DiffSuppressFunc IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

},
},
},
},
Expand Down Expand Up @@ -6570,6 +6577,7 @@ func expandFleet(configured interface{}) *container.Fleet {
config := l[0].(map[string]interface{})
return &container.Fleet{
Project: config["project"].(string),
MembershipType: config["membership_type"].(string),
}
}

Expand Down Expand Up @@ -7680,6 +7688,7 @@ func flattenFleet(c *container.Fleet) []map[string]interface{} {
"membership_id": membership_id,
"membership_location": membership_location,
"pre_registered": c.PreRegistered,
"membership_type": c.MembershipType,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5914,6 +5914,15 @@ func TestAccContainerCluster_withFleetConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testAccContainerCluster_withFleetConfigLightweightMembership(clusterName, projectID, networkName, subnetworkName),
},
{
ResourceName: "google_container_cluster.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
}
Expand Down Expand Up @@ -6040,6 +6049,26 @@ resource "google_container_cluster" "primary" {
`, resource_name, networkName, subnetworkName)
}

func testAccContainerCluster_withFleetConfigLightweightMembership(name, projectID, networkName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1

fleet {
project = "%s"
membership_type = "LIGHTWEIGHT"
}

network = "%s"
subnetwork = "%s"

deletion_protection = false
}
`, name, projectID, networkName, subnetworkName)
}

func testAccContainerCluster_withIncompatibleMasterVersionNodeVersion(name, networkName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "gke_cluster" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,8 @@ linux_node_config {

* `project` - (Optional) The name of the Fleet host project where this cluster will be registered.

* `membership_type` - (Optional) Sets the membership type of the cluster. Available options are `LIGHTWEIGHT` and `MEMBERSHIP_TYPE_UNSPECIFIED`.

<a name="nested_workload_alts_config"></a>The `workload_alts_config` block supports:

* `enable_alts` - (Required) Whether the alts handshaker should be enabled or not for direct-path. Requires Workload Identity ([workloadPool]((#nested_workload_identity_config)) must be non-empty).
Expand Down
Loading