From e764d77dc58b91b1a7d61b243abd1af6183f1c97 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:23:46 +0000 Subject: [PATCH] fix(gce): remove the duplicate cache attribute "subnet" and update the test (#5977) (#5986) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit ace11c4d5aa642ed8ff686b75c1e86a3a9d67165) Co-authored-by: Kiran Godishala <53332225+kirangodishala@users.noreply.github.com> --- .../provider/agent/GoogleSubnetCachingAgent.groovy | 2 +- .../agent/GoogleSubnetCachingAgentSpec.groovy | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgent.groovy b/clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgent.groovy index f07b586c00d..84863dde325 100644 --- a/clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgent.groovy +++ b/clouddriver-google/src/main/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgent.groovy @@ -86,7 +86,7 @@ class GoogleSubnetCachingAgent extends AbstractGoogleCachingAgent { def subnetKey = Keys.getSubnetKey(deriveSubnetId(subnet), region, accountName) cacheResultBuilder.namespace(SUBNETS.ns).keep(subnetKey).with { - attributes.subnet = [subnet: subnet,project: project] + attributes = [subnet: subnet,project: project] } } diff --git a/clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgentSpec.groovy b/clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgentSpec.groovy index 955bc12a93e..cf33493aff0 100644 --- a/clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgentSpec.groovy +++ b/clouddriver-google/src/test/groovy/com/netflix/spinnaker/clouddriver/google/provider/agent/GoogleSubnetCachingAgentSpec.groovy @@ -43,12 +43,13 @@ class GoogleSubnetCachingAgentSpec extends Specification { 1 * computeMock.subnetworks() >> subnetsMock 1 * subnetsMock.list(PROJECT_NAME,REGION) >> subnetworksListMock 1 * subnetworksListMock.execute() >> SubnetsListReal - with(cache.cacheResults.get(Keys.Namespace.SUBNETS.ns)) { Collection cd -> - cd.stream().forEach( { - Map attributes= it.getAttributes() - attributes.get(0) == "my-project" - }) - cd.id.containsAll([keyGroupA]) + def cd = cache.cacheResults.get(Keys.Namespace.SUBNETS.ns) + cd.id.containsAll([keyGroupA]) + with(cd.asList().get(0)){ + def attributes = it.attributes + attributes.project == "my-project" + attributes.subnet.name == "name-a" + attributes.subnet.selfLink == "https://compute.googleapis.com/compute/v1/projects/my-project/us-east1/subnetworks/name-a" } }