-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new resource for Service Project for Apphub (#10048) (#2034)
FIXES hashicorp/terraform-provider-google#17405 [upstream:ab2122202ab62d620cbbbc8928078b0782146994] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
e988ba5
commit f6651dc
Showing
3 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
tfplan2cai/converters/google/resources/services/apphub/apphub_service_project_attachment.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |