Skip to content

Commit d88bb72

Browse files
Add membership_type field to cluster/fleet (#15221) (#24759)
[upstream:5eb5d67648c83178b954e882289e27370d1924d8] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 4a84219 commit d88bb72

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

.changelog/15221.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: added `fleet.membership_type` field to `google_container_cluster` resource
3+
```

google/services/container/resource_container_cluster.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,12 @@ func ResourceContainerCluster() *schema.Resource {
22842284
Computed: true,
22852285
Description: `Location of the fleet membership, for example "us-central1".`,
22862286
},
2287+
"membership_type": {
2288+
Type: schema.TypeString,
2289+
Optional: true,
2290+
ValidateFunc: validation.StringInSlice([]string{"LIGHTWEIGHT"}, false),
2291+
Description: `The type of the cluster's fleet membership.`,
2292+
},
22872293
},
22882294
},
22892295
},
@@ -6148,7 +6154,8 @@ func expandFleet(configured interface{}) *container.Fleet {
61486154

61496155
config := l[0].(map[string]interface{})
61506156
return &container.Fleet{
6151-
Project: config["project"].(string),
6157+
Project: config["project"].(string),
6158+
MembershipType: config["membership_type"].(string),
61526159
}
61536160
}
61546161

@@ -7179,6 +7186,7 @@ func flattenFleet(c *container.Fleet) []map[string]interface{} {
71797186
"membership_id": membership_id,
71807187
"membership_location": membership_location,
71817188
"pre_registered": c.PreRegistered,
7189+
"membership_type": c.MembershipType,
71827190
},
71837191
}
71847192
}

google/services/container/resource_container_cluster_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5516,6 +5516,15 @@ func TestAccContainerCluster_withFleetConfig(t *testing.T) {
55165516
ImportStateVerify: true,
55175517
ImportStateVerifyIgnore: []string{"deletion_protection"},
55185518
},
5519+
{
5520+
Config: testAccContainerCluster_withFleetConfigLightweightMembership(clusterName, projectID, networkName, subnetworkName),
5521+
},
5522+
{
5523+
ResourceName: "google_container_cluster.primary",
5524+
ImportState: true,
5525+
ImportStateVerify: true,
5526+
ImportStateVerifyIgnore: []string{"deletion_protection"},
5527+
},
55195528
},
55205529
})
55215530
}
@@ -5572,6 +5581,26 @@ resource "google_container_cluster" "primary" {
55725581
`, resource_name, networkName, subnetworkName)
55735582
}
55745583

5584+
func testAccContainerCluster_withFleetConfigLightweightMembership(name, projectID, networkName, subnetworkName string) string {
5585+
return fmt.Sprintf(`
5586+
resource "google_container_cluster" "primary" {
5587+
name = "%s"
5588+
location = "us-central1-a"
5589+
initial_node_count = 1
5590+
5591+
fleet {
5592+
project = "%s"
5593+
membership_type = "LIGHTWEIGHT"
5594+
}
5595+
5596+
network = "%s"
5597+
subnetwork = "%s"
5598+
5599+
deletion_protection = false
5600+
}
5601+
`, name, projectID, networkName, subnetworkName)
5602+
}
5603+
55755604
func testAccContainerCluster_withIncompatibleMasterVersionNodeVersion(name, networkName, subnetworkName string) string {
55765605
return fmt.Sprintf(`
55775606
resource "google_container_cluster" "gke_cluster" {

website/docs/r/container_cluster.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,8 @@ linux_node_config {
16761676

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

1679+
* `membership_type` - (Optional) Sets the membership type of the cluster. Available option is `LIGHTWEIGHT` to support only lightweight compatible features. If unspecified, the membership_type will be a regular membership that supports all features.
1680+
16791681
<a name="nested_workload_alts_config"></a>The `workload_alts_config` block supports:
16801682

16811683
* `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).

0 commit comments

Comments
 (0)