From 4b5569f164ed09f78505cfc3f86786456afb9970 Mon Sep 17 00:00:00 2001 From: Jacob Kiefer Date: Wed, 1 Nov 2017 12:33:14 -0400 Subject: [PATCH] feat(artifacts): Resolve expectedArtifact by ids in trigger. --- build.gradle | 2 +- .../AppEngineServerGroupCreator.groovy | 18 +++++++++++------- .../orca/pipeline/util/ArtifactResolver.groovy | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index c2df8bf1d7..1698bc4945 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ allprojects { group = "com.netflix.spinnaker.orca" ext { - spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.117.0' + spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.120.0' } def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion] diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/appengine/AppEngineServerGroupCreator.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/appengine/AppEngineServerGroupCreator.groovy index 54d27a5715..0de5c86dac 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/appengine/AppEngineServerGroupCreator.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/appengine/AppEngineServerGroupCreator.groovy @@ -64,16 +64,20 @@ class AppEngineServerGroupCreator implements ServerGroupCreator { return } - Map expectedArtifact = operation.expectedArtifact + String expectedArtifactId = operation.expectedArtifactId + Execution execution = stage.getExecution() + + Map expectedArtifact = [:] + Map trigger = [:] + if (execution instanceof Pipeline) { + // TODO(jacobkiefer): Use stage context input/output lookup. + trigger = ((Pipeline) execution).getTrigger() + expectedArtifact = trigger.resolvedExpectedArtifacts.find { e -> e.id == expectedArtifactId } as Map + } + // NOTE: expectedArtifact is a Map, and fragile to field changes in the underlying data structures. // If a field changes in the ExpectedArtifact model, change it here. if (operation.fromArtifact && expectedArtifact && expectedArtifact.matchArtifact) { - Execution execution = stage.getExecution() - Map trigger = [:] - if (execution instanceof Pipeline) { - trigger = ((Pipeline) execution).getTrigger() - } - List artifacts = (List) trigger.artifacts def foundArtifact = artifacts.find { a -> ExpectedArtifact e = objectMapper.convertValue(expectedArtifact, ExpectedArtifact) diff --git a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.groovy b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.groovy index 931285237d..035ff2e165 100644 --- a/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.groovy +++ b/orca-core/src/main/groovy/com/netflix/spinnaker/orca/pipeline/util/ArtifactResolver.groovy @@ -28,7 +28,7 @@ class ArtifactResolver { static void resolveArtifacts(Map pipeline) { Set resolvedArtifacts = [] List receivedArtifacts = pipeline.receivedArtifacts ?: [] - List expectedArtifacts = pipeline.trigger.expectedArtifacts ?: [] + List expectedArtifacts = pipeline.expectedArtifacts.findAll { e -> e.id in pipeline.trigger.expectedArtifactIds } ?: [] List unresolvedExpectedArtifacts = [] for (ExpectedArtifact expectedArtifact : expectedArtifacts) { @@ -56,12 +56,12 @@ class ArtifactResolver { } pipeline.trigger.artifacts = resolvedArtifacts as List + pipeline.trigger.resolvedExpectedArtifacts = expectedArtifacts // Add the actual expectedArtifacts we included in the ids. } static class ArtifactResolutionException extends RuntimeException { ArtifactResolutionException(String message) { super(message) } - } }