Skip to content

Commit 7db0926

Browse files
authored
Use GA provider to generate TGC (#15345)
1 parent 21a008a commit 7db0926

File tree

6 files changed

+6
-88
lines changed

6 files changed

+6
-88
lines changed

GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ clean-tgc:
124124
tgc:
125125
cd mmv1;\
126126
go run . --version beta --provider tgc --output $(OUTPUT_PATH)/tfplan2cai $(mmv1_compile)\
127-
&& go run . --version beta --provider tgc_cai2hcl --output $(OUTPUT_PATH)/cai2hcl $(mmv1_compile)\
128-
&& go run . --version beta --provider tgc_next --output $(OUTPUT_PATH) $(mmv1_compile);\
127+
&& go run . --version ga --provider tgc_cai2hcl --output $(OUTPUT_PATH)/cai2hcl $(mmv1_compile)\
128+
&& go run . --version ga --provider tgc_next --output $(OUTPUT_PATH) $(mmv1_compile);\
129129

130130
tf-oics:
131131
cd mmv1;\

docs/content/convert/add-new-resource-tgc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const ProductResourceAssetType string = "whatever.googleapis.com/asset-type"
6262
// ProductResourceSchemaName is the TF resource schema name for the Resource resource within Product.
6363
const ProductResourceSchemaName string = "google_product_resource"
6464

65-
// Copy the resource schema from [google-beta](https://github.com/hashicorp/terraform-provider-google-beta) Terraform provider
65+
// Copy the resource schema from [google](https://github.com/hashicorp/terraform-provider-google) Terraform provider
6666
func ResourceGoogleProject() *schema.Resource {
6767
return &schema.Resource{
6868
SchemaVersion: 1,

mmv1/products/networksecurity/AuthorizationPolicy.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ async:
4545
sweeper:
4646
url_substitutions:
4747
- region: "global"
48-
include_in_tgc_next_DO_NOT_USE: true
4948
examples:
5049
- name: 'network_security_authorization_policy_basic'
5150
primary_resource_id: 'default'

mmv1/third_party/tgc_next/pkg/services/compute/compute_instance.go

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1111

12-
compute "google.golang.org/api/compute/v0.beta"
12+
"google.golang.org/api/compute/v1"
1313
)
1414

1515
// ComputeInstanceAssetType is the CAI asset type name for compute instance.
@@ -71,8 +71,6 @@ var (
7171
"scheduling.0.max_run_duration",
7272
"scheduling.0.on_instance_stop_action",
7373
"scheduling.0.maintenance_interval",
74-
"scheduling.0.host_error_timeout_seconds",
75-
"scheduling.0.graceful_shutdown",
7674
"scheduling.0.local_ssd_recovery_timeout",
7775
}
7876

@@ -463,15 +461,6 @@ func ResourceComputeInstance() *schema.Resource {
463461
Description: `The name or self_link of the subnetwork attached to this interface.`,
464462
},
465463

466-
"network_attachment": {
467-
Type: schema.TypeString,
468-
Optional: true,
469-
Computed: true,
470-
ForceNew: true,
471-
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
472-
Description: `The URL of the network attachment that this interface should connect to in the following format: projects/{projectNumber}/regions/{region_name}/networkAttachments/{network_attachment_name}.`,
473-
},
474-
475464
"subnetwork_project": {
476465
Type: schema.TypeString,
477466
Optional: true,
@@ -829,15 +818,6 @@ func ResourceComputeInstance() *schema.Resource {
829818
Description: `Metadata key/value pairs made available within the instance.`,
830819
},
831820

832-
"partner_metadata": {
833-
Type: schema.TypeMap,
834-
Optional: true,
835-
DiffSuppressFunc: ComparePartnerMetadataDiff,
836-
DiffSuppressOnRefresh: true,
837-
Elem: &schema.Schema{Type: schema.TypeString},
838-
Description: `Partner Metadata Map made available within the instance.`,
839-
},
840-
841821
"metadata_startup_script": {
842822
Type: schema.TypeString,
843823
Optional: true,
@@ -986,11 +966,6 @@ be from 0 to 999,999,999 inclusive.`,
986966
},
987967
},
988968
},
989-
"host_error_timeout_seconds": {
990-
Type: schema.TypeInt,
991-
Optional: true,
992-
Description: `Specify the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.`,
993-
},
994969

995970
"maintenance_interval": {
996971
Type: schema.TypeString,
@@ -1441,8 +1416,6 @@ func flattenAliasIpRangeTgc(ranges []*compute.AliasIpRange) []map[string]interfa
14411416
func flattenSchedulingTgc(resp *compute.Scheduling) []map[string]interface{} {
14421417
schedulingMap := make(map[string]interface{}, 0)
14431418

1444-
// gracefulShutdown is not in the cai asset, so graceful_shutdown is skipped.
1445-
14461419
if resp.InstanceTerminationAction != "" {
14471420
schedulingMap["instance_termination_action"] = resp.InstanceTerminationAction
14481421
}
@@ -1487,14 +1460,6 @@ func flattenSchedulingTgc(resp *compute.Scheduling) []map[string]interface{} {
14871460
schedulingMap["on_instance_stop_action"] = flattenOnInstanceStopAction(resp.OnInstanceStopAction)
14881461
}
14891462

1490-
if resp.HostErrorTimeoutSeconds != 0 {
1491-
schedulingMap["host_error_timeout_seconds"] = resp.HostErrorTimeoutSeconds
1492-
}
1493-
1494-
if resp.MaintenanceInterval != "" {
1495-
schedulingMap["maintenance_interval"] = resp.MaintenanceInterval
1496-
}
1497-
14981463
if resp.LocalSsdRecoveryTimeout != nil {
14991464
schedulingMap["local_ssd_recovery_timeout"] = flattenComputeLocalSsdRecoveryTimeout(resp.LocalSsdRecoveryTimeout)
15001465
}
@@ -1546,14 +1511,6 @@ func flattenNetworkInterfacesTgc(networkInterfaces []*compute.NetworkInterface,
15461511
internalIP = iface.NetworkIP
15471512
}
15481513

1549-
if iface.NetworkAttachment != "" {
1550-
networkAttachment, err := tpgresource.GetRelativePath(iface.NetworkAttachment)
1551-
if err != nil {
1552-
return nil, "", "", err
1553-
}
1554-
flattened[i]["network_attachment"] = networkAttachment
1555-
}
1556-
15571514
// the security_policy for a network_interface is found in one of its accessConfigs.
15581515
if len(iface.AccessConfigs) > 0 && iface.AccessConfigs[0].SecurityPolicy != "" {
15591516
flattened[i]["security_policy"] = iface.AccessConfigs[0].SecurityPolicy

mmv1/third_party/tgc_next/pkg/services/compute/compute_instance_cai2hcl.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
"github.com/GoogleCloudPlatform/terraform-google-conversion/v7/pkg/tpgresource"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14-
compute "google.golang.org/api/compute/v0.beta"
14+
"google.golang.org/api/compute/v1"
1515
)
1616

1717
// ComputeInstanceCai2hclConverter for compute instance resource.
@@ -101,12 +101,6 @@ func (c *ComputeInstanceCai2hclConverter) convertResourceData(asset caiasset.Ass
101101
hclData["key_revocation_action_type"] = strings.TrimSuffix(instance.KeyRevocationActionType, "_ON_KEY_REVOCATION")
102102
hclData["instance_encryption_key"] = flattenComputeInstanceEncryptionKey(instance.InstanceEncryptionKey)
103103

104-
partnerMetadata, err := flattenPartnerMetadata(instance.PartnerMetadata)
105-
if err != nil {
106-
return nil, fmt.Errorf("Error parsing partner metadata: %s", err)
107-
}
108-
hclData["partner_metadata"] = partnerMetadata
109-
110104
// TODO: convert details from the boot disk assets (separate disk assets) into initialize_params in cai2hcl?
111105
// It needs to integrate the disk assets into instance assets with the resolver.
112106

mmv1/third_party/tgc_next/pkg/services/compute/compute_instance_tfplan2cai.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"strings"
77

8-
compute "google.golang.org/api/compute/v0.beta"
8+
"google.golang.org/api/compute/v1"
99
"google.golang.org/api/googleapi"
1010

1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -132,11 +132,6 @@ func expandComputeInstance(project string, d tpgresource.TerraformResourceData,
132132
return nil, fmt.Errorf("Error creating metadata: %s", err)
133133
}
134134

135-
partnerMetadata, err := resourceInstancePartnerMetadata(d)
136-
if err != nil {
137-
return nil, fmt.Errorf("Error creating partner metadata: %s", err)
138-
}
139-
140135
networkInterfaces, err := expandNetworkInterfacesTgc(d, config)
141136
if err != nil {
142137
return nil, fmt.Errorf("Error creating network interfaces: %s", err)
@@ -164,7 +159,6 @@ func expandComputeInstance(project string, d tpgresource.TerraformResourceData,
164159
Disks: disks,
165160
MachineType: machineTypeUrl,
166161
Metadata: metadata,
167-
PartnerMetadata: partnerMetadata,
168162
Name: d.Get("name").(string),
169163
Zone: d.Get("zone").(string),
170164
NetworkInterfaces: networkInterfaces,
@@ -504,21 +498,12 @@ func expandNetworkInterfacesTgc(d tpgresource.TerraformResourceData, config *tra
504498
for i, raw := range configs {
505499
data := raw.(map[string]interface{})
506500

507-
var networkAttachment = ""
508501
network := data["network"].(string)
509502
subnetwork := data["subnetwork"].(string)
510-
if networkAttachmentObj, ok := data["network_attachment"]; ok {
511-
networkAttachment = networkAttachmentObj.(string)
512-
}
513-
// Checks if networkAttachment is not specified in resource, network or subnetwork have to be specified.
514-
if networkAttachment == "" && network == "" && subnetwork == "" {
515-
return nil, fmt.Errorf("exactly one of network, subnetwork, or network_attachment must be provided")
516-
}
517503

518504
ifaces[i] = &compute.NetworkInterface{
519505
NetworkIP: data["network_ip"].(string),
520506
Network: network,
521-
NetworkAttachment: networkAttachment,
522507
Subnetwork: subnetwork,
523508
AccessConfigs: expandAccessConfigs(data["access_config"].([]interface{})),
524509
AliasIpRanges: expandAliasIpRanges(data["alias_ip_range"].([]interface{})),
@@ -621,24 +606,7 @@ func expandSchedulingTgc(v interface{}) (*compute.Scheduling, error) {
621606
scheduling.OnInstanceStopAction = transformedOnInstanceStopAction
622607
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "OnInstanceStopAction")
623608
}
624-
if v, ok := original["host_error_timeout_seconds"]; ok {
625-
if v != nil && v != 0 {
626-
scheduling.HostErrorTimeoutSeconds = int64(v.(int))
627-
}
628-
}
629609

630-
if v, ok := original["maintenance_interval"]; ok {
631-
scheduling.MaintenanceInterval = v.(string)
632-
}
633-
634-
if v, ok := original["graceful_shutdown"]; ok {
635-
transformedGracefulShutdown, err := expandGracefulShutdown(v)
636-
if err != nil {
637-
return nil, err
638-
}
639-
scheduling.GracefulShutdown = transformedGracefulShutdown
640-
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "GracefulShutdown")
641-
}
642610
if v, ok := original["local_ssd_recovery_timeout"]; ok {
643611
transformedLocalSsdRecoveryTimeout, err := expandComputeLocalSsdRecoveryTimeout(v)
644612
if err != nil {

0 commit comments

Comments
 (0)