parent
dcc0130237
commit
c59c36a86c
|
@ -522,18 +522,17 @@ func TestGoogleComputeInstanceGroup(t *testing.T) {
|
|||
response: []*assetpb.ResourceSearchResult{
|
||||
{
|
||||
AssetType: "compute.googleapis.com/InstanceGroup",
|
||||
DisplayName: "driftctl-unittest-1",
|
||||
Name: "//compute.googleapis.com/projects/driftctl-qa-1/zones/us-central1-a/instanceGroups/driftctl-unittest-1",
|
||||
DisplayName: "driftctl-test-1",
|
||||
Name: "//compute.googleapis.com/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1",
|
||||
Project: "cloudskiff-dev-raphael",
|
||||
Location: "us-central1-a",
|
||||
},
|
||||
{
|
||||
AssetType: "compute.googleapis.com/InstanceGroup",
|
||||
DisplayName: "driftctl-unittest-2",
|
||||
Name: "//compute.googleapis.com/projects/driftctl-qa-1/zones/us-central1-a/instanceGroups/driftctl-unittest-2",
|
||||
},
|
||||
{
|
||||
AssetType: "compute.googleapis.com/InstanceGroup",
|
||||
DisplayName: "driftctl-unittest-3",
|
||||
Name: "//compute.googleapis.com/projects/driftctl-qa-1/zones/us-central1-a/instanceGroups/driftctl-unittest-3",
|
||||
DisplayName: "driftctl-test-2",
|
||||
Name: "//compute.googleapis.com/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2",
|
||||
Project: "cloudskiff-dev-raphael",
|
||||
Location: "us-central1-a",
|
||||
},
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -612,10 +611,11 @@ func TestGoogleComputeInstanceGroup(t *testing.T) {
|
|||
|
||||
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||
got, err := s.Resources()
|
||||
assert.Equal(tt, err, c.wantErr)
|
||||
assert.Equal(tt, c.wantErr, err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
alerter.AssertExpectations(tt)
|
||||
testFilter.AssertExpectations(tt)
|
||||
test.TestAgainstGoldenFile(got, resType.String(), c.dirName, provider, de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XR3b3Jrcy90ZXN0LW5ldHdvcmsiLCJwcm9qZWN0IjoiY2xvdWRza2lmZi1kZXYtcmFwaGFlbCIsInNlbGZfbGluayI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2NvbXB1dGUvdjEvcHJvamVjdHMvY2xvdWRza2lmZi1kZXYtcmFwaGFlbC96b25lcy91cy1jZW50cmFsMS1hL2luc3RhbmNlR3JvdXBzL2RyaWZ0Y3RsLXRlc3QtMiIsInNpemUiOjAsInRpbWVvdXRzIjp7ImNyZWF0ZSI6bnVsbCwiZGVsZXRlIjpudWxsLCJ1cGRhdGUiOm51bGx9LCJ6b25lIjoidXMtY2VudHJhbDEtYSJ9",
|
||||
"Err": null
|
||||
}
|
|
@ -1 +1,28 @@
|
|||
[]
|
||||
[
|
||||
{
|
||||
"description": "Terraform test instance group",
|
||||
"id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2",
|
||||
"instances": null,
|
||||
"name": "driftctl-test-2",
|
||||
"named_port": null,
|
||||
"network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network",
|
||||
"project": "cloudskiff-dev-raphael",
|
||||
"self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2",
|
||||
"size": 0,
|
||||
"timeouts": null,
|
||||
"zone": "us-central1-a"
|
||||
},
|
||||
{
|
||||
"description": "Terraform test instance group",
|
||||
"id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1",
|
||||
"instances": null,
|
||||
"name": "driftctl-test-1",
|
||||
"named_port": null,
|
||||
"network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network",
|
||||
"project": "cloudskiff-dev-raphael",
|
||||
"self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1",
|
||||
"size": 0,
|
||||
"timeouts": null,
|
||||
"zone": "us-central1-a"
|
||||
}
|
||||
]
|
|
@ -1,12 +1,19 @@
|
|||
provider "google" {}
|
||||
|
||||
resource "google_compute_network" "default" {
|
||||
name = "test-network"
|
||||
name = "test-network"
|
||||
}
|
||||
|
||||
resource "google_compute_instance_group" "test" {
|
||||
name = "terraform-test"
|
||||
description = "Terraform test instance group"
|
||||
zone = "us-central1-a"
|
||||
network = google_compute_network.default.id
|
||||
resource "google_compute_instance_group" "test-1" {
|
||||
name = "driftctl-test-1"
|
||||
description = "Terraform test instance group"
|
||||
zone = "us-central1-a"
|
||||
network = google_compute_network.default.id
|
||||
}
|
||||
|
||||
resource "google_compute_instance_group" "test-2" {
|
||||
name = "driftctl-test-2"
|
||||
description = "Terraform test instance group"
|
||||
zone = "us-central1-a"
|
||||
network = google_compute_network.default.id
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import "github.com/cloudskiff/driftctl/pkg/resource"
|
|||
const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group"
|
||||
|
||||
func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetNormalizeFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) {
|
||||
res.Attributes().SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"name": *res.Attributes().GetString("display_name"),
|
||||
|
|
Loading…
Reference in New Issue