Skip to content

Commit 76f9ba8

Browse files
modular-magicianEdward Sun
and
Edward Sun
authored
fix subcategory (#6334) (#12200)
Co-authored-by: Edward Sun <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Edward Sun <[email protected]>
1 parent 482e35e commit 76f9ba8

9 files changed

+366
-34
lines changed

.changelog/6334.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:none
2+
OS Config: fixed the left navigation subcategory for `google_os_config_os_policy_assignment`
3+
4+
```

google/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type Formatter struct {
6666
// Borrowed logic from https://github.com/sirupsen/logrus/blob/master/json_formatter.go and https://github.com/t-tomalak/logrus-easy-formatter/blob/master/formatter.go
6767
func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error) {
6868
// Suppress logs if TF_LOG is not DEBUG or TRACE
69-
// also suppress frequent transport spam
69+
// Also suppress frequent transport spam
7070
if !logging.IsDebugOrHigher() || strings.Contains(entry.Message, "transport is closing") {
7171
return nil, nil
7272
}

google/provider.go

+1-32
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,6 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
12391239
// ####### START handwritten resources ###########
12401240
"google_app_engine_application": resourceAppEngineApplication(),
12411241
"google_bigquery_table": resourceBigQueryTable(),
1242-
"google_bigquery_reservation_assignment": resourceBigqueryReservationAssignment(),
12431242
"google_bigtable_gc_policy": resourceBigtableGCPolicy(),
12441243
"google_bigtable_instance": resourceBigtableInstance(),
12451244
"google_bigtable_table": resourceBigtableTable(),
@@ -1309,37 +1308,6 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
13091308
"google_storage_transfer_job": resourceStorageTransferJob(),
13101309
// ####### END handwritten resources ###########
13111310
},
1312-
map[string]*schema.Resource{
1313-
// ####### START tpgtools resources ###########
1314-
"google_apikeys_key": resourceApikeysKey(),
1315-
"google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(),
1316-
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
1317-
"google_clouddeploy_delivery_pipeline": resourceClouddeployDeliveryPipeline(),
1318-
"google_clouddeploy_target": resourceClouddeployTarget(),
1319-
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
1320-
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
1321-
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
1322-
"google_container_aws_cluster": resourceContainerAwsCluster(),
1323-
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
1324-
"google_container_azure_client": resourceContainerAzureClient(),
1325-
"google_container_azure_cluster": resourceContainerAzureCluster(),
1326-
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
1327-
"google_dataplex_lake": resourceDataplexLake(),
1328-
"google_dataplex_zone": resourceDataplexZone(),
1329-
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
1330-
"google_eventarc_trigger": resourceEventarcTrigger(),
1331-
"google_firebaserules_release": resourceFirebaserulesRelease(),
1332-
"google_firebaserules_ruleset": resourceFirebaserulesRuleset(),
1333-
"google_logging_log_view": resourceLoggingLogView(),
1334-
"google_monitoring_monitored_project": resourceMonitoringMonitoredProject(),
1335-
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
1336-
"google_network_connectivity_spoke": resourceNetworkConnectivitySpoke(),
1337-
"google_org_policy_policy": resourceOrgPolicyPolicy(),
1338-
"google_os_config_os_policy_assignment": resourceOsConfigOsPolicyAssignment(),
1339-
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
1340-
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
1341-
// ####### END tpgtools resources ###########
1342-
},
13431311
map[string]*schema.Resource{
13441312
// ####### START non-generated IAM resources ###########
13451313
"google_bigtable_instance_iam_binding": ResourceIamBinding(IamBigtableInstanceSchema, NewBigtableInstanceUpdater, BigtableInstanceIdParseFunc),
@@ -1404,6 +1372,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
14041372
"google_service_account_iam_policy": ResourceIamPolicy(IamServiceAccountSchema, NewServiceAccountIamUpdater, ServiceAccountIdParseFunc),
14051373
// ####### END non-generated IAM resources ###########
14061374
},
1375+
dclResources,
14071376
)
14081377
}
14091378

google/provider_dcl_resources.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: DCL ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is managed by Magic Modules (https://github.com/GoogleCloudPlatform/magic-modules)
8+
// and is based on the DCL (https://github.com/GoogleCloudPlatform/declarative-resource-client-library).
9+
// Changes will need to be made to the DCL or Magic Modules instead of here.
10+
//
11+
// We are not currently able to accept contributions to this file. If changes
12+
// are required, please file an issue at https://github.com/hashicorp/terraform-provider-google/issues/new/choose
13+
//
14+
// ----------------------------------------------------------------------------
15+
16+
package google
17+
18+
import (
19+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
20+
)
21+
22+
var dclResources = map[string]*schema.Resource{
23+
"google_apikeys_key": resourceApikeysKey(),
24+
"google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(),
25+
"google_bigquery_reservation_assignment": resourceBigqueryReservationAssignment(),
26+
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
27+
"google_clouddeploy_delivery_pipeline": resourceClouddeployDeliveryPipeline(),
28+
"google_clouddeploy_target": resourceClouddeployTarget(),
29+
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
30+
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
31+
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
32+
"google_container_aws_cluster": resourceContainerAwsCluster(),
33+
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
34+
"google_container_azure_client": resourceContainerAzureClient(),
35+
"google_container_azure_cluster": resourceContainerAzureCluster(),
36+
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
37+
"google_dataplex_lake": resourceDataplexLake(),
38+
"google_dataplex_zone": resourceDataplexZone(),
39+
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
40+
"google_eventarc_trigger": resourceEventarcTrigger(),
41+
"google_firebaserules_release": resourceFirebaserulesRelease(),
42+
"google_firebaserules_ruleset": resourceFirebaserulesRuleset(),
43+
"google_logging_log_view": resourceLoggingLogView(),
44+
"google_monitoring_monitored_project": resourceMonitoringMonitoredProject(),
45+
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
46+
"google_network_connectivity_spoke": resourceNetworkConnectivitySpoke(),
47+
"google_org_policy_policy": resourceOrgPolicyPolicy(),
48+
"google_os_config_os_policy_assignment": resourceOsConfigOsPolicyAssignment(),
49+
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
50+
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
51+
}

google/resource_container_cluster.go

+75
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,23 @@ func resourceContainerCluster() *schema.Resource {
10701070
},
10711071
},
10721072

1073+
"mesh_certificates": {
1074+
Type: schema.TypeList,
1075+
MaxItems: 1,
1076+
Optional: true,
1077+
Computed: true,
1078+
Description: `If set, and enable_certificates=true, the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster.`,
1079+
Elem: &schema.Resource{
1080+
Schema: map[string]*schema.Schema{
1081+
"enable_certificates": {
1082+
Type: schema.TypeBool,
1083+
Required: true,
1084+
Description: `When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster.`,
1085+
},
1086+
},
1087+
},
1088+
},
1089+
10731090
"database_encryption": {
10741091
Type: schema.TypeList,
10751092
MaxItems: 1,
@@ -1438,6 +1455,10 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
14381455
cluster.VerticalPodAutoscaling = expandVerticalPodAutoscaling(v)
14391456
}
14401457

1458+
if v, ok := d.GetOk("mesh_certificates"); ok {
1459+
cluster.MeshCertificates = expandMeshCertificates(v)
1460+
}
1461+
14411462
if v, ok := d.GetOk("database_encryption"); ok {
14421463
cluster.DatabaseEncryption = expandDatabaseEncryption(v)
14431464
}
@@ -1770,6 +1791,10 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
17701791
return err
17711792
}
17721793

1794+
if err := d.Set("mesh_certificates", flattenMeshCertificates(cluster.MeshCertificates)); err != nil {
1795+
return err
1796+
}
1797+
17731798
if err := d.Set("database_encryption", flattenDatabaseEncryption(cluster.DatabaseEncryption)); err != nil {
17741799
return err
17751800
}
@@ -2414,6 +2439,33 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
24142439
}
24152440
}
24162441

2442+
if d.HasChange("mesh_certificates") {
2443+
c := d.Get("mesh_certificates")
2444+
req := &container.UpdateClusterRequest{
2445+
Update: &container.ClusterUpdate{
2446+
DesiredMeshCertificates: expandMeshCertificates(c),
2447+
},
2448+
}
2449+
2450+
updateF := func() error {
2451+
name := containerClusterFullName(project, location, clusterName)
2452+
clusterUpdateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.Update(name, req)
2453+
if config.UserProjectOverride {
2454+
clusterUpdateCall.Header().Add("X-Goog-User-Project", project)
2455+
}
2456+
op, err := clusterUpdateCall.Do()
2457+
if err != nil {
2458+
return err
2459+
}
2460+
// Wait until it's updated
2461+
return containerOperationWait(config, op, project, location, "updating GKE cluster mesh certificates config", userAgent, d.Timeout(schema.TimeoutUpdate))
2462+
}
2463+
if err := lockedCall(lockKey, updateF); err != nil {
2464+
return err
2465+
}
2466+
log.Printf("[INFO] GKE cluster %s mesh certificates config has been updated", d.Id())
2467+
}
2468+
24172469
if d.HasChange("database_encryption") {
24182470
c := d.Get("database_encryption")
24192471
req := &container.UpdateClusterRequest{
@@ -3165,6 +3217,18 @@ func expandVerticalPodAutoscaling(configured interface{}) *container.VerticalPod
31653217
}
31663218
}
31673219

3220+
func expandMeshCertificates(configured interface{}) *container.MeshCertificates {
3221+
l := configured.([]interface{})
3222+
if len(l) == 0 {
3223+
return nil
3224+
}
3225+
config := l[0].(map[string]interface{})
3226+
return &container.MeshCertificates{
3227+
EnableCertificates: config["enable_certificates"].(bool),
3228+
ForceSendFields: []string{"EnableCertificates"},
3229+
}
3230+
}
3231+
31683232
func expandDatabaseEncryption(configured interface{}) *container.DatabaseEncryption {
31693233
l := configured.([]interface{})
31703234
if len(l) == 0 {
@@ -3708,6 +3772,17 @@ func flattenResourceUsageExportConfig(c *container.ResourceUsageExportConfig) []
37083772
}
37093773
}
37103774

3775+
func flattenMeshCertificates(c *container.MeshCertificates) []map[string]interface{} {
3776+
if c == nil {
3777+
return nil
3778+
}
3779+
return []map[string]interface{}{
3780+
{
3781+
"enable_certificates": c.EnableCertificates,
3782+
},
3783+
}
3784+
}
3785+
37113786
func flattenDatabaseEncryption(c *container.DatabaseEncryption) []map[string]interface{} {
37123787
if c == nil {
37133788
return nil

google/resource_container_cluster_test.go

+83
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,48 @@ func TestAccContainerCluster_errorNoClusterCreated(t *testing.T) {
19551955
})
19561956
}
19571957

1958+
func TestAccContainerCluster_withMeshCertificatesConfig(t *testing.T) {
1959+
t.Parallel()
1960+
1961+
clusterName := fmt.Sprintf("tf-test-cluster-%s", randString(t, 10))
1962+
pid := getTestProjectFromEnv()
1963+
1964+
vcrTest(t, resource.TestCase{
1965+
PreCheck: func() { testAccPreCheck(t) },
1966+
Providers: testAccProviders,
1967+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
1968+
Steps: []resource.TestStep{
1969+
{
1970+
Config: testAccContainerCluster_withMeshCertificatesConfigEnabled(pid, clusterName),
1971+
},
1972+
{
1973+
ResourceName: "google_container_cluster.with_mesh_certificates_config",
1974+
ImportState: true,
1975+
ImportStateVerify: true,
1976+
ImportStateVerifyIgnore: []string{"remove_default_node_pool"},
1977+
},
1978+
{
1979+
Config: testAccContainerCluster_updateMeshCertificatesConfig(pid, clusterName, true),
1980+
},
1981+
{
1982+
ResourceName: "google_container_cluster.with_mesh_certificates_config",
1983+
ImportState: true,
1984+
ImportStateVerify: true,
1985+
ImportStateVerifyIgnore: []string{"remove_default_node_pool"},
1986+
},
1987+
{
1988+
Config: testAccContainerCluster_updateMeshCertificatesConfig(pid, clusterName, false),
1989+
},
1990+
{
1991+
ResourceName: "google_container_cluster.with_mesh_certificates_config",
1992+
ImportState: true,
1993+
ImportStateVerify: true,
1994+
ImportStateVerifyIgnore: []string{"remove_default_node_pool"},
1995+
},
1996+
},
1997+
})
1998+
}
1999+
19582000
func TestAccContainerCluster_withDatabaseEncryption(t *testing.T) {
19592001
t.Parallel()
19602002

@@ -4139,6 +4181,47 @@ resource "google_container_cluster" "with_resource_labels" {
41394181
`, location)
41404182
}
41414183

4184+
func testAccContainerCluster_withMeshCertificatesConfigEnabled(projectID string, clusterName string) string {
4185+
return fmt.Sprintf(`
4186+
data "google_project" "project" {
4187+
project_id = "%s"
4188+
}
4189+
4190+
resource "google_container_cluster" "with_mesh_certificates_config" {
4191+
name = "%s"
4192+
location = "us-central1-a"
4193+
initial_node_count = 1
4194+
remove_default_node_pool = true
4195+
workload_identity_config {
4196+
workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
4197+
}
4198+
mesh_certificates {
4199+
enable_certificates = true
4200+
}
4201+
}
4202+
`, projectID, clusterName)
4203+
}
4204+
4205+
func testAccContainerCluster_updateMeshCertificatesConfig(projectID string, clusterName string, enabled bool) string {
4206+
return fmt.Sprintf(`
4207+
data "google_project" "project" {
4208+
project_id = "%s"
4209+
}
4210+
4211+
resource "google_container_cluster" "with_mesh_certificates_config" {
4212+
name = "%s"
4213+
location = "us-central1-a"
4214+
initial_node_count = 1
4215+
remove_default_node_pool = true
4216+
workload_identity_config {
4217+
workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
4218+
}
4219+
mesh_certificates {
4220+
enable_certificates = %v
4221+
}
4222+
}`, projectID, clusterName, enabled)
4223+
}
4224+
41424225
func testAccContainerCluster_withDatabaseEncryption(clusterName string, kmsData bootstrappedKMS) string {
41434226
return fmt.Sprintf(`
41444227
data "google_project" "project" {

0 commit comments

Comments
 (0)