diff --git a/go.mod b/go.mod index 76da3440c..1fed21705 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.18.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240308220643-02cd818b0a15 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240309000314-98d493863f1d 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 a27becaba..346c2cfad 100644 --- a/go.sum +++ b/go.sum @@ -175,8 +175,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwU github.com/hashicorp/terraform-plugin-mux v0.13.0 h1:79U401/3nd8CWwDGtTHc8F3miSCAS9XGtVarxSTDgwA= github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 h1:Bl3e2ei2j/Z3Hc2HIS15Gal2KMKyLAZ2om1HCEvK6es= github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0/go.mod h1:i2C41tszDjiWfziPQDL5R/f3Zp0gahXe5No/MIO9rCE= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240308220643-02cd818b0a15 h1:4vvSyMbYgdsJJFKIQb38a9g4fozSsoNVXAPZzQvgNu0= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240308220643-02cd818b0a15/go.mod h1:xqktgz44XcXx24WFlm6lYZEri5YeyyFGL+qBamSShDc= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240309000314-98d493863f1d h1:Shy/AEGfW5/0NJhH9pfAK1ngiGAaX28ujOXUBlawgZ0= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20240309000314-98d493863f1d/go.mod h1:xqktgz44XcXx24WFlm6lYZEri5YeyyFGL+qBamSShDc= 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/apphub/apphub_service_project_attachment.go b/tfplan2cai/converters/google/resources/services/apphub/apphub_service_project_attachment.go new file mode 100644 index 000000000..63b43dd3d --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/apphub/apphub_service_project_attachment.go @@ -0,0 +1,79 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 apphub + +import ( + "reflect" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "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" +) + +// Suppress all diff for the field Service Project +func ServiceProjectDiffSuppress(_, _, _ string, _ *schema.ResourceData) bool { + return true +} + +const ApphubServiceProjectAttachmentAssetType string = "apphub.googleapis.com/ServiceProjectAttachment" + +func ResourceConverterApphubServiceProjectAttachment() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: ApphubServiceProjectAttachmentAssetType, + Convert: GetApphubServiceProjectAttachmentCaiObject, + } +} + +func GetApphubServiceProjectAttachmentCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//apphub.googleapis.com/projects/{{project}}/locations/global/serviceProjectAttachments/{{service_project_attachment_id}}") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetApphubServiceProjectAttachmentApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: ApphubServiceProjectAttachmentAssetType, + Resource: &cai.AssetResource{ + Version: "v1", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/apphub/v1/rest", + DiscoveryName: "ServiceProjectAttachment", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetApphubServiceProjectAttachmentApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + serviceProjectProp, err := expandApphubServiceProjectAttachmentServiceProject(d.Get("service_project"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("service_project"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceProjectProp)) && (ok || !reflect.DeepEqual(v, serviceProjectProp)) { + obj["serviceProject"] = serviceProjectProp + } + + return obj, nil +} + +func expandApphubServiceProjectAttachmentServiceProject(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + + service_project := "projects/" + d.Get("service_project_attachment_id").(string) + + return service_project, nil +}