Skip to content

Commit

Permalink
gke_backup_agent_config: support from beta to ga (#6898) (#13223)
Browse files Browse the repository at this point in the history
* promote backup to ga

* gke_backup_agent_config: doc update

* fix typo in a test func name

* retrigger checks

* update test for gke backup config in ga

Co-authored-by: Shubham Singh <skshubham@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Shubham Singh <skshubham@google.com>
  • Loading branch information
modular-magician and shubhamkr619 committed Dec 12, 2022
1 parent ad1522e commit d3e9199
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/6898.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
container: promoted `gke_backup_agent_config` in `google_container_cluster` to GA
```
31 changes: 31 additions & 0 deletions google/resource_container_cluster.go
Expand Up @@ -68,6 +68,7 @@ var (
"addons_config.0.gcp_filestore_csi_driver_config",
"addons_config.0.dns_cache_config",
"addons_config.0.gce_persistent_disk_csi_driver_config",
"addons_config.0.gke_backup_agent_config",
}

privateClusterConfigKeys = []string{
Expand Down Expand Up @@ -366,6 +367,22 @@ func resourceContainerCluster() *schema.Resource {
},
},
},
"gke_backup_agent_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: addonsConfigKeys,
MaxItems: 1,
Description: `The status of the Backup for GKE Agent addon. It is disabled by default. Set enabled = true to enable.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
},
},
},
Expand Down Expand Up @@ -3357,6 +3374,13 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
ForceSendFields: []string{"Enabled"},
}
}
if v, ok := config["gke_backup_agent_config"]; ok && len(v.([]interface{})) > 0 {
addon := v.([]interface{})[0].(map[string]interface{})
ac.GkeBackupAgentConfig = &container.GkeBackupAgentConfig{
Enabled: addon["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
}

return ac
}
Expand Down Expand Up @@ -4205,6 +4229,13 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
},
}
}
if c.GkeBackupAgentConfig != nil {
result["gke_backup_agent_config"] = []map[string]interface{}{
{
"enabled": c.GkeBackupAgentConfig.Enabled,
},
}
}

return []map[string]interface{}{result}
}
Expand Down
6 changes: 6 additions & 0 deletions google/resource_container_cluster_test.go
Expand Up @@ -3166,6 +3166,9 @@ resource "google_container_cluster" "primary" {
gce_persistent_disk_csi_driver_config {
enabled = false
}
gke_backup_agent_config {
enabled = false
}
}
}
`, projectID, clusterName)
Expand Down Expand Up @@ -3212,6 +3215,9 @@ resource "google_container_cluster" "primary" {
gce_persistent_disk_csi_driver_config {
enabled = true
}
gke_backup_agent_config {
enabled = true
}
}
}
`, projectID, clusterName)
Expand Down
2 changes: 1 addition & 1 deletion google/validation_test.go
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func TestvalidateGCEName(t *testing.T) {
func TestValidateGCEName(t *testing.T) {
x := []StringValidationTestCase{
// No errors
{TestName: "basic", Value: "foobar"},
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/container_cluster.html.markdown
Expand Up @@ -403,14 +403,15 @@ subnetwork in which the cluster's instances are launched.
* `gce_persistent_disk_csi_driver_config` - (Optional).
Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enabled.

* `gke_backup_agent_config` - (Optional).
The status of the Backup for GKE agent addon. It is disabled by default; Set `enabled = true` to enable.

* `kalm_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
Configuration for the KALM addon, which manages the lifecycle of k8s. It is disabled by default; Set `enabled = true` to enable.

* `config_connector_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
The status of the ConfigConnector addon. It is disabled by default; Set `enabled = true` to enable.

* `gke_backup_agent_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
The status of the Backup for GKE agent addon. It is disabled by default; Set `enabled = true` to enable.

This example `addons_config` disables two addons:

Expand Down

0 comments on commit d3e9199

Please sign in to comment.