Skip to content

Commit

Permalink
dcl upgrade (#5994) (#4276)
Browse files Browse the repository at this point in the history
* dcl upgrade + proxy_config test

* run make serialize

* added more multicloud tests

* added forwarding_rule tests + doc and exclude service_directory_registrations from global_forwarding_rule

* fix tests

* run make serialize

* fix forwarding_rule test

* added EXCLUDE to beta file

* update test + hide beta example + exclude containeraws proxy_config

* upgrade dcl to 1.5.1

* added proxy_config test

* remove EXCLUDE tag

* fix test

* format

* remove require

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 3, 2022
1 parent c79475b commit 2f534d5
Show file tree
Hide file tree
Showing 20 changed files with 1,956 additions and 93 deletions.
21 changes: 21 additions & 0 deletions .changelog/5994.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```release-note: enhancement
compute: added `service_directory_registrations` to `google_compute_forwarding_rule` resource
```
```release-note:enhancement
containeraws: added `proxy_config` to `google_container_aws_node_pool` resource
```
```release-note:enhancement
containerazure: added `proxy_config` to `google_container_azure_node_pool` resource
```
```release-note:enhancement
containeraws: added `instance_placement` and `logging_config` to `google_container_aws_cluster` resource (beta)
```
```release-note:enhancement
containeraws: added `image_type` and `instance_placement` to `google_container_aws_node_pool` resource (beta)
```
```release-note:enhancement
containerazure: added `logging_config` to `google_container_azure_cluster` resource (beta)
```
```release-note:enhancement
containerazure: added `image_type` to `google_container_azure_node_pool` resource (beta)
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/hashicorp/terraform-provider-google-beta
require (
cloud.google.com/go/bigtable v1.13.0
cloud.google.com/go/iam v0.1.1 // indirect
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.1.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1543,3 +1543,9 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-202203
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220316014534-ac1c1c4fdb29/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.1.0 h1:6EDY4EUsCW/mTRzYJ8SEzL2V5JACYCiIswnbhpaAwaY=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.1.0/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.4.1 h1:nqlJvanh1GLSkVNpw6e4ecXtMd8Vl7c/USkI9qTyVzI=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.4.1/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1 h1:WsauUAtzKxwcfR2SAN8K/yeHS6S4pGK6r/oJdKJaTgI=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1 h1:WsauUAtzKxwcfR2SAN8K/yeHS6S4pGK6r/oJdKJaTgI=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.5.1/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
247 changes: 171 additions & 76 deletions google-beta/resource_compute_forwarding_rule.go

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions google-beta/resource_compute_forwarding_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ func TestAccComputeForwardingRule_networkTier(t *testing.T) {
})
}

func TestAccComputeForwardingRule_serviceDirectoryRegistrations(t *testing.T) {
t.Parallel()

poolName := fmt.Sprintf("tf-test-%s", randString(t, 10))
ruleName := fmt.Sprintf("tf-test-%s", randString(t, 10))
svcDirNamespace := fmt.Sprintf("tf-test-%s", randString(t, 10))
serviceName := fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeForwardingRuleDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeForwardingRule_serviceDirectoryRegistrations(poolName, ruleName, svcDirNamespace, serviceName),
},

{
ResourceName: "google_compute_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeForwardingRule_basic(poolName, ruleName string) string {
return fmt.Sprintf(`
resource "google_compute_target_pool" "foo-tp" {
Expand Down Expand Up @@ -187,3 +213,41 @@ resource "google_compute_forwarding_rule" "foobar" {
}
`, poolName, ruleName)
}

func testAccComputeForwardingRule_serviceDirectoryRegistrations(poolName, ruleName, svcDirNamespace, serviceName string) string {
return fmt.Sprintf(`
resource "google_compute_target_pool" "foo-tp" {
description = "Resource created for Terraform acceptance testing"
instances = ["us-central1-a/foo", "us-central1-b/bar"]
name = "foo-%s"
}
resource "google_compute_forwarding_rule" "foobar" {
description = "Resource created for Terraform acceptance testing"
ip_protocol = "UDP"
name = "%s"
port_range = "80-81"
target = google_compute_target_pool.foo-tp.self_link
service_directory_registrations {
namespace = google_service_directory_namespace.examplens.namespace_id
service = google_service_directory_service.examplesvc.service_id
}
}
resource "google_service_directory_namespace" "examplens" {
namespace_id = "%s"
location = "us-central1"
}
resource "google_service_directory_service" "examplesvc" {
service_id = "%s"
namespace = google_service_directory_namespace.examplens.id
metadata = {
stage = "prod"
region = "us-central1"
}
}
`, poolName, ruleName, svcDirNamespace, serviceName)
}
174 changes: 173 additions & 1 deletion google-beta/resource_container_aws_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ func resourceContainerAwsCluster() *schema.Resource {
Description: "Optional. A human readable description of this cluster. Cannot be longer than 255 UTF-8 encoded bytes.",
},

"logging_config": {
Type: schema.TypeList,
Computed: true,
Optional: true,
ForceNew: true,
Description: "Logging configuration.",
MaxItems: 1,
Elem: ContainerAwsClusterLoggingConfigSchema(),
},

"project": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -180,7 +190,7 @@ func ContainerAwsClusterAuthorizationSchema() *schema.Resource {
"admin_users": {
Type: schema.TypeList,
Required: true,
Description: "Users to perform operations as a cluster admin. A managed ClusterRoleBinding will be created to grant the `cluster-admin` ClusterRole to the users. At most one user can be specified. For more info on RBAC, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles",
Description: "Users to perform operations as a cluster admin. A managed ClusterRoleBinding will be created to grant the `cluster-admin` ClusterRole to the users. Up to ten admin users can be provided. For more info on RBAC, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles",
Elem: ContainerAwsClusterAuthorizationAdminUsersSchema(),
},
},
Expand Down Expand Up @@ -248,6 +258,16 @@ func ContainerAwsClusterControlPlaneSchema() *schema.Resource {
Description: "The Kubernetes version to run on control plane replicas (e.g. `1.19.10-gke.1000`). You can list all supported versions on a given Google Cloud region by calling .",
},

"instance_placement": {
Type: schema.TypeList,
Computed: true,
Optional: true,
ForceNew: true,
Description: "Details of placement information for an instance.",
MaxItems: 1,
Elem: ContainerAwsClusterControlPlaneInstancePlacementSchema(),
},

"instance_type": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -353,6 +373,20 @@ func ContainerAwsClusterControlPlaneDatabaseEncryptionSchema() *schema.Resource
}
}

func ContainerAwsClusterControlPlaneInstancePlacementSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"tenancy": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
Description: "The tenancy for the instance. Possible values: TENANCY_UNSPECIFIED, DEFAULT, DEDICATED, HOST",
},
},
}
}

func ContainerAwsClusterControlPlaneMainVolumeSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -504,6 +538,37 @@ func ContainerAwsClusterNetworkingSchema() *schema.Resource {
}
}

func ContainerAwsClusterLoggingConfigSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"component_config": {
Type: schema.TypeList,
Computed: true,
Optional: true,
ForceNew: true,
Description: "Configuration of the logging components.",
MaxItems: 1,
Elem: ContainerAwsClusterLoggingConfigComponentConfigSchema(),
},
},
}
}

func ContainerAwsClusterLoggingConfigComponentConfigSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"enable_components": {
Type: schema.TypeList,
Computed: true,
Optional: true,
ForceNew: true,
Description: "Components of the logging configuration to be enabled.",
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}

func ContainerAwsClusterWorkloadIdentityConfigSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -545,6 +610,7 @@ func resourceContainerAwsClusterCreate(d *schema.ResourceData, meta interface{})
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
Annotations: checkStringMap(d.Get("annotations")),
Description: dcl.String(d.Get("description").(string)),
LoggingConfig: expandContainerAwsClusterLoggingConfig(d.Get("logging_config")),
Project: dcl.String(project),
}

Expand Down Expand Up @@ -602,6 +668,7 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
Annotations: checkStringMap(d.Get("annotations")),
Description: dcl.String(d.Get("description").(string)),
LoggingConfig: expandContainerAwsClusterLoggingConfig(d.Get("logging_config")),
Project: dcl.String(project),
}

Expand Down Expand Up @@ -654,6 +721,9 @@ func resourceContainerAwsClusterRead(d *schema.ResourceData, meta interface{}) e
if err = d.Set("description", res.Description); err != nil {
return fmt.Errorf("error setting description in state: %s", err)
}
if err = d.Set("logging_config", flattenContainerAwsClusterLoggingConfig(res.LoggingConfig)); err != nil {
return fmt.Errorf("error setting logging_config in state: %s", err)
}
if err = d.Set("project", res.Project); err != nil {
return fmt.Errorf("error setting project in state: %s", err)
}
Expand Down Expand Up @@ -701,6 +771,7 @@ func resourceContainerAwsClusterUpdate(d *schema.ResourceData, meta interface{})
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
Annotations: checkStringMap(d.Get("annotations")),
Description: dcl.String(d.Get("description").(string)),
LoggingConfig: expandContainerAwsClusterLoggingConfig(d.Get("logging_config")),
Project: dcl.String(project),
}
directive := UpdateDirective
Expand Down Expand Up @@ -753,6 +824,7 @@ func resourceContainerAwsClusterDelete(d *schema.ResourceData, meta interface{})
Networking: expandContainerAwsClusterNetworking(d.Get("networking")),
Annotations: checkStringMap(d.Get("annotations")),
Description: dcl.String(d.Get("description").(string)),
LoggingConfig: expandContainerAwsClusterLoggingConfig(d.Get("logging_config")),
Project: dcl.String(project),
}

Expand Down Expand Up @@ -899,6 +971,7 @@ func expandContainerAwsClusterControlPlane(o interface{}) *containeraws.ClusterC
IamInstanceProfile: dcl.String(obj["iam_instance_profile"].(string)),
SubnetIds: expandStringArray(obj["subnet_ids"]),
Version: dcl.String(obj["version"].(string)),
InstancePlacement: expandContainerAwsClusterControlPlaneInstancePlacement(obj["instance_placement"]),
InstanceType: dcl.StringOrNil(obj["instance_type"].(string)),
MainVolume: expandContainerAwsClusterControlPlaneMainVolume(obj["main_volume"]),
ProxyConfig: expandContainerAwsClusterControlPlaneProxyConfig(obj["proxy_config"]),
Expand All @@ -920,6 +993,7 @@ func flattenContainerAwsClusterControlPlane(obj *containeraws.ClusterControlPlan
"iam_instance_profile": obj.IamInstanceProfile,
"subnet_ids": obj.SubnetIds,
"version": obj.Version,
"instance_placement": flattenContainerAwsClusterControlPlaneInstancePlacement(obj.InstancePlacement),
"instance_type": obj.InstanceType,
"main_volume": flattenContainerAwsClusterControlPlaneMainVolume(obj.MainVolume),
"proxy_config": flattenContainerAwsClusterControlPlaneProxyConfig(obj.ProxyConfig),
Expand Down Expand Up @@ -1013,6 +1087,32 @@ func flattenContainerAwsClusterControlPlaneDatabaseEncryption(obj *containeraws.

}

func expandContainerAwsClusterControlPlaneInstancePlacement(o interface{}) *containeraws.ClusterControlPlaneInstancePlacement {
if o == nil {
return nil
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return nil
}
obj := objArr[0].(map[string]interface{})
return &containeraws.ClusterControlPlaneInstancePlacement{
Tenancy: containeraws.ClusterControlPlaneInstancePlacementTenancyEnumRef(obj["tenancy"].(string)),
}
}

func flattenContainerAwsClusterControlPlaneInstancePlacement(obj *containeraws.ClusterControlPlaneInstancePlacement) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"tenancy": obj.Tenancy,
}

return []interface{}{transformed}

}

func expandContainerAwsClusterControlPlaneMainVolume(o interface{}) *containeraws.ClusterControlPlaneMainVolume {
if o == nil {
return nil
Expand Down Expand Up @@ -1188,6 +1288,58 @@ func flattenContainerAwsClusterNetworking(obj *containeraws.ClusterNetworking) i

}

func expandContainerAwsClusterLoggingConfig(o interface{}) *containeraws.ClusterLoggingConfig {
if o == nil {
return nil
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return nil
}
obj := objArr[0].(map[string]interface{})
return &containeraws.ClusterLoggingConfig{
ComponentConfig: expandContainerAwsClusterLoggingConfigComponentConfig(obj["component_config"]),
}
}

func flattenContainerAwsClusterLoggingConfig(obj *containeraws.ClusterLoggingConfig) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"component_config": flattenContainerAwsClusterLoggingConfigComponentConfig(obj.ComponentConfig),
}

return []interface{}{transformed}

}

func expandContainerAwsClusterLoggingConfigComponentConfig(o interface{}) *containeraws.ClusterLoggingConfigComponentConfig {
if o == nil {
return nil
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return nil
}
obj := objArr[0].(map[string]interface{})
return &containeraws.ClusterLoggingConfigComponentConfig{
EnableComponents: expandContainerAwsClusterLoggingConfigComponentConfigEnableComponentsArray(obj["enable_components"]),
}
}

func flattenContainerAwsClusterLoggingConfigComponentConfig(obj *containeraws.ClusterLoggingConfigComponentConfig) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"enable_components": flattenContainerAwsClusterLoggingConfigComponentConfigEnableComponentsArray(obj.EnableComponents),
}

return []interface{}{transformed}

}

func flattenContainerAwsClusterWorkloadIdentityConfig(obj *containeraws.ClusterWorkloadIdentityConfig) interface{} {
if obj == nil || obj.Empty() {
return nil
Expand All @@ -1201,3 +1353,23 @@ func flattenContainerAwsClusterWorkloadIdentityConfig(obj *containeraws.ClusterW
return []interface{}{transformed}

}
func flattenContainerAwsClusterLoggingConfigComponentConfigEnableComponentsArray(obj []containeraws.ClusterLoggingConfigComponentConfigEnableComponentsEnum) interface{} {
if obj == nil {
return nil
}
items := []string{}
for _, item := range obj {
items = append(items, string(item))
}
return items
}

func expandContainerAwsClusterLoggingConfigComponentConfigEnableComponentsArray(o interface{}) []containeraws.ClusterLoggingConfigComponentConfigEnableComponentsEnum {
objs := o.([]interface{})
items := make([]containeraws.ClusterLoggingConfigComponentConfigEnableComponentsEnum, 0, len(objs))
for _, item := range objs {
i := containeraws.ClusterLoggingConfigComponentConfigEnableComponentsEnumRef(item.(string))
items = append(items, *i)
}
return items
}
Loading

0 comments on commit 2f534d5

Please sign in to comment.