Skip to content

Commit

Permalink
feat(gce): Support new artifact model for deploy SG (#3018)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy Louie committed Jul 3, 2019
1 parent e967bf3 commit 9e6f470
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.clouddriver.tasks.providers.gce

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.kork.artifacts.model.Artifact
import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.ServerGroupCreator
import com.netflix.spinnaker.orca.kato.tasks.DeploymentDetailsAware
Expand All @@ -35,6 +36,9 @@ class GoogleServerGroupCreator implements ServerGroupCreator, DeploymentDetailsA
@Autowired
ArtifactResolver artifactResolver

@Autowired
ObjectMapper objectMapper

@Override
List<Map> getOperations(Stage stage) {
def operation = [:]
Expand Down Expand Up @@ -68,10 +72,11 @@ class GoogleServerGroupCreator implements ServerGroupCreator, DeploymentDetailsA
def stageContext = stage.getContext()

def artifactId = stageContext.imageArtifactId as String
if (artifactId == null) {
Artifact imageArtifact = stageContext.imageArtifact ? objectMapper.convertValue(stageContext.imageArtifact, Artifact.class) : null
if (artifactId == null && imageArtifact == null) {
throw new IllegalArgumentException("Image source was set to artifact but no artifact was specified.")
}
return artifactResolver.getBoundArtifactForId(stage, artifactId)
return artifactResolver.getBoundArtifactForStage(stage, artifactId, imageArtifact)
}

private String getImage(Stage stage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class GoogleServerGroupCreatorSpec extends Specification {
context.putAll(ctx)
}
Artifact buildArtifact = Artifact.ArtifactBuilder.newInstance().name("santaImage").build();
artifactResolver.getBoundArtifactForId(*_) >> buildArtifact
artifactResolver.getBoundArtifactForStage(*_) >> buildArtifact
ops = new GoogleServerGroupCreator(artifactResolver: artifactResolver).getOperations(stage)

then:
Expand Down

0 comments on commit 9e6f470

Please sign in to comment.