parent
dcc0130237
commit
c59c36a86c
|
@ -522,18 +522,17 @@ func TestGoogleComputeInstanceGroup(t *testing.T) {
|
||||||
response: []*assetpb.ResourceSearchResult{
|
response: []*assetpb.ResourceSearchResult{
|
||||||
{
|
{
|
||||||
AssetType: "compute.googleapis.com/InstanceGroup",
|
AssetType: "compute.googleapis.com/InstanceGroup",
|
||||||
DisplayName: "driftctl-unittest-1",
|
DisplayName: "driftctl-test-1",
|
||||||
Name: "//compute.googleapis.com/projects/driftctl-qa-1/zones/us-central1-a/instanceGroups/driftctl-unittest-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",
|
AssetType: "compute.googleapis.com/InstanceGroup",
|
||||||
DisplayName: "driftctl-unittest-2",
|
DisplayName: "driftctl-test-2",
|
||||||
Name: "//compute.googleapis.com/projects/driftctl-qa-1/zones/us-central1-a/instanceGroups/driftctl-unittest-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",
|
||||||
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",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: nil,
|
wantErr: nil,
|
||||||
|
@ -612,10 +611,11 @@ func TestGoogleComputeInstanceGroup(t *testing.T) {
|
||||||
|
|
||||||
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||||
got, err := s.Resources()
|
got, err := s.Resources()
|
||||||
assert.Equal(tt, err, c.wantErr)
|
assert.Equal(tt, c.wantErr, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
alerter.AssertExpectations(tt)
|
alerter.AssertExpectations(tt)
|
||||||
testFilter.AssertExpectations(tt)
|
testFilter.AssertExpectations(tt)
|
||||||
test.TestAgainstGoldenFile(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt)
|
test.TestAgainstGoldenFile(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"Typ": "WyJvYmplY3QiLHsiZGVzY3JpcHRpb24iOiJzdHJpbmciLCJpZCI6InN0cmluZyIsImluc3RhbmNlcyI6WyJzZXQiLCJzdHJpbmciXSwibmFtZSI6InN0cmluZyIsIm5hbWVkX3BvcnQiOlsibGlzdCIsWyJvYmplY3QiLHsibmFtZSI6InN0cmluZyIsInBvcnQiOiJudW1iZXIifV1dLCJuZXR3b3JrIjoic3RyaW5nIiwicHJvamVjdCI6InN0cmluZyIsInNlbGZfbGluayI6InN0cmluZyIsInNpemUiOiJudW1iZXIiLCJ0aW1lb3V0cyI6WyJvYmplY3QiLHsiY3JlYXRlIjoic3RyaW5nIiwiZGVsZXRlIjoic3RyaW5nIiwidXBkYXRlIjoic3RyaW5nIn1dLCJ6b25lIjoic3RyaW5nIn1d",
|
||||||
|
"Val": "eyJkZXNjcmlwdGlvbiI6IlRlcnJhZm9ybSB0ZXN0IGluc3RhbmNlIGdyb3VwIiwiaWQiOiJwcm9qZWN0cy9jbG91ZHNraWZmLWRldi1yYXBoYWVsL3pvbmVzL3VzLWNlbnRyYWwxLWEvaW5zdGFuY2VHcm91cHMvZHJpZnRjdGwtdGVzdC0xIiwiaW5zdGFuY2VzIjpbXSwibmFtZSI6ImRyaWZ0Y3RsLXRlc3QtMSIsIm5hbWVkX3BvcnQiOltdLC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wiaWQiOiJwcm9qZWN0cy9jbG91ZHNraWZmLWRldi1yYXBoYWVsL3pvbmVzL3VzLWNlbnRyYWwxLWEvaW5zdGFuY2VHcm91cHMvZHJpZnRjdGwtdGVzdC0yIiwiaW5zdGFuY2VzIjpbXSwibmFtZSI6ImRyaWZ0Y3RsLXRlc3QtMiIsIm5hbWVkX3BvcnQiOltdLCJuZXR3b3JrIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vY29tcHV0ZS92MS9wcm9qZWN0cy9jbG91ZHNraWZmLWRldi1yYXBoYWVsL2dsb2JhbC9uZXR3b3Jrcy90ZXN0LW5ldHdvcmsiLCJwcm9qZWN0IjoiY2xvdWRza2lmZi1kZXYtcmFwaGFlbCIsInNlbGZfbGluayI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2NvbXB1dGUvdjEvcHJvamVjdHMvY2xvdWRza2lmZi1kZXYtcmFwaGFlbC96b25lcy91cy1jZW50cmFsMS1hL2luc3RhbmNlR3JvdXBzL2RyaWZ0Y3RsLXRlc3QtMiIsInNpemUiOjAsInRpbWVvdXRzIjp7ImNyZWF0ZSI6bnVsbCwiZGVsZXRlIjpudWxsLCJ1cGRhdGUiOm51bGx9LCJ6b25lIjoidXMtY2VudHJhbDEtYSJ9",
|
||||||
|
"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" {}
|
provider "google" {}
|
||||||
|
|
||||||
resource "google_compute_network" "default" {
|
resource "google_compute_network" "default" {
|
||||||
name = "test-network"
|
name = "test-network"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_instance_group" "test" {
|
resource "google_compute_instance_group" "test-1" {
|
||||||
name = "terraform-test"
|
name = "driftctl-test-1"
|
||||||
description = "Terraform test instance group"
|
description = "Terraform test instance group"
|
||||||
zone = "us-central1-a"
|
zone = "us-central1-a"
|
||||||
network = google_compute_network.default.id
|
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"
|
const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group"
|
||||||
|
|
||||||
func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
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 {
|
resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"name": *res.Attributes().GetString("display_name"),
|
"name": *res.Attributes().GetString("display_name"),
|
||||||
|
|
Loading…
Reference in New Issue