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

Promoted managed_prometheus field in google_container_cluster` to GA #6877

Merged
merged 8 commits into from
Nov 30, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ func resourceContainerCluster() *schema.Resource {
<% end -%>
},
},
<% unless version == "ga" -%>
"managed_prometheus": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -968,7 +967,6 @@ func resourceContainerCluster() *schema.Resource {
},
},
},
<% end -%>
},
},
},
Expand Down Expand Up @@ -4327,14 +4325,12 @@ func expandMonitoringConfig(configured interface{}) *container.MonitoringConfig
EnableComponents: convertStringArr(enable_components),
}
}
<% unless version == 'ga' -%>
if v, ok := config["managed_prometheus"]; ok && len(v.([]interface{})) > 0 {
managed_prometheus := v.([]interface{})[0].(map[string]interface{})
mc.ManagedPrometheusConfig = &container.ManagedPrometheusConfig{
Enabled: managed_prometheus["enabled"].(bool),
}
}
<% end -%>
return mc
}

Expand Down Expand Up @@ -5046,23 +5042,19 @@ func flattenMonitoringConfig(c *container.MonitoringConfig) []map[string]interfa
if c.ComponentConfig != nil {
result["enable_components"] = c.ComponentConfig.EnableComponents
}
<% unless version == 'ga' -%>
if c.ManagedPrometheusConfig != nil {
result["managed_prometheus"] = flattenManagedPrometheusConfig(c.ManagedPrometheusConfig)
}
<% end -%>
return []map[string]interface{}{result}
}

<% unless version == 'ga' -%>
func flattenManagedPrometheusConfig(c *container.ManagedPrometheusConfig) []map[string]interface{} {
return []map[string]interface{}{
{
"enabled": c != nil && c.Enabled,
},
}
}
<% end -%>

<% unless version == 'ga' -%>
func flattenNodePoolAutoConfig(c *container.NodePoolAutoConfig) []map[string]interface{} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version"},
},
<% if version == 'beta' -%>
<% if version == "beta" -%>
{
Config: testAccContainerCluster_withMonitoringConfigUpdated(clusterName),
},
Expand All @@ -2484,6 +2484,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version"},
},
<% end -%>
{
Config: testAccContainerCluster_withMonitoringConfigPrometheusUpdated(clusterName),
},
Expand Down Expand Up @@ -2512,7 +2513,6 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version"},
},
<% end -%>
{
Config: testAccContainerCluster_basic_1_23_8(clusterName),
},
Expand Down Expand Up @@ -6648,7 +6648,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
logging_config {
enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER", "WORKLOADS" ]
enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER"]
}
monitoring_config {
enable_components = [ "SYSTEM_COMPONENTS" ]
Expand Down Expand Up @@ -6695,7 +6695,7 @@ resource "google_container_cluster" "primary" {
`, name)
}

<% if version == 'beta' -%>
<% if version == "beta" -%>
func testAccContainerCluster_withMonitoringConfigUpdated(name string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "primary" {
Expand All @@ -6709,6 +6709,7 @@ resource "google_container_cluster" "primary" {
}
`, name)
}
<% end -%>

func testAccContainerCluster_withMonitoringConfigPrometheusUpdated(name string) string {
return fmt.Sprintf(`
Expand All @@ -6718,7 +6719,7 @@ resource "google_container_cluster" "primary" {
initial_node_count = 1
min_master_version = "1.23.8-gke.1900"
monitoring_config {
enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER", "WORKLOADS" ]
enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER" ]
managed_prometheus {
enabled = true
}
Expand All @@ -6735,14 +6736,15 @@ resource "google_container_cluster" "primary" {
initial_node_count = 1
min_master_version = "1.23.8-gke.1900"
monitoring_config {
enable_components = []
managed_prometheus {
enabled = true
enabled = true
}
}
}
`, name)
}
<% end -%>


func testAccContainerCluster_withSoleTenantGroup(name string) string {
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ This block also contains several computed attributes, documented below.

* `enable_components` - (Optional) The GKE components exposing metrics. Supported values include: `SYSTEM_COMPONENTS`, `APISERVER`, `CONTROLLER_MANAGER`, and `SCHEDULER`. In beta provider, `WORKLOADS` is supported on top of those 4 values. (`WORKLOADS` is deprecated and removed in GKE 1.24.)

* `managed_prometheus` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) Configuration for Managed Service for Prometheus. Structure is [documented below](#nested_managed_prometheus).
* `managed_prometheus` - (Optional) Configuration for Managed Service for Prometheus. Structure is [documented below](#nested_managed_prometheus).

<a name="nested_managed_prometheus"></a>The `managed_prometheus` block supports:

Expand Down