diff --git a/go.mod b/go.mod index 6b8f67c1c..e1721dadc 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.20.1 github.com/hashicorp/terraform-json v0.22.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003160821-6c15720a9a02 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003174638-e8bcfecbdafc github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index a84e6cdfd..64151999e 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c= github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003160821-6c15720a9a02 h1:+g6tF2/hAiFY5WOraQZDEpq5Ci/afvIugnnBfV34F54= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003160821-6c15720a9a02/go.mod h1:0LymWybO9dJ38EJdzzbUKO9LaYBgoJsR/gKVAP+8hr8= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003174638-e8bcfecbdafc h1:FkdivL8jWkkVIK6sZjqsxsj08nkpBDleCOWyh9d7AvQ= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20241003174638-e8bcfecbdafc/go.mod h1:0LymWybO9dJ38EJdzzbUKO9LaYBgoJsR/gKVAP+8hr8= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= diff --git a/tfplan2cai/converters/google/resources/cai/string_helpers.go b/tfplan2cai/converters/google/resources/cai/string_helpers.go new file mode 100644 index 000000000..33395886a --- /dev/null +++ b/tfplan2cai/converters/google/resources/cai/string_helpers.go @@ -0,0 +1,9 @@ +package cai + +func ConvertInterfaceToStringArray(values []interface{}) []string { + stringArray := make([]string, len(values)) + for i, v := range values { + stringArray[i] = v.(string) + } + return stringArray +} diff --git a/tfplan2cai/converters/google/resources/firebase_project.go b/tfplan2cai/converters/google/resources/firebase_project.go deleted file mode 100644 index 28b469278..000000000 --- a/tfplan2cai/converters/google/resources/firebase_project.go +++ /dev/null @@ -1,105 +0,0 @@ -package google - -import ( - "reflect" - - "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" -) - -const firebaseProjectAssetType string = "firebase.googleapis.com/FirebaseProject" - -func resourceConverterFirebaseProject() cai.ResourceConverter { - return cai.ResourceConverter{ - AssetType: firebaseProjectAssetType, - Convert: GetFirebaseProjectCaiObject, - } -} - -func GetFirebaseProjectCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { - name, err := cai.AssetName(d, config, "//firebase.googleapis.com/v1beta1/projects/{{project}}") - if err != nil { - return []cai.Asset{}, err - } - if obj, err := GetFirebaseProjectApiObject(d, config); err == nil { - return []cai.Asset{{ - Name: name, - Type: firebaseProjectAssetType, - Resource: &cai.AssetResource{ - Version: "v1beta1", - DiscoveryDocumentURI: "https://firebase.googleapis.com/$discovery/rest?version=v1beta1", - DiscoveryName: "FirebaseProject", - Data: obj, - }, - }}, nil - } else { - return []cai.Asset{}, err - } -} - -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 - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - - projectProp, err := expandFirebaseProjectProjectId(d.Get("project"), d, config) - if err != nil { - return nil, err - } else if v, ok := d.GetOkExists("project"); !tpgresource.IsEmptyValue(reflect.ValueOf(projectProp)) && (ok || !reflect.DeepEqual(v, projectProp)) { - obj["projectId"] = projectProp - } - - idProp, err := expandFirebaseProjectId(d.Get("id"), d, config) - if err != nil { - return nil, err - } else if v, ok := d.GetOkExists("id"); !tpgresource.IsEmptyValue(reflect.ValueOf(idProp)) && (ok || !reflect.DeepEqual(v, idProp)) { - obj["id"] = idProp - } - - projectNumberProp, err := expandFirebaseProjectProjectNumber(d.Get("project_number"), d, config) - if err != nil { - return nil, err - } else if v, ok := d.GetOkExists("project_number"); !tpgresource.IsEmptyValue(reflect.ValueOf(projectNumberProp)) && (ok || !reflect.DeepEqual(v, projectNumberProp)) { - obj["projectNumber"] = projectNumberProp - } - - displayNameProp, err := expandFirebaseProjectDisplayName(d.Get("display_name"), d, config) - if err != nil { - return nil, err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - - return obj, nil -} - -func expandFirebaseProjectDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandFirebaseProjectProjectNumber(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandFirebaseProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - v, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") - if err != nil { - return nil, err - } - - return v, nil -} - -func expandFirebaseProjectProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandFirebaseProjectName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} \ No newline at end of file diff --git a/tfplan2cai/converters/google/resources/resource_converters.go b/tfplan2cai/converters/google/resources/resource_converters.go index a7f957ad3..6c20baf3c 100644 --- a/tfplan2cai/converters/google/resources/resource_converters.go +++ b/tfplan2cai/converters/google/resources/resource_converters.go @@ -18,11 +18,14 @@ import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/accesscontextmanager" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/alloydb" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/apigee" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/apikeys" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/appengine" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/artifactregistry" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/bigquery" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/bigqueryanalyticshub" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/bigqueryconnection" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/bigquerydatapolicy" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/bigtable" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/binaryauthorization" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/clouddeploy" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/cloudfunctions" @@ -30,9 +33,12 @@ import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/cloudrun" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/cloudrunv2" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/cloudtasks" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/composer" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/compute" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/container" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/containeranalysis" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/datacatalog" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/dataflow" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/datafusion" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/dataplex" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/dataproc" @@ -40,6 +46,7 @@ import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/datastream" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/dns" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/filestore" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/firebase" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/gkebackup" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/gkehub" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/gkehub2" @@ -62,6 +69,7 @@ import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/servicemanagement" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/spanner" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/sql" + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/storage" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/vertexai" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/vpcaccess" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/services/workbench" @@ -78,10 +86,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()}, @@ -92,14 +100,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()}, @@ -108,31 +116,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_firebase_project": {firebase.ResourceConverterFirebaseProject()}, + "google_org_policy_policy": {resourcemanager.ResourceConverterOrgPolicyPolicy()}, "google_redis_instance": {redis.ResourceConverterRedisInstance()}, "google_spanner_database": {spanner.ResourceConverterSpannerDatabase()}, "google_spanner_database_iam_policy": {spanner.ResourceConverterSpannerDatabaseIamPolicy()}, @@ -142,7 +150,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()}, @@ -152,15 +160,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()}, @@ -171,7 +179,7 @@ func ResourceConverters() map[string][]cai.ResourceConverter { "google_cloud_run_service": {cloudrun.ResourceConverterCloudRunService()}, "google_cloud_run_domain_mapping": {cloudrun.ResourceConverterCloudRunDomainMapping()}, "google_cloud_run_v2_job": {cloudrunv2.ResourceConverterCloudRunV2Job()}, - "google_cloudfunctions_function": {resourceConverterCloudFunctionsCloudFunction()}, + "google_cloudfunctions_function": {cloudfunctions.ResourceConverterCloudFunctionsCloudFunction()}, "google_monitoring_notification_channel": {monitoring.ResourceConverterMonitoringNotificationChannel()}, "google_monitoring_alert_policy": {monitoring.ResourceConverterMonitoringAlertPolicy()}, "google_vertex_ai_dataset": {vertexai.ResourceConverterVertexAIDataset()}, @@ -401,37 +409,37 @@ func ResourceConverters() map[string][]cai.ResourceConverter { "google_workbench_instance_iam_binding": {workbench.ResourceConverterWorkbenchInstanceIamBinding()}, "google_workbench_instance_iam_member": {workbench.ResourceConverterWorkbenchInstanceIamMember()}, "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()}, } } diff --git a/tfplan2cai/converters/google/resources/apikeys_key.go b/tfplan2cai/converters/google/resources/services/apikeys/apikeys_key.go similarity index 98% rename from tfplan2cai/converters/google/resources/apikeys_key.go rename to tfplan2cai/converters/google/resources/services/apikeys/apikeys_key.go index 33fbb1016..3dad5789d 100644 --- a/tfplan2cai/converters/google/resources/apikeys_key.go +++ b/tfplan2cai/converters/google/resources/services/apikeys/apikeys_key.go @@ -1,4 +1,4 @@ -package google +package apikeys import ( "reflect" @@ -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, @@ -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 @@ -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 { @@ -235,10 +234,9 @@ func expandApikeysKeyService(v interface{}, d tpgresource.TerraformResourceData, } func expandApikeysKeyMethods(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return convertInterfaceToStringArray(v.([]interface{})), nil + return cai.ConvertInterfaceToStringArray(v.([]interface{})), nil } - func expandApikeysKeyDEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/tfplan2cai/converters/google/resources/appengine_application.go b/tfplan2cai/converters/google/resources/services/appengine/appengine_application.go similarity index 96% rename from tfplan2cai/converters/google/resources/appengine_application.go rename to tfplan2cai/converters/google/resources/services/appengine/appengine_application.go index c64f8db8c..bdd9ee2c3 100644 --- a/tfplan2cai/converters/google/resources/appengine_application.go +++ b/tfplan2cai/converters/google/resources/services/appengine/appengine_application.go @@ -1,4 +1,4 @@ -package google +package appengine import ( "reflect" @@ -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, @@ -55,7 +55,6 @@ func GetAppEngineApplicationApiObject(d tpgresource.TerraformResourceData, confi obj["location_id"] = locationIdProp } - return obj, nil } @@ -63,7 +62,6 @@ func expandAppEngineApplicationId(v interface{}, d tpgresource.TerraformResource return v, nil } - func expandAppEngineApplicationLocationId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/tfplan2cai/converters/google/resources/appengine_standard_version.go b/tfplan2cai/converters/google/resources/services/appengine/appengine_standard_version.go similarity index 99% rename from tfplan2cai/converters/google/resources/appengine_standard_version.go rename to tfplan2cai/converters/google/resources/services/appengine/appengine_standard_version.go index a86bfb70e..7d9a23685 100644 --- a/tfplan2cai/converters/google/resources/appengine_standard_version.go +++ b/tfplan2cai/converters/google/resources/services/appengine/appengine_standard_version.go @@ -1,4 +1,4 @@ -package google +package appengine import ( "reflect" @@ -12,7 +12,7 @@ import ( const AppEngineVersionAssetType string = "appengine.googleapis.com/Version" -func resourceAppEngineStandardAppVersion() cai.ResourceConverter { +func ResourceAppEngineStandardAppVersion() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: AppEngineVersionAssetType, Convert: GetAppEngineVersionCaiObject, diff --git a/tfplan2cai/converters/google/resources/bigquery_table.go b/tfplan2cai/converters/google/resources/services/bigquery/bigquery_table.go similarity index 99% rename from tfplan2cai/converters/google/resources/bigquery_table.go rename to tfplan2cai/converters/google/resources/services/bigquery/bigquery_table.go index 20ede57cc..a37f4a1cc 100644 --- a/tfplan2cai/converters/google/resources/bigquery_table.go +++ b/tfplan2cai/converters/google/resources/services/bigquery/bigquery_table.go @@ -1,4 +1,4 @@ -package google +package bigquery import ( "reflect" @@ -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, diff --git a/tfplan2cai/converters/google/resources/bigtable_cluster.go b/tfplan2cai/converters/google/resources/services/bigtable/bigtable_cluster.go similarity index 97% rename from tfplan2cai/converters/google/resources/bigtable_cluster.go rename to tfplan2cai/converters/google/resources/services/bigtable/bigtable_cluster.go index 99ce6e523..9f3129784 100644 --- a/tfplan2cai/converters/google/resources/bigtable_cluster.go +++ b/tfplan2cai/converters/google/resources/services/bigtable/bigtable_cluster.go @@ -1,4 +1,4 @@ -package google +package bigtable import ( "reflect" @@ -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, diff --git a/tfplan2cai/converters/google/resources/bigtable_instance.go b/tfplan2cai/converters/google/resources/services/bigtable/bigtable_instance.go similarity index 97% rename from tfplan2cai/converters/google/resources/bigtable_instance.go rename to tfplan2cai/converters/google/resources/services/bigtable/bigtable_instance.go index 6403eb378..fc63bb539 100644 --- a/tfplan2cai/converters/google/resources/bigtable_instance.go +++ b/tfplan2cai/converters/google/resources/services/bigtable/bigtable_instance.go @@ -1,4 +1,4 @@ -package google +package bigtable import ( "reflect" @@ -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, diff --git a/tfplan2cai/converters/google/resources/cloudfunctions_cloud_function.go b/tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_cloud_function.go similarity index 99% rename from tfplan2cai/converters/google/resources/cloudfunctions_cloud_function.go rename to tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_cloud_function.go index 7e5fb205c..c54d8ed57 100644 --- a/tfplan2cai/converters/google/resources/cloudfunctions_cloud_function.go +++ b/tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_cloud_function.go @@ -1,4 +1,4 @@ -package google +package cloudfunctions import ( "reflect" @@ -10,7 +10,7 @@ import ( const CloudFunctionsCloudFunctionAssetType string = "cloudfunctions.googleapis.com/CloudFunction" -func resourceConverterCloudFunctionsCloudFunction() cai.ResourceConverter { +func ResourceConverterCloudFunctionsCloudFunction() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: CloudFunctionsCloudFunctionAssetType, Convert: GetCloudFunctionsCloudFunctionCaiObject, diff --git a/tfplan2cai/converters/google/resources/cloudfunctions_function.go b/tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_function.go similarity index 99% rename from tfplan2cai/converters/google/resources/cloudfunctions_function.go rename to tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_function.go index 1f1d917d2..2ffb16e1d 100644 --- a/tfplan2cai/converters/google/resources/cloudfunctions_function.go +++ b/tfplan2cai/converters/google/resources/services/cloudfunctions/cloudfunctions_function.go @@ -1,4 +1,4 @@ -package google +package cloudfunctions import ( "reflect" diff --git a/tfplan2cai/converters/google/resources/composer_environment.go b/tfplan2cai/converters/google/resources/services/composer/composer_environment.go similarity index 99% rename from tfplan2cai/converters/google/resources/composer_environment.go rename to tfplan2cai/converters/google/resources/services/composer/composer_environment.go index fff555854..16963eefa 100644 --- a/tfplan2cai/converters/google/resources/composer_environment.go +++ b/tfplan2cai/converters/google/resources/services/composer/composer_environment.go @@ -1,4 +1,4 @@ -package google +package composer import ( "reflect" @@ -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, diff --git a/tfplan2cai/converters/google/resources/commitment.go b/tfplan2cai/converters/google/resources/services/compute/commitment.go similarity index 99% rename from tfplan2cai/converters/google/resources/commitment.go rename to tfplan2cai/converters/google/resources/services/compute/commitment.go index 26bb7d47d..a7dc1bff6 100644 --- a/tfplan2cai/converters/google/resources/commitment.go +++ b/tfplan2cai/converters/google/resources/services/compute/commitment.go @@ -1,4 +1,4 @@ -package google +package compute import ( "reflect" @@ -10,7 +10,7 @@ import ( const commitmentAssetType string = "compute.googleapis.com/Commitment" -func resourceConverterCommitment() cai.ResourceConverter { +func ResourceConverterCommitment() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: commitmentAssetType, Convert: GetCommitmentCaiObject, @@ -152,14 +152,14 @@ func GetCommitmentApiObject(d tpgresource.TerraformResourceData, config *transpo } else if v, ok := d.GetOkExists("start_timestamp"); !tpgresource.IsEmptyValue(reflect.ValueOf(statusMessageProp)) && (ok || !reflect.DeepEqual(v, statusMessageProp)) { obj["startTimestamp"] = startTimestampProp } - + endTimestampProp, err := expandCommitmentEndTimestamp(d.Get("end_timestamp"), d, config) if err != nil { return nil, err } else if v, ok := d.GetOkExists("end_timestamp"); !tpgresource.IsEmptyValue(reflect.ValueOf(endTimestampProp)) && (ok || !reflect.DeepEqual(v, endTimestampProp)) { obj["endTimestamp"] = endTimestampProp } - + selfLinkProp, err := expandCommitmentSelfLink(d.Get("self_link"), d, config) if err != nil { return nil, err @@ -323,4 +323,4 @@ func expandCommitmentPlan(v interface{}, d tpgresource.TerraformResourceData, co func expandCommitmentName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil -} \ No newline at end of file +} diff --git a/tfplan2cai/converters/google/resources/compute_instance_group.go b/tfplan2cai/converters/google/resources/services/compute/compute_instance_group.go similarity index 98% rename from tfplan2cai/converters/google/resources/compute_instance_group.go rename to tfplan2cai/converters/google/resources/services/compute/compute_instance_group.go index a7916bc32..5d6896143 100644 --- a/tfplan2cai/converters/google/resources/compute_instance_group.go +++ b/tfplan2cai/converters/google/resources/services/compute/compute_instance_group.go @@ -1,4 +1,4 @@ -package google +package compute import ( "reflect" @@ -10,7 +10,7 @@ import ( const ComputeInstanceGroupAssetType string = "compute.googleapis.com/InstanceGroup" -func resourceConverterComputeInstanceGroup() cai.ResourceConverter { +func ResourceConverterComputeInstanceGroup() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ComputeInstanceGroupAssetType, Convert: GetComputeInstanceGroupCaiObject, @@ -80,7 +80,7 @@ func GetComputeInstanceGroupApiObject(d tpgresource.TerraformResourceData, confi } url = url + zoneProp.(string) - obj["zone"] = url + obj["zone"] = url } selfLinkProp, err := expandComputeInstanceGroupSelfLink(d.Get("self_link"), d, config) if err != nil { @@ -152,4 +152,4 @@ func expandComputeInstanceGroupRegion(v interface{}, d tpgresource.TerraformReso func expandComputeInstanceGroupSubnetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil -} \ No newline at end of file +} diff --git a/tfplan2cai/converters/google/resources/compute_security_policy.go b/tfplan2cai/converters/google/resources/services/compute/compute_security_policy.go similarity index 99% rename from tfplan2cai/converters/google/resources/compute_security_policy.go rename to tfplan2cai/converters/google/resources/services/compute/compute_security_policy.go index 7107d175c..f9a1829cf 100644 --- a/tfplan2cai/converters/google/resources/compute_security_policy.go +++ b/tfplan2cai/converters/google/resources/services/compute/compute_security_policy.go @@ -1,4 +1,4 @@ -package google +package compute import ( "reflect" @@ -11,7 +11,7 @@ import ( const ComputeSecurityPolicyAssetType string = "compute.googleapis.com/SecurityPolicy" -func resourceConverterComputeSecurityPolicy() cai.ResourceConverter { +func ResourceConverterComputeSecurityPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ComputeSecurityPolicyAssetType, Convert: GetComputeSecurityPolicyCaiObject, diff --git a/tfplan2cai/converters/google/resources/compute_target_pool.go b/tfplan2cai/converters/google/resources/services/compute/compute_target_pool.go similarity index 98% rename from tfplan2cai/converters/google/resources/compute_target_pool.go rename to tfplan2cai/converters/google/resources/services/compute/compute_target_pool.go index 60a5e28b8..0174c0015 100644 --- a/tfplan2cai/converters/google/resources/compute_target_pool.go +++ b/tfplan2cai/converters/google/resources/services/compute/compute_target_pool.go @@ -1,4 +1,4 @@ -package google +package compute import ( "reflect" @@ -11,7 +11,7 @@ import ( const ComputeTargetPoolAssetType string = "compute.googleapis.com/TargetPool" -func resourceConverterComputeTargetPool() cai.ResourceConverter { +func ResourceConverterComputeTargetPool() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ComputeTargetPoolAssetType, Convert: GetComputeTargetPoolCaiObject, diff --git a/tfplan2cai/converters/google/resources/container.go b/tfplan2cai/converters/google/resources/services/container/container.go similarity index 99% rename from tfplan2cai/converters/google/resources/container.go rename to tfplan2cai/converters/google/resources/services/container/container.go index 4c7caa378..6da99c3da 100644 --- a/tfplan2cai/converters/google/resources/container.go +++ b/tfplan2cai/converters/google/resources/services/container/container.go @@ -4,7 +4,7 @@ // see https://github.com/GoogleCloudPlatform/magic-modules/pull/2485#issuecomment-545680059 // for the discussion. -package google +package container import ( "fmt" @@ -19,14 +19,14 @@ import ( const ContainerClusterAssetType string = "container.googleapis.com/Cluster" const ContainerNodePoolAssetType string = "container.googleapis.com/NodePool" -func resourceConverterContainerCluster() cai.ResourceConverter { +func ResourceConverterContainerCluster() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ContainerClusterAssetType, Convert: GetContainerClusterCaiObject, } } -func resourceConverterContainerNodePool() cai.ResourceConverter { +func ResourceConverterContainerNodePool() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ContainerNodePoolAssetType, Convert: GetContainerNodePoolCaiObject, diff --git a/tfplan2cai/converters/google/resources/job.go b/tfplan2cai/converters/google/resources/services/dataflow/job.go similarity index 99% rename from tfplan2cai/converters/google/resources/job.go rename to tfplan2cai/converters/google/resources/services/dataflow/job.go index 94cac9246..4675769fb 100644 --- a/tfplan2cai/converters/google/resources/job.go +++ b/tfplan2cai/converters/google/resources/services/dataflow/job.go @@ -1,4 +1,4 @@ -package google +package dataflow import ( "reflect" @@ -10,7 +10,7 @@ import ( const DataflowJobAssetType string = "dataflow.googleapis.com/Job" -func resourceDataflowJob() cai.ResourceConverter { +func ResourceDataflowJob() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: DataflowJobAssetType, Convert: GetDataflowJobCaiObject, @@ -302,4 +302,4 @@ func expandDataflowRuntimeUpdatableParams(v interface{}, d tpgresource.Terraform func expandDataflowSatisfiesPzi(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil -} \ No newline at end of file +} diff --git a/tfplan2cai/converters/google/resources/dataproc_cluster.go b/tfplan2cai/converters/google/resources/services/dataproc/dataproc_cluster.go similarity index 99% rename from tfplan2cai/converters/google/resources/dataproc_cluster.go rename to tfplan2cai/converters/google/resources/services/dataproc/dataproc_cluster.go index e33b81346..5cd634a35 100644 --- a/tfplan2cai/converters/google/resources/dataproc_cluster.go +++ b/tfplan2cai/converters/google/resources/services/dataproc/dataproc_cluster.go @@ -1,4 +1,4 @@ -package google +package dataproc import ( "reflect" @@ -11,7 +11,7 @@ import ( const DataprocClusterAssetType string = "dataproc.googleapis.com/Cluster" -func resourceConverterDataprocCluster() cai.ResourceConverter { +func ResourceConverterDataprocCluster() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: DataprocClusterAssetType, Convert: GetDataprocClusterCaiObject, diff --git a/tfplan2cai/converters/google/resources/services/firebase/firebase_project.go b/tfplan2cai/converters/google/resources/services/firebase/firebase_project.go index 66d33f232..7e553f6f0 100644 --- a/tfplan2cai/converters/google/resources/services/firebase/firebase_project.go +++ b/tfplan2cai/converters/google/resources/services/firebase/firebase_project.go @@ -1,79 +1,35 @@ -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - package firebase import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "reflect" "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func getExistingFirebaseProjectId(config *transport_tpg.Config, d *schema.ResourceData, billingProject string, userAgent string) (string, error) { - url, err := tpgresource.ReplaceVars(d, config, "{{FirebaseBasePath}}projects/{{project}}") - if err != nil { - return "", err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - }) - if err == nil { - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") - if err != nil { - return "", fmt.Errorf("Error constructing id: %s", err) - } - return id, nil - } - - if !transport_tpg.IsGoogleApiErrorWithCode(err, 404) { - return "", err - } - - return "", nil -} - -const FirebaseProjectAssetType string = "firebase.googleapis.com/Project" +const firebaseProjectAssetType string = "firebase.googleapis.com/FirebaseProject" func ResourceConverterFirebaseProject() cai.ResourceConverter { return cai.ResourceConverter{ - AssetType: FirebaseProjectAssetType, + AssetType: firebaseProjectAssetType, Convert: GetFirebaseProjectCaiObject, } } func GetFirebaseProjectCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { - name, err := cai.AssetName(d, config, "//firebase.googleapis.com/projects/{{project}}") + name, err := cai.AssetName(d, config, "//firebase.googleapis.com/v1beta1/projects/{{project}}") if err != nil { return []cai.Asset{}, err } if obj, err := GetFirebaseProjectApiObject(d, config); err == nil { return []cai.Asset{{ Name: name, - Type: FirebaseProjectAssetType, + Type: firebaseProjectAssetType, Resource: &cai.AssetResource{ Version: "v1beta1", - DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/firebase/v1beta1/rest", - DiscoveryName: "Project", + DiscoveryDocumentURI: "https://firebase.googleapis.com/$discovery/rest?version=v1beta1", + DiscoveryName: "FirebaseProject", Data: obj, }, }}, nil @@ -85,5 +41,65 @@ 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 + } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { + obj["name"] = nameProp + } + + projectProp, err := expandFirebaseProjectProjectId(d.Get("project"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("project"); !tpgresource.IsEmptyValue(reflect.ValueOf(projectProp)) && (ok || !reflect.DeepEqual(v, projectProp)) { + obj["projectId"] = projectProp + } + + idProp, err := expandFirebaseProjectId(d.Get("id"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("id"); !tpgresource.IsEmptyValue(reflect.ValueOf(idProp)) && (ok || !reflect.DeepEqual(v, idProp)) { + obj["id"] = idProp + } + + projectNumberProp, err := expandFirebaseProjectProjectNumber(d.Get("project_number"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("project_number"); !tpgresource.IsEmptyValue(reflect.ValueOf(projectNumberProp)) && (ok || !reflect.DeepEqual(v, projectNumberProp)) { + obj["projectNumber"] = projectNumberProp + } + + displayNameProp, err := expandFirebaseProjectDisplayName(d.Get("display_name"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { + obj["displayName"] = displayNameProp + } + return obj, nil } + +func expandFirebaseProjectDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandFirebaseProjectProjectNumber(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandFirebaseProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + v, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") + if err != nil { + return nil, err + } + + return v, nil +} + +func expandFirebaseProjectProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandFirebaseProjectName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/tfplan2cai/converters/google/resources/kms_crypto_key_iam.go b/tfplan2cai/converters/google/resources/services/kms/kms_crypto_key_iam.go similarity index 95% rename from tfplan2cai/converters/google/resources/kms_crypto_key_iam.go rename to tfplan2cai/converters/google/resources/services/kms/kms_crypto_key_iam.go index 201cef86c..2690a120e 100644 --- a/tfplan2cai/converters/google/resources/kms_crypto_key_iam.go +++ b/tfplan2cai/converters/google/resources/services/kms/kms_crypto_key_iam.go @@ -1,4 +1,4 @@ -package google +package kms import ( "fmt" @@ -10,7 +10,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterKmsCryptoKeyIamPolicy() cai.ResourceConverter { +func ResourceConverterKmsCryptoKeyIamPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/CryptoKey", Convert: GetKmsCryptoKeyIamPolicyCaiObject, @@ -18,7 +18,7 @@ func resourceConverterKmsCryptoKeyIamPolicy() cai.ResourceConverter { } } -func resourceConverterKmsCryptoKeyIamBinding() cai.ResourceConverter { +func ResourceConverterKmsCryptoKeyIamBinding() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/CryptoKey", Convert: GetKmsCryptoKeyIamBindingCaiObject, @@ -28,7 +28,7 @@ func resourceConverterKmsCryptoKeyIamBinding() cai.ResourceConverter { } } -func resourceConverterKmsCryptoKeyIamMember() cai.ResourceConverter { +func ResourceConverterKmsCryptoKeyIamMember() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/CryptoKey", Convert: GetKmsCryptoKeyIamMemberCaiObject, diff --git a/tfplan2cai/converters/google/resources/kms_key_ring_iam.go b/tfplan2cai/converters/google/resources/services/kms/kms_key_ring_iam.go similarity index 95% rename from tfplan2cai/converters/google/resources/kms_key_ring_iam.go rename to tfplan2cai/converters/google/resources/services/kms/kms_key_ring_iam.go index 57404f814..6197ed499 100644 --- a/tfplan2cai/converters/google/resources/kms_key_ring_iam.go +++ b/tfplan2cai/converters/google/resources/services/kms/kms_key_ring_iam.go @@ -1,4 +1,4 @@ -package google +package kms import ( "fmt" @@ -10,7 +10,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterKmsKeyRingIamPolicy() cai.ResourceConverter { +func ResourceConverterKmsKeyRingIamPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/KeyRing", Convert: GetKmsKeyRingIamPolicyCaiObject, @@ -18,7 +18,7 @@ func resourceConverterKmsKeyRingIamPolicy() cai.ResourceConverter { } } -func resourceConverterKmsKeyRingIamBinding() cai.ResourceConverter { +func ResourceConverterKmsKeyRingIamBinding() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/KeyRing", Convert: GetKmsKeyRingIamBindingCaiObject, @@ -28,7 +28,7 @@ func resourceConverterKmsKeyRingIamBinding() cai.ResourceConverter { } } -func resourceConverterKmsKeyRingIamMember() cai.ResourceConverter { +func ResourceConverterKmsKeyRingIamMember() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudkms.googleapis.com/KeyRing", Convert: GetKmsKeyRingIamMemberCaiObject, diff --git a/tfplan2cai/converters/google/resources/logging_billing_account_bucket_config.go b/tfplan2cai/converters/google/resources/services/logging/logging_billing_account_bucket_config.go similarity index 98% rename from tfplan2cai/converters/google/resources/logging_billing_account_bucket_config.go rename to tfplan2cai/converters/google/resources/services/logging/logging_billing_account_bucket_config.go index 741e11a59..6a1dae39b 100644 --- a/tfplan2cai/converters/google/resources/logging_billing_account_bucket_config.go +++ b/tfplan2cai/converters/google/resources/services/logging/logging_billing_account_bucket_config.go @@ -1,4 +1,4 @@ -package google +package logging import ( "reflect" @@ -12,7 +12,7 @@ import ( const logBillingAccountBucketAssetType string = "logging.googleapis.com/LogBucket" -func resourceConverterLogBillingAccountBucket() cai.ResourceConverter { +func ResourceConverterLogBillingAccountBucket() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: logBillingAccountBucketAssetType, Convert: GetLogBillingAccountBucketCaiObject, diff --git a/tfplan2cai/converters/google/resources/logging_folder_bucket_config.go b/tfplan2cai/converters/google/resources/services/logging/logging_folder_bucket_config.go similarity index 98% rename from tfplan2cai/converters/google/resources/logging_folder_bucket_config.go rename to tfplan2cai/converters/google/resources/services/logging/logging_folder_bucket_config.go index 564fc2555..b2c0e2703 100644 --- a/tfplan2cai/converters/google/resources/logging_folder_bucket_config.go +++ b/tfplan2cai/converters/google/resources/services/logging/logging_folder_bucket_config.go @@ -1,4 +1,4 @@ -package google +package logging import ( "reflect" @@ -12,7 +12,7 @@ import ( const logFolderBucketAssetType string = "logging.googleapis.com/LogBucket" -func resourceConverterLogFolderBucket() cai.ResourceConverter { +func ResourceConverterLogFolderBucket() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: logFolderBucketAssetType, Convert: GetLogFolderBucketCaiObject, diff --git a/tfplan2cai/converters/google/resources/logging_organization_bucket_config.go b/tfplan2cai/converters/google/resources/services/logging/logging_organization_bucket_config.go similarity index 98% rename from tfplan2cai/converters/google/resources/logging_organization_bucket_config.go rename to tfplan2cai/converters/google/resources/services/logging/logging_organization_bucket_config.go index c617d9616..a4de258d9 100644 --- a/tfplan2cai/converters/google/resources/logging_organization_bucket_config.go +++ b/tfplan2cai/converters/google/resources/services/logging/logging_organization_bucket_config.go @@ -1,4 +1,4 @@ -package google +package logging import ( "reflect" @@ -12,7 +12,7 @@ import ( const logOrganizationBucketAssetType string = "logging.googleapis.com/LogBucket" -func resourceConverterLogOrganizationBucket() cai.ResourceConverter { +func ResourceConverterLogOrganizationBucket() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: logOrganizationBucketAssetType, Convert: GetLogOrganizationBucketCaiObject, diff --git a/tfplan2cai/converters/google/resources/logging_project_bucket_config.go b/tfplan2cai/converters/google/resources/services/logging/logging_project_bucket_config.go similarity index 98% rename from tfplan2cai/converters/google/resources/logging_project_bucket_config.go rename to tfplan2cai/converters/google/resources/services/logging/logging_project_bucket_config.go index 77e96884a..6db9b4fee 100644 --- a/tfplan2cai/converters/google/resources/logging_project_bucket_config.go +++ b/tfplan2cai/converters/google/resources/services/logging/logging_project_bucket_config.go @@ -1,4 +1,4 @@ -package google +package logging import ( "reflect" @@ -12,7 +12,7 @@ import ( const logProjectBucketAssetType string = "logging.googleapis.com/LogBucket" -func resourceConverterLogProjectBucket() cai.ResourceConverter { +func ResourceConverterLogProjectBucket() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: logProjectBucketAssetType, Convert: GetLogProjectBucketCaiObject, diff --git a/tfplan2cai/converters/google/resources/folder.go b/tfplan2cai/converters/google/resources/services/resourcemanager/folder.go similarity index 95% rename from tfplan2cai/converters/google/resources/folder.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/folder.go index cdcf1b564..3dd43c056 100644 --- a/tfplan2cai/converters/google/resources/folder.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/folder.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "time" @@ -8,7 +8,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterFolder() cai.ResourceConverter { +func ResourceConverterFolder() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudresourcemanager.googleapis.com/Folder", Convert: GetFolderCaiObject, diff --git a/tfplan2cai/converters/google/resources/folder_organization_policy.go b/tfplan2cai/converters/google/resources/services/resourcemanager/folder_organization_policy.go similarity index 95% rename from tfplan2cai/converters/google/resources/folder_organization_policy.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/folder_organization_policy.go index 275743e35..16a50cefe 100644 --- a/tfplan2cai/converters/google/resources/folder_organization_policy.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/folder_organization_policy.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" @@ -6,7 +6,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterFolderOrgPolicy() cai.ResourceConverter { +func ResourceConverterFolderOrgPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudresourcemanager.googleapis.com/Folder", Convert: GetFolderOrgPolicyCaiObject, diff --git a/tfplan2cai/converters/google/resources/org_policy_policy.go b/tfplan2cai/converters/google/resources/services/resourcemanager/org_policy_policy.go similarity index 91% rename from tfplan2cai/converters/google/resources/org_policy_policy.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/org_policy_policy.go index bf14d9a52..26773f65a 100644 --- a/tfplan2cai/converters/google/resources/org_policy_policy.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/org_policy_policy.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "fmt" @@ -9,7 +9,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterOrgPolicyPolicy() cai.ResourceConverter { +func ResourceConverterOrgPolicyPolicy() cai.ResourceConverter { return cai.ResourceConverter{ Convert: GetV2OrgPoliciesCaiObject, MergeCreateUpdate: MergeV2OrgPolicies, @@ -150,8 +150,8 @@ func expandValuesPolicyRule(configured []interface{}) (*cai.StringValues, error) } valuesMap := configured[0].(map[string]interface{}) return &cai.StringValues{ - AllowedValues: convertInterfaceToStringArray(valuesMap["allowed_values"].([]interface{})), - DeniedValues: convertInterfaceToStringArray(valuesMap["denied_values"].([]interface{})), + AllowedValues: cai.ConvertInterfaceToStringArray(valuesMap["allowed_values"].([]interface{})), + DeniedValues: cai.ConvertInterfaceToStringArray(valuesMap["denied_values"].([]interface{})), }, nil } @@ -177,11 +177,3 @@ func convertStringToBool(val string) (bool, error) { return false, fmt.Errorf("Invalid value for a boolean field: %s", val) } - -func convertInterfaceToStringArray(values []interface{}) []string { - stringArray := make([]string, len(values)) - for i, v := range values { - stringArray[i] = v.(string) - } - return stringArray -} diff --git a/tfplan2cai/converters/google/resources/organization_iam_custom_role.go b/tfplan2cai/converters/google/resources/services/resourcemanager/organization_iam_custom_role.go similarity index 97% rename from tfplan2cai/converters/google/resources/organization_iam_custom_role.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/organization_iam_custom_role.go index 439975955..65bab3d11 100644 --- a/tfplan2cai/converters/google/resources/organization_iam_custom_role.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/organization_iam_custom_role.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "reflect" @@ -11,7 +11,7 @@ import ( const OrganizationIAMCustomRoleAssetType string = "iam.googleapis.com/Role" -func resourceConverterOrganizationIAMCustomRole() cai.ResourceConverter { +func ResourceConverterOrganizationIAMCustomRole() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: OrganizationIAMCustomRoleAssetType, Convert: GetOrganizationIAMCustomRoleCaiObject, diff --git a/tfplan2cai/converters/google/resources/organization_policy.go b/tfplan2cai/converters/google/resources/services/resourcemanager/organization_policy.go similarity index 95% rename from tfplan2cai/converters/google/resources/organization_policy.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/organization_policy.go index 123689001..0d894cc13 100644 --- a/tfplan2cai/converters/google/resources/organization_policy.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/organization_policy.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" @@ -6,7 +6,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterOrganizationPolicy() cai.ResourceConverter { +func ResourceConverterOrganizationPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudresourcemanager.googleapis.com/Organization", Convert: GetOrganizationPolicyCaiObject, diff --git a/tfplan2cai/converters/google/resources/project.go b/tfplan2cai/converters/google/resources/services/resourcemanager/project.go similarity index 96% rename from tfplan2cai/converters/google/resources/project.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/project.go index 9f33a8a95..c43fc4426 100644 --- a/tfplan2cai/converters/google/resources/project.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/project.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "fmt" @@ -11,7 +11,7 @@ import ( "google.golang.org/api/cloudresourcemanager/v1" ) -func resourceConverterProject() cai.ResourceConverter { +func ResourceConverterProject() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudresourcemanager.googleapis.com/Project", Convert: GetProjectCaiObject, @@ -19,7 +19,7 @@ func resourceConverterProject() cai.ResourceConverter { } } -func resourceConverterProjectBillingInfo() cai.ResourceConverter { +func ResourceConverterProjectBillingInfo() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudbilling.googleapis.com/ProjectBillingInfo", Convert: GetProjectBillingInfoCaiObject, diff --git a/tfplan2cai/converters/google/resources/project_iam_custom_role.go b/tfplan2cai/converters/google/resources/services/resourcemanager/project_iam_custom_role.go similarity index 97% rename from tfplan2cai/converters/google/resources/project_iam_custom_role.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/project_iam_custom_role.go index e16bbcc15..21188a195 100644 --- a/tfplan2cai/converters/google/resources/project_iam_custom_role.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/project_iam_custom_role.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "reflect" @@ -11,7 +11,7 @@ import ( const ProjectIAMCustomRoleAssetType string = "iam.googleapis.com/Role" -func resourceConverterProjectIAMCustomRole() cai.ResourceConverter { +func ResourceConverterProjectIAMCustomRole() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ProjectIAMCustomRoleAssetType, Convert: GetProjectIAMCustomRoleCaiObject, diff --git a/tfplan2cai/converters/google/resources/project_organization_policy.go b/tfplan2cai/converters/google/resources/services/resourcemanager/project_organization_policy.go similarity index 97% rename from tfplan2cai/converters/google/resources/project_organization_policy.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/project_organization_policy.go index 16a9b73f7..a9f14545f 100644 --- a/tfplan2cai/converters/google/resources/project_organization_policy.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/project_organization_policy.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "fmt" @@ -10,7 +10,7 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" ) -func resourceConverterProjectOrgPolicy() cai.ResourceConverter { +func ResourceConverterProjectOrgPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: "cloudresourcemanager.googleapis.com/Project", Convert: GetProjectOrgPolicyCaiObject, diff --git a/tfplan2cai/converters/google/resources/project_service.go b/tfplan2cai/converters/google/resources/services/resourcemanager/project_service.go similarity index 96% rename from tfplan2cai/converters/google/resources/project_service.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/project_service.go index 50eeae0ba..8babed065 100644 --- a/tfplan2cai/converters/google/resources/project_service.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/project_service.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "fmt" @@ -11,7 +11,7 @@ import ( const ServiceUsageAssetType string = "serviceusage.googleapis.com/Service" -func resourceConverterServiceUsage() cai.ResourceConverter { +func ResourceConverterServiceUsage() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ServiceUsageAssetType, Convert: GetServiceUsageCaiObject, diff --git a/tfplan2cai/converters/google/resources/service_account.go b/tfplan2cai/converters/google/resources/services/resourcemanager/service_account.go similarity index 98% rename from tfplan2cai/converters/google/resources/service_account.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/service_account.go index b9cc14038..d3f7509ee 100644 --- a/tfplan2cai/converters/google/resources/service_account.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/service_account.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "fmt" @@ -11,7 +11,7 @@ import ( const ServiceAccountAssetType string = "iam.googleapis.com/ServiceAccount" -func resourceConverterServiceAccount() cai.ResourceConverter { +func ResourceConverterServiceAccount() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ServiceAccountAssetType, Convert: GetServiceAccountCaiObject, diff --git a/tfplan2cai/converters/google/resources/service_account_key.go b/tfplan2cai/converters/google/resources/services/resourcemanager/service_account_key.go similarity index 99% rename from tfplan2cai/converters/google/resources/service_account_key.go rename to tfplan2cai/converters/google/resources/services/resourcemanager/service_account_key.go index c62b3b14f..7835ea49d 100644 --- a/tfplan2cai/converters/google/resources/service_account_key.go +++ b/tfplan2cai/converters/google/resources/services/resourcemanager/service_account_key.go @@ -1,4 +1,4 @@ -package google +package resourcemanager import ( "reflect" @@ -10,7 +10,7 @@ import ( const ServiceAccountKeyAssetType string = "iam.googleapis.com/ServiceAccountKey" -func resourceConverterServiceAccountKey() cai.ResourceConverter { +func ResourceConverterServiceAccountKey() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: ServiceAccountKeyAssetType, Convert: GetServiceAccountKeyCaiObject, diff --git a/tfplan2cai/converters/google/resources/sql_database_instance.go b/tfplan2cai/converters/google/resources/services/sql/sql_database_instance.go similarity index 99% rename from tfplan2cai/converters/google/resources/sql_database_instance.go rename to tfplan2cai/converters/google/resources/services/sql/sql_database_instance.go index 3903b31f2..baeccda26 100644 --- a/tfplan2cai/converters/google/resources/sql_database_instance.go +++ b/tfplan2cai/converters/google/resources/services/sql/sql_database_instance.go @@ -6,7 +6,7 @@ // third_party/terraform/resources/resource_sql_database_instance.go.erb.go // // ---------------------------------------------------------------------------- -package google +package sql import ( "regexp" @@ -22,7 +22,7 @@ import ( const SQLDatabaseInstanceAssetType string = "sqladmin.googleapis.com/Instance" -func resourceConverterSQLDatabaseInstance() cai.ResourceConverter { +func ResourceConverterSQLDatabaseInstance() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: SQLDatabaseInstanceAssetType, Convert: GetSQLDatabaseInstanceCaiObject, diff --git a/tfplan2cai/converters/google/resources/iam_storage_bucket.go b/tfplan2cai/converters/google/resources/services/storage/iam_storage_bucket.go similarity index 99% rename from tfplan2cai/converters/google/resources/iam_storage_bucket.go rename to tfplan2cai/converters/google/resources/services/storage/iam_storage_bucket.go index 44b1ce92a..57258ff04 100644 --- a/tfplan2cai/converters/google/resources/iam_storage_bucket.go +++ b/tfplan2cai/converters/google/resources/services/storage/iam_storage_bucket.go @@ -1,4 +1,4 @@ -package google +package storage import ( "fmt" diff --git a/tfplan2cai/converters/google/resources/storage_bucket.go b/tfplan2cai/converters/google/resources/services/storage/storage_bucket.go similarity index 99% rename from tfplan2cai/converters/google/resources/storage_bucket.go rename to tfplan2cai/converters/google/resources/services/storage/storage_bucket.go index 1bacf205a..3bd3f4ae4 100644 --- a/tfplan2cai/converters/google/resources/storage_bucket.go +++ b/tfplan2cai/converters/google/resources/services/storage/storage_bucket.go @@ -6,7 +6,7 @@ // third_party/terraform/resources/resource_storage_bucket.go // // ---------------------------------------------------------------------------- -package google +package storage import ( "fmt" @@ -21,7 +21,7 @@ import ( const StorageBucketAssetType string = "storage.googleapis.com/Bucket" -func resourceConverterStorageBucket() cai.ResourceConverter { +func ResourceConverterStorageBucket() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: StorageBucketAssetType, Convert: GetStorageBucketCaiObject, diff --git a/tfplan2cai/converters/google/resources/storage_bucket_iam.go b/tfplan2cai/converters/google/resources/services/storage/storage_bucket_iam.go similarity index 94% rename from tfplan2cai/converters/google/resources/storage_bucket_iam.go rename to tfplan2cai/converters/google/resources/services/storage/storage_bucket_iam.go index f88e54c5d..6ced5b8c6 100644 --- a/tfplan2cai/converters/google/resources/storage_bucket_iam.go +++ b/tfplan2cai/converters/google/resources/services/storage/storage_bucket_iam.go @@ -1,4 +1,4 @@ -package google +package storage import ( "fmt" @@ -11,7 +11,7 @@ import ( // Provide a separate asset type constant so we don't have to worry about name conflicts between IAM and non-IAM converter files const StorageBucketIAMAssetType string = "storage.googleapis.com/Bucket" -func resourceConverterStorageBucketIamPolicy() cai.ResourceConverter { +func ResourceConverterStorageBucketIamPolicy() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: StorageBucketIAMAssetType, Convert: GetStorageBucketIamPolicyCaiObject, @@ -19,7 +19,7 @@ func resourceConverterStorageBucketIamPolicy() cai.ResourceConverter { } } -func resourceConverterStorageBucketIamBinding() cai.ResourceConverter { +func ResourceConverterStorageBucketIamBinding() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: StorageBucketIAMAssetType, Convert: GetStorageBucketIamBindingCaiObject, @@ -29,7 +29,7 @@ func resourceConverterStorageBucketIamBinding() cai.ResourceConverter { } } -func resourceConverterStorageBucketIamMember() cai.ResourceConverter { +func ResourceConverterStorageBucketIamMember() cai.ResourceConverter { return cai.ResourceConverter{ AssetType: StorageBucketIAMAssetType, Convert: GetStorageBucketIamMemberCaiObject,