Skip to content

Commit

Permalink
Split tgc converters
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Oct 1, 2024
1 parent 02d6c97 commit 522c1fe
Show file tree
Hide file tree
Showing 50 changed files with 198 additions and 202 deletions.
152 changes: 76 additions & 76 deletions mmv1/provider/terraform_tgc.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions mmv1/third_party/tgc/firebase_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const firebaseProjectAssetType string = "firebase.googleapis.com/FirebaseProject"

func resourceConverterFirebaseProject() cai.ResourceConverter {
func ResourceConverterFirebaseProject() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: firebaseProjectAssetType,
Convert: GetFirebaseProjectCaiObject,
Expand Down Expand Up @@ -40,7 +40,7 @@ func GetFirebaseProjectCaiObject(d tpgresource.TerraformResourceData, config *tr

func GetFirebaseProjectApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})

nameProp, err := expandFirebaseProjectName(d.Get("name"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -102,4 +102,4 @@ func expandFirebaseProjectProjectId(v interface{}, d tpgresource.TerraformResour

func expandFirebaseProjectName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
}
84 changes: 42 additions & 42 deletions mmv1/third_party/tgc/resource_converters.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import (
func ResourceConverters() map[string][]cai.ResourceConverter {
return map[string][]cai.ResourceConverter{
"google_artifact_registry_repository": {artifactregistry.ResourceConverterArtifactRegistryRepository()},
"google_app_engine_application": {resourceConverterAppEngineApplication()},
"google_app_engine_application": {appengine.ResourceConverterAppEngineApplication()},
"google_alloydb_cluster": {alloydb.ResourceConverterAlloydbCluster()},
"google_alloydb_instance": {alloydb.ResourceConverterAlloydbInstance()},
"google_apikeys_key": {resourceConverterApikeysKey()},
"google_apikeys_key": {apikeys.ResourceConverterApikeysKey()},
"google_compute_address": {compute.ResourceConverterComputeAddress()},
"google_compute_autoscaler": {compute.ResourceConverterComputeAutoscaler()},
"google_compute_firewall": {compute.ResourceConverterComputeFirewall()},
Expand All @@ -65,14 +65,14 @@ func ResourceConverters() map[string][]cai.ResourceConverter {
"google_compute_global_forwarding_rule": {compute.ResourceConverterComputeGlobalForwardingRule()},
"google_compute_health_check": {compute.ResourceConverterComputeHealthCheck()},
"google_compute_instance": {compute.ResourceConverterComputeInstance()},
"google_compute_instance_group": {resourceConverterComputeInstanceGroup()},
"google_compute_instance_group": {compute.ResourceConverterComputeInstanceGroup()},
"google_compute_network": {compute.ResourceConverterComputeNetwork()},
"google_compute_node_template": {compute.ResourceConverterComputeNodeTemplate()},
"google_compute_route": {compute.ResourceConverterComputeRoute()},
"google_compute_router": {compute.ResourceConverterComputeRouter()},
"google_compute_vpn_tunnel": {compute.ResourceConverterComputeVpnTunnel()},
"google_compute_resource_policy": {compute.ResourceConverterComputeResourcePolicy()},
"google_compute_security_policy": {resourceConverterComputeSecurityPolicy()},
"google_compute_security_policy": {compute.ResourceConverterComputeSecurityPolicy()},
"google_compute_snapshot": {compute.ResourceConverterComputeSnapshot()},
"google_compute_subnetwork": {compute.ResourceConverterComputeSubnetwork()},
"google_compute_ssl_policy": {compute.ResourceConverterComputeSslPolicy()},
Expand All @@ -81,31 +81,31 @@ func ResourceConverters() map[string][]cai.ResourceConverter {
"google_compute_target_http_proxy": {compute.ResourceConverterComputeTargetHttpProxy()},
"google_compute_target_https_proxy": {compute.ResourceConverterComputeTargetHttpsProxy()},
"google_compute_target_ssl_proxy": {compute.ResourceConverterComputeTargetSslProxy()},
"google_compute_target_pool": {resourceConverterComputeTargetPool()},
"google_composer_environment": {resourceConverterComposerEnvironment()},
"google_compute_region_commitment": {resourceConverterCommitment()},
"google_dataflow_job": {resourceDataflowJob()},
"google_compute_target_pool": {compute.ResourceConverterComputeTargetPool()},
"google_composer_environment": {composer.ResourceConverterComposerEnvironment()},
"google_compute_region_commitment": {compute.ResourceConverterCommitment()},
"google_dataflow_job": {dataflow.ResourceDataflowJob()},
"google_dataproc_autoscaling_policy": {dataproc.ResourceConverterDataprocAutoscalingPolicy()},
"google_dataproc_cluster": {resourceConverterDataprocCluster()},
"google_dataproc_cluster": {dataproc.ResourceConverterDataprocCluster()},
"google_dns_managed_zone": {dns.ResourceConverterDNSManagedZone()},
"google_dns_policy": {dns.ResourceConverterDNSPolicy()},
"google_kms_key_ring_import_job": {kms.ResourceConverterKMSKeyRingImportJob()},
"google_gke_hub_feature": {gkehub2.ResourceConverterGKEHub2Feature()},
"google_storage_bucket": {resourceConverterStorageBucket()},
"google_sql_database_instance": {resourceConverterSQLDatabaseInstance()},
"google_storage_bucket": {storage.ResourceConverterStorageBucket()},
"google_sql_database_instance": {sql.ResourceConverterSQLDatabaseInstance()},
"google_sql_database": {sql.ResourceConverterSQLDatabase()},
"google_container_cluster": {resourceConverterContainerCluster()},
"google_container_node_pool": {resourceConverterContainerNodePool()},
"google_container_cluster": {container.ResourceConverterContainerCluster()},
"google_container_node_pool": {container.ResourceConverterContainerNodePool()},
"google_bigquery_dataset": {bigquery.ResourceConverterBigQueryDataset()},
"google_bigquery_dataset_iam_policy": {bigquery.ResourceConverterBigqueryDatasetIamPolicy()},
"google_bigquery_dataset_iam_binding": {bigquery.ResourceConverterBigqueryDatasetIamBinding()},
"google_bigquery_dataset_iam_member": {bigquery.ResourceConverterBigqueryDatasetIamMember()},
"google_bigquery_table": {resourceConverterBigQueryTable()},
"google_bigquery_table": {bigquery.ResourceConverterBigQueryTable()},
"google_datastream_connection_profile": {datastream.ResourceConverterDatastreamConnectionProfile()},
"google_datastream_private_connection": {datastream.ResourceConverterDatastreamPrivateConnection()},
"google_datastream_stream": {datastream.ResourceConverterDatastreamStream()},
"google_firebase_project": {resourceConverterFirebaseProject()},
"google_org_policy_policy": {resourceConverterOrgPolicyPolicy()},
"google_org_policy_policy": {resourcemanager.ResourceConverterOrgPolicyPolicy()},
"google_redis_instance": {redis.ResourceConverterRedisInstance()},
"google_spanner_database": {spanner.ResourceConverterSpannerDatabase()},
"google_spanner_database_iam_policy": {spanner.ResourceConverterSpannerDatabaseIamPolicy()},
Expand All @@ -115,7 +115,7 @@ func ResourceConverters() map[string][]cai.ResourceConverter {
"google_spanner_instance_iam_policy": {spanner.ResourceConverterSpannerInstanceIamPolicy()},
"google_spanner_instance_iam_binding": {spanner.ResourceConverterSpannerInstanceIamBinding()},
"google_spanner_instance_iam_member": {spanner.ResourceConverterSpannerInstanceIamMember()},
"google_project_service": {resourceConverterServiceUsage()},
"google_project_service": {resourcemanager.ResourceConverterServiceUsage()},
"google_secret_manager_secret_version": {secretmanager.ResourceConverterSecretManagerSecretVersion()},
"google_pubsub_lite_reservation": {pubsublite.ResourceConverterPubsubLiteReservation()},
"google_pubsub_lite_subscription": {pubsublite.ResourceConverterPubsubLiteSubscription()},
Expand All @@ -125,15 +125,15 @@ func ResourceConverters() map[string][]cai.ResourceConverter {
"google_pubsub_subscription_iam_policy": {pubsub.ResourceConverterPubsubSubscriptionIamPolicy()},
"google_pubsub_subscription_iam_binding": {pubsub.ResourceConverterPubsubSubscriptionIamBinding()},
"google_pubsub_subscription_iam_member": {pubsub.ResourceConverterPubsubSubscriptionIamMember()},
"google_storage_bucket_iam_policy": {resourceConverterStorageBucketIamPolicy()},
"google_storage_bucket_iam_binding": {resourceConverterStorageBucketIamBinding()},
"google_storage_bucket_iam_member": {resourceConverterStorageBucketIamMember()},
"google_storage_bucket_iam_policy": {storage.ResourceConverterStorageBucketIamPolicy()},
"google_storage_bucket_iam_binding": {storage.ResourceConverterStorageBucketIamBinding()},
"google_storage_bucket_iam_member": {storage.ResourceConverterStorageBucketIamMember()},
"google_compute_node_group": {compute.ResourceConverterComputeNodeGroup()},
"google_logging_folder_bucket_config": {resourceConverterLogFolderBucket()},
"google_app_engine_standard_app_version": {resourceAppEngineStandardAppVersion()},
"google_logging_organization_bucket_config": {resourceConverterLogOrganizationBucket()},
"google_logging_project_bucket_config": {resourceConverterLogProjectBucket()},
"google_logging_billing_account_bucket_config": {resourceConverterLogBillingAccountBucket()},
"google_logging_folder_bucket_config": {logging.ResourceConverterLogFolderBucket()},
"google_app_engine_standard_app_version": {appengine.ResourceAppEngineStandardAppVersion()},
"google_logging_organization_bucket_config": {logging.ResourceConverterLogOrganizationBucket()},
"google_logging_project_bucket_config": {logging.ResourceConverterLogProjectBucket()},
"google_logging_billing_account_bucket_config": {logging.ResourceConverterLogBillingAccountBucket()},
"google_cloud_tasks_queue": {cloudtasks.ResourceConverterCloudTasksQueue()},
"google_pubsub_topic": {pubsub.ResourceConverterPubsubTopic()},
"google_kms_crypto_key": {kms.ResourceConverterKMSCryptoKey()},
Expand All @@ -156,38 +156,38 @@ func ResourceConverters() map[string][]cai.ResourceConverter {
{{- end }}
{{- end }}
"google_project": {
resourceConverterProject(),
resourceConverterProjectBillingInfo(),
resourcemanager.ResourceConverterProject(),
resourcemanager.ResourceConverterProjectBillingInfo(),
},
"google_bigtable_instance": {
resourceConverterBigtableInstance(),
resourceConverterBigtableCluster(),
bigtable.ResourceConverterBigtableInstance(),
bigtable.ResourceConverterBigtableCluster(),
},
"google_organization_iam_policy": {resourcemanager.ResourceConverterOrganizationIamPolicy()},
"google_organization_iam_binding": {resourcemanager.ResourceConverterOrganizationIamBinding()},
"google_organization_iam_member": {resourcemanager.ResourceConverterOrganizationIamMember()},
"google_organization_policy": {resourceConverterOrganizationPolicy()},
"google_project_organization_policy": {resourceConverterProjectOrgPolicy()},
"google_folder": {resourceConverterFolder()},
"google_organization_policy": {resourcemanager.ResourceConverterOrganizationPolicy()},
"google_project_organization_policy": {resourcemanager.ResourceConverterProjectOrgPolicy()},
"google_folder": {resourcemanager.ResourceConverterFolder()},
"google_folder_iam_policy": {resourcemanager.ResourceConverterFolderIamPolicy()},
"google_folder_iam_binding": {resourcemanager.ResourceConverterFolderIamBinding()},
"google_folder_iam_member": {resourcemanager.ResourceConverterFolderIamMember()},
"google_folder_organization_policy": {resourceConverterFolderOrgPolicy()},
"google_kms_crypto_key_iam_policy": {resourceConverterKmsCryptoKeyIamPolicy()},
"google_kms_crypto_key_iam_binding": {resourceConverterKmsCryptoKeyIamBinding()},
"google_kms_crypto_key_iam_member": {resourceConverterKmsCryptoKeyIamMember()},
"google_kms_key_ring_iam_policy": {resourceConverterKmsKeyRingIamPolicy()},
"google_kms_key_ring_iam_binding": {resourceConverterKmsKeyRingIamBinding()},
"google_kms_key_ring_iam_member": {resourceConverterKmsKeyRingIamMember()},
"google_folder_organization_policy": {resourcemanager.ResourceConverterFolderOrgPolicy()},
"google_kms_crypto_key_iam_policy": {kms.ResourceConverterKmsCryptoKeyIamPolicy()},
"google_kms_crypto_key_iam_binding": {kms.ResourceConverterKmsCryptoKeyIamBinding()},
"google_kms_crypto_key_iam_member": {kms.ResourceConverterKmsCryptoKeyIamMember()},
"google_kms_key_ring_iam_policy": {kms.ResourceConverterKmsKeyRingIamPolicy()},
"google_kms_key_ring_iam_binding": {kms.ResourceConverterKmsKeyRingIamBinding()},
"google_kms_key_ring_iam_member": {kms.ResourceConverterKmsKeyRingIamMember()},
"google_project_iam_policy": {resourcemanager.ResourceConverterProjectIamPolicy()},
"google_project_iam_binding": {resourcemanager.ResourceConverterProjectIamBinding()},
"google_project_iam_member": {resourcemanager.ResourceConverterProjectIamMember()},
"google_project_iam_custom_role": {resourceConverterProjectIAMCustomRole()},
"google_organization_iam_custom_role": {resourceConverterOrganizationIAMCustomRole()},
"google_project_iam_custom_role": {resourcemanager.ResourceConverterProjectIAMCustomRole()},
"google_organization_iam_custom_role": {resourcemanager.ResourceConverterOrganizationIAMCustomRole()},
"google_vpc_access_connector": {vpcaccess.ResourceConverterVPCAccessConnector()},
"google_logging_metric": {logging.ResourceConverterLoggingMetric()},
"google_service_account": {resourceConverterServiceAccount()},
"google_service_account_key": {resourceConverterServiceAccountKey()},
"google_service_account": {resourcemanager.ResourceConverterServiceAccount()},
"google_service_account_key": {resourcemanager.ResourceConverterServiceAccountKey()},

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package apikeys

import (
"reflect"
Expand All @@ -10,7 +10,7 @@ import (

const ApikeysKeyAssetType string = "apikeys.googleapis.com/Key"

func resourceConverterApikeysKey() cai.ResourceConverter {
func ResourceConverterApikeysKey() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: ApikeysKeyAssetType,
Convert: GetApikeysKeyCaiObject,
Expand Down Expand Up @@ -125,7 +125,7 @@ func expandApikeysKeyDeleteTime(v interface{}, d tpgresource.TerraformResourceDa
}

func expandApikeysKeyRestrictions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {

l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
Expand Down Expand Up @@ -203,7 +203,6 @@ func expandApikeysKeySha1Fingerprint(v interface{}, d tpgresource.TerraformResou
return v, nil
}


func expandApikeysKeyApiTargets(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down Expand Up @@ -238,7 +237,6 @@ func expandApikeysKeyMethods(v interface{}, d tpgresource.TerraformResourceData,
return convertInterfaceToStringArray(v.([]interface{})), nil
}


func expandApikeysKeyDEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package appengine

import (
"reflect"
Expand All @@ -10,7 +10,7 @@ import (

const AppEngineApplicationAssetType string = "appengine.googleapis.com/Application"

func resourceConverterAppEngineApplication() cai.ResourceConverter {
func ResourceConverterAppEngineApplication() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: AppEngineApplicationAssetType,
Convert: GetAppEngineApplicationCaiObject,
Expand Down Expand Up @@ -55,15 +55,13 @@ func GetAppEngineApplicationApiObject(d tpgresource.TerraformResourceData, confi
obj["location_id"] = locationIdProp
}


return obj, nil
}

func expandAppEngineApplicationId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}


func expandAppEngineApplicationLocationId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package appengine

import (
"reflect"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package bigquery

import (
"reflect"
Expand All @@ -10,7 +10,7 @@ import (

const BigQueryTableAssetType string = "bigquery.googleapis.com/Table"

func resourceConverterBigQueryTable() cai.ResourceConverter {
func ResourceConverterBigQueryTable() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: BigQueryTableAssetType,
Convert: GetBigQueryTableCaiObject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package bigtable

import (
"reflect"
Expand All @@ -8,7 +8,7 @@ import (
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

func resourceConverterBigtableCluster() cai.ResourceConverter {
func ResourceConverterBigtableCluster() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: "bigtableadmin.googleapis.com/Cluster",
Convert: GetBigtableClusterCaiObject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package bigtable

import (
"reflect"
Expand All @@ -8,7 +8,7 @@ import (
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

func resourceConverterBigtableInstance() cai.ResourceConverter {
func ResourceConverterBigtableInstance() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: "bigtableadmin.googleapis.com/Instance",
Convert: GetBigtableInstanceCaiObject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package cloudfunctions

import (
"reflect"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package cloudfunctions

import (
"reflect"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package google
package composer

import (
"reflect"
Expand All @@ -11,7 +11,7 @@ import (

const ComposerEnvironmentAssetType string = "composer.googleapis.com/Environment"

func resourceConverterComposerEnvironment() cai.ResourceConverter {
func ResourceConverterComposerEnvironment() cai.ResourceConverter {
return cai.ResourceConverter{
AssetType: ComposerEnvironmentAssetType,
Convert: GetComposerEnvironmentCaiObject,
Expand Down
Loading

0 comments on commit 522c1fe

Please sign in to comment.