diff --git a/go.mod b/go.mod index 25f6b42a0..4acbcc143 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/terraform-json v0.21.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240325181751-4300f1ddf3d9 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240326163212-6928d4ef51d7 github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index dddfbd30e..e960c0ec0 100644 --- a/go.sum +++ b/go.sum @@ -185,8 +185,8 @@ github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9 github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240325181751-4300f1ddf3d9 h1:CDgU36e7QrZngPYygAjSXfK3oB/zOyxsEINDkATgHrw= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240325181751-4300f1ddf3d9/go.mod h1:GesRWDMaDeOpEw0LUy2r48oumdoocoCIWoCBj4MomRY= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240326163212-6928d4ef51d7 h1:mwMpNTQlH5S/78duhr+/2XXIMfI+V7oAxEx0cdJDQSs= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240326163212-6928d4ef51d7/go.mod h1:GesRWDMaDeOpEw0LUy2r48oumdoocoCIWoCBj4MomRY= 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/services/cloudquotas/cloudquotas_quota_preference.go b/tfplan2cai/converters/google/resources/services/cloudquotas/cloudquotas_quota_preference.go new file mode 100644 index 000000000..c184b01f2 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/cloudquotas/cloudquotas_quota_preference.go @@ -0,0 +1,217 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 cloudquotas + +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 CloudQuotasQuotaPreferenceAssetType string = "cloudquotas.googleapis.com/QuotaPreference" + +func ResourceConverterCloudQuotasQuotaPreference() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: CloudQuotasQuotaPreferenceAssetType, + Convert: GetCloudQuotasQuotaPreferenceCaiObject, + } +} + +func GetCloudQuotasQuotaPreferenceCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//cloudquotas.googleapis.com/{{parent}}/locations/global/quotaPreferences/{{name}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetCloudQuotasQuotaPreferenceApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: CloudQuotasQuotaPreferenceAssetType, + Resource: &cai.AssetResource{ + Version: "v1", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/cloudquotas/v1/rest", + DiscoveryName: "QuotaPreference", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetCloudQuotasQuotaPreferenceApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + nameProp, err := expandCloudQuotasQuotaPreferenceName(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 + } + serviceProp, err := expandCloudQuotasQuotaPreferenceService(d.Get("service"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("service"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceProp)) && (ok || !reflect.DeepEqual(v, serviceProp)) { + obj["service"] = serviceProp + } + quotaIdProp, err := expandCloudQuotasQuotaPreferenceQuotaId(d.Get("quota_id"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("quota_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaIdProp)) && (ok || !reflect.DeepEqual(v, quotaIdProp)) { + obj["quotaId"] = quotaIdProp + } + quotaConfigProp, err := expandCloudQuotasQuotaPreferenceQuotaConfig(d.Get("quota_config"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("quota_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaConfigProp)) && (ok || !reflect.DeepEqual(v, quotaConfigProp)) { + obj["quotaConfig"] = quotaConfigProp + } + dimensionsProp, err := expandCloudQuotasQuotaPreferenceDimensions(d.Get("dimensions"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("dimensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(dimensionsProp)) && (ok || !reflect.DeepEqual(v, dimensionsProp)) { + obj["dimensions"] = dimensionsProp + } + justificationProp, err := expandCloudQuotasQuotaPreferenceJustification(d.Get("justification"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("justification"); !tpgresource.IsEmptyValue(reflect.ValueOf(justificationProp)) && (ok || !reflect.DeepEqual(v, justificationProp)) { + obj["justification"] = justificationProp + } + contactEmailProp, err := expandCloudQuotasQuotaPreferenceContactEmail(d.Get("contact_email"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("contact_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(contactEmailProp)) && (ok || !reflect.DeepEqual(v, contactEmailProp)) { + obj["contactEmail"] = contactEmailProp + } + + return obj, nil +} + +func expandCloudQuotasQuotaPreferenceName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return tpgresource.GetResourceNameFromSelfLink(v.(string)), nil +} + +func expandCloudQuotasQuotaPreferenceService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedPreferredValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(original["preferred_value"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPreferredValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["preferredValue"] = transformedPreferredValue + } + + transformedStateDetail, err := expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(original["state_detail"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedStateDetail); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["stateDetail"] = transformedStateDetail + } + + transformedGrantedValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(original["granted_value"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedGrantedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["grantedValue"] = transformedGrantedValue + } + + transformedTraceId, err := expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(original["trace_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedTraceId); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["traceId"] = transformedTraceId + } + + transformedAnnotations, err := expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(original["annotations"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAnnotations); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["annotations"] = transformedAnnotations + } + + transformedRequestOrigin, err := expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(original["request_origin"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedRequestOrigin); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["requestOrigin"] = transformedRequestOrigin + } + + return transformed, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceDimensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} + +func expandCloudQuotasQuotaPreferenceJustification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudQuotasQuotaPreferenceContactEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go index 1f77927e0..9669c1d05 100644 --- a/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go +++ b/tfplan2cai/converters/google/resources/services/cloudrunv2/cloudrunv2_job.go @@ -628,6 +628,13 @@ func expandCloudRunV2JobTemplateTemplateVolumes(v interface{}, d tpgresource.Ter transformed["emptyDir"] = transformedEmptyDir } + transformedGcs, err := expandCloudRunV2JobTemplateTemplateVolumesGcs(original["gcs"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedGcs); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["gcs"] = transformedGcs + } + req = append(req, transformed) } return req, nil @@ -783,6 +790,40 @@ func expandCloudRunV2JobTemplateTemplateVolumesEmptyDirSizeLimit(v interface{}, return v, nil } +func expandCloudRunV2JobTemplateTemplateVolumesGcs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedBucket, err := expandCloudRunV2JobTemplateTemplateVolumesGcsBucket(original["bucket"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedBucket); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["bucket"] = transformedBucket + } + + transformedReadOnly, err := expandCloudRunV2JobTemplateTemplateVolumesGcsReadOnly(original["read_only"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedReadOnly); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["readOnly"] = transformedReadOnly + } + + return transformed, nil +} + +func expandCloudRunV2JobTemplateTemplateVolumesGcsBucket(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandCloudRunV2JobTemplateTemplateVolumesGcsReadOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandCloudRunV2JobTemplateTemplateTimeout(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/tfplan2cai/converters/google/resources/services/dataprocmetastore/dataprocmetastore_service.go b/tfplan2cai/converters/google/resources/services/dataprocmetastore/dataprocmetastore_service.go index 2a60c7a5c..3452aa2b3 100644 --- a/tfplan2cai/converters/google/resources/services/dataprocmetastore/dataprocmetastore_service.go +++ b/tfplan2cai/converters/google/resources/services/dataprocmetastore/dataprocmetastore_service.go @@ -80,6 +80,12 @@ func GetDataprocMetastoreServiceApiObject(d tpgresource.TerraformResourceData, c } else if v, ok := d.GetOkExists("scaling_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(scalingConfigProp)) && (ok || !reflect.DeepEqual(v, scalingConfigProp)) { obj["scalingConfig"] = scalingConfigProp } + scheduledBackupProp, err := expandDataprocMetastoreServiceScheduledBackup(d.Get("scheduled_backup"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("scheduled_backup"); !tpgresource.IsEmptyValue(reflect.ValueOf(scheduledBackupProp)) && (ok || !reflect.DeepEqual(v, scheduledBackupProp)) { + obj["scheduledBackup"] = scheduledBackupProp + } maintenanceWindowProp, err := expandDataprocMetastoreServiceMaintenanceWindow(d.Get("maintenance_window"), d, config) if err != nil { return nil, err @@ -184,6 +190,62 @@ func expandDataprocMetastoreServiceScalingConfigScalingFactor(v interface{}, d t return v, nil } +func expandDataprocMetastoreServiceScheduledBackup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedEnabled, err := expandDataprocMetastoreServiceScheduledBackupEnabled(original["enabled"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["enabled"] = transformedEnabled + } + + transformedCronSchedule, err := expandDataprocMetastoreServiceScheduledBackupCronSchedule(original["cron_schedule"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCronSchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["cronSchedule"] = transformedCronSchedule + } + + transformedTimeZone, err := expandDataprocMetastoreServiceScheduledBackupTimeZone(original["time_zone"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedTimeZone); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["timeZone"] = transformedTimeZone + } + + transformedBackupLocation, err := expandDataprocMetastoreServiceScheduledBackupBackupLocation(original["backup_location"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedBackupLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["backupLocation"] = transformedBackupLocation + } + + return transformed, nil +} + +func expandDataprocMetastoreServiceScheduledBackupEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataprocMetastoreServiceScheduledBackupCronSchedule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataprocMetastoreServiceScheduledBackupTimeZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDataprocMetastoreServiceScheduledBackupBackupLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDataprocMetastoreServiceMaintenanceWindow(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/tfplan2cai/converters/google/resources/services/integrations/integrations_client.go b/tfplan2cai/converters/google/resources/services/integrations/integrations_client.go new file mode 100644 index 000000000..e23a120ad --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/integrations/integrations_client.go @@ -0,0 +1,57 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 integrations + +import ( + "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 IntegrationsClientAssetType string = "integrations.googleapis.com/Client" + +func ResourceConverterIntegrationsClient() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: IntegrationsClientAssetType, + Convert: GetIntegrationsClientCaiObject, + } +} + +func GetIntegrationsClientCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//integrations.googleapis.com/projects/{{project}}/locations/{{location}}/clients") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetIntegrationsClientApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: IntegrationsClientAssetType, + Resource: &cai.AssetResource{ + Version: "v1", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/integrations/v1/rest", + DiscoveryName: "Client", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetIntegrationsClientApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + + return obj, nil +} diff --git a/tfplan2cai/converters/google/resources/services/networksecurity/networksecurity_firewall_endpoint.go b/tfplan2cai/converters/google/resources/services/networksecurity/networksecurity_firewall_endpoint.go index d603be6e1..d6d7297df 100644 --- a/tfplan2cai/converters/google/resources/services/networksecurity/networksecurity_firewall_endpoint.go +++ b/tfplan2cai/converters/google/resources/services/networksecurity/networksecurity_firewall_endpoint.go @@ -54,6 +54,12 @@ func GetNetworkSecurityFirewallEndpointCaiObject(d tpgresource.TerraformResource func GetNetworkSecurityFirewallEndpointApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { obj := make(map[string]interface{}) + billingProjectIdProp, err := expandNetworkSecurityFirewallEndpointBillingProjectId(d.Get("billing_project_id"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("billing_project_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(billingProjectIdProp)) && (ok || !reflect.DeepEqual(v, billingProjectIdProp)) { + obj["billingProjectId"] = billingProjectIdProp + } labelsProp, err := expandNetworkSecurityFirewallEndpointEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return nil, err @@ -64,6 +70,10 @@ func GetNetworkSecurityFirewallEndpointApiObject(d tpgresource.TerraformResource return obj, nil } +func expandNetworkSecurityFirewallEndpointBillingProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandNetworkSecurityFirewallEndpointEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/tfplan2cai/converters/google/resources/services/pubsub/pubsub_topic.go b/tfplan2cai/converters/google/resources/services/pubsub/pubsub_topic.go index bc084afd3..7077e5414 100644 --- a/tfplan2cai/converters/google/resources/services/pubsub/pubsub_topic.go +++ b/tfplan2cai/converters/google/resources/services/pubsub/pubsub_topic.go @@ -84,6 +84,12 @@ func GetPubsubTopicApiObject(d tpgresource.TerraformResourceData, config *transp } else if v, ok := d.GetOkExists("message_retention_duration"); !tpgresource.IsEmptyValue(reflect.ValueOf(messageRetentionDurationProp)) && (ok || !reflect.DeepEqual(v, messageRetentionDurationProp)) { obj["messageRetentionDuration"] = messageRetentionDurationProp } + ingestionDataSourceSettingsProp, err := expandPubsubTopicIngestionDataSourceSettings(d.Get("ingestion_data_source_settings"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("ingestion_data_source_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(ingestionDataSourceSettingsProp)) && (ok || !reflect.DeepEqual(v, ingestionDataSourceSettingsProp)) { + obj["ingestionDataSourceSettings"] = ingestionDataSourceSettingsProp + } labelsProp, err := expandPubsubTopicEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return nil, err @@ -168,6 +174,81 @@ func expandPubsubTopicMessageRetentionDuration(v interface{}, d tpgresource.Terr return v, nil } +func expandPubsubTopicIngestionDataSourceSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedAwsKinesis, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesis(original["aws_kinesis"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAwsKinesis); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["awsKinesis"] = transformedAwsKinesis + } + + return transformed, nil +} + +func expandPubsubTopicIngestionDataSourceSettingsAwsKinesis(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedStreamArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(original["stream_arn"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedStreamArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["streamArn"] = transformedStreamArn + } + + transformedConsumerArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(original["consumer_arn"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedConsumerArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["consumerArn"] = transformedConsumerArn + } + + transformedAwsRoleArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(original["aws_role_arn"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAwsRoleArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["awsRoleArn"] = transformedAwsRoleArn + } + + transformedGcpServiceAccount, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(original["gcp_service_account"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedGcpServiceAccount); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["gcpServiceAccount"] = transformedGcpServiceAccount + } + + return transformed, nil +} + +func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandPubsubTopicEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/tfplan2cai/converters/google/resources/services/spanner/spanner_database.go b/tfplan2cai/converters/google/resources/services/spanner/spanner_database.go index efeca317d..490451bf0 100644 --- a/tfplan2cai/converters/google/resources/services/spanner/spanner_database.go +++ b/tfplan2cai/converters/google/resources/services/spanner/spanner_database.go @@ -19,8 +19,6 @@ import ( "fmt" "log" "reflect" - "regexp" - "strconv" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -61,44 +59,6 @@ func resourceSpannerDBDdlCustomDiff(_ context.Context, diff *schema.ResourceDiff return resourceSpannerDBDdlCustomDiffFunc(diff) } -func ValidateDatabaseRetentionPeriod(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - valueError := fmt.Errorf("version_retention_period should be in range [1h, 7d], in a format resembling 1d, 24h, 1440m, or 86400s") - - r := regexp.MustCompile("^(\\d{1}d|\\d{1,3}h|\\d{2,5}m|\\d{4,6}s)$") - if !r.MatchString(value) { - errors = append(errors, valueError) - return - } - - unit := value[len(value)-1:] - multiple := value[:len(value)-1] - num, err := strconv.Atoi(multiple) - if err != nil { - errors = append(errors, valueError) - return - } - - if unit == "d" && (num < 1 || num > 7) { - errors = append(errors, valueError) - return - } - if unit == "h" && (num < 1 || num > 7*24) { - errors = append(errors, valueError) - return - } - if unit == "m" && (num < 1*60 || num > 7*24*60) { - errors = append(errors, valueError) - return - } - if unit == "s" && (num < 1*60*60 || num > 7*24*60*60) { - errors = append(errors, valueError) - return - } - - return -} - func resourceSpannerDBVirtualUpdate(d *schema.ResourceData, resourceSchema map[string]*schema.Schema) bool { // deletion_protection is the only virtual field if d.HasChange("deletion_protection") { diff --git a/tfplan2cai/converters/google/resources/services/workstations/workstations_workstation_config.go b/tfplan2cai/converters/google/resources/services/workstations/workstations_workstation_config.go index 962108818..1752ca583 100644 --- a/tfplan2cai/converters/google/resources/services/workstations/workstations_workstation_config.go +++ b/tfplan2cai/converters/google/resources/services/workstations/workstations_workstation_config.go @@ -284,6 +284,13 @@ func expandWorkstationsWorkstationConfigHostGceInstance(v interface{}, d tpgreso transformed["accelerators"] = transformedAccelerators } + transformedBoostConfigs, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigs(original["boost_configs"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedBoostConfigs); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["boostConfigs"] = transformedBoostConfigs + } + return transformed, nil } @@ -428,6 +435,87 @@ func expandWorkstationsWorkstationConfigHostGceInstanceAcceleratorsCount(v inter return v, nil } +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + req := make([]interface{}, 0, len(l)) + for _, raw := range l { + if raw == nil { + continue + } + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedId, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsId(original["id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedId); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["id"] = transformedId + } + + transformedMachineType, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsMachineType(original["machine_type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedMachineType); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["machineType"] = transformedMachineType + } + + transformedAccelerators, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAccelerators(original["accelerators"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAccelerators); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["accelerators"] = transformedAccelerators + } + + req = append(req, transformed) + } + return req, nil +} + +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsMachineType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAccelerators(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + req := make([]interface{}, 0, len(l)) + for _, raw := range l { + if raw == nil { + continue + } + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedType, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAcceleratorsType(original["type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["type"] = transformedType + } + + transformedCount, err := expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAcceleratorsCount(original["count"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["count"] = transformedCount + } + + req = append(req, transformed) + } + return req, nil +} + +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAcceleratorsType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandWorkstationsWorkstationConfigHostGceInstanceBoostConfigsAcceleratorsCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandWorkstationsWorkstationConfigPersistentDirectories(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) req := make([]interface{}, 0, len(l))