Skip to content

Commit

Permalink
Promoted managed_prometheus field in google_container_cluster` to GA (
Browse files Browse the repository at this point in the history
  • Loading branch information
IIBenII authored and hao-nan-li committed Dec 6, 2022
1 parent a90ce22 commit 4cca129
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,6 @@ func resourceContainerCluster() *schema.Resource {
<% end -%>
},
},
<% unless version == "ga" -%>
"managed_prometheus": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -982,7 +981,6 @@ func resourceContainerCluster() *schema.Resource {
},
},
},
<% end -%>
},
},
},
Expand Down Expand Up @@ -4381,14 +4379,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 @@ -5100,23 +5096,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 @@ -2549,7 +2549,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 @@ -2559,6 +2559,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version"},
},
<% end -%>
{
Config: testAccContainerCluster_withMonitoringConfigPrometheusUpdated(clusterName),
},
Expand Down Expand Up @@ -2587,7 +2588,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 @@ -6873,7 +6873,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 @@ -6920,7 +6920,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 @@ -6934,6 +6934,7 @@ resource "google_container_cluster" "primary" {
}
`, name)
}
<% end -%>

func testAccContainerCluster_withMonitoringConfigPrometheusUpdated(name string) string {
return fmt.Sprintf(`
Expand All @@ -6943,7 +6944,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 @@ -6960,14 +6961,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 @@ -540,7 +540,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

0 comments on commit 4cca129

Please sign in to comment.