Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(gcb): Use generic maps for GCB objects #2853

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion orca-igor/orca-igor.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies {
compile project(":orca-front50")
compile spinnaker.dependency('kork')
compile spinnaker.dependency('bootAutoConfigure')
compile spinnaker.dependency('googleCloudBuild')
compileOnly spinnaker.dependency("lombok")
annotationProcessor spinnaker.dependency("lombok")
testCompile project(":orca-test-groovy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.netflix.spinnaker.orca.igor;

import com.google.api.services.cloudbuild.v1.model.Build;
import com.google.api.services.cloudbuild.v1.model.Operation;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import retrofit.http.*;

Expand Down Expand Up @@ -72,7 +70,7 @@ List<Artifact> getArtifacts(
@Path(value = "job", encode = false) String job);

@POST("/gcb/builds/create/{account}")
Operation createGoogleCloudBuild(
Map<String, Object> createGoogleCloudBuild(
@Path("account") String account,
@Body Build job);
@Body Map<String, Object> job);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@
package com.netflix.spinnaker.orca.igor.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.api.services.cloudbuild.v1.model.Build;
import lombok.Getter;

import java.util.Map;

@Getter
public class GoogleCloudBuildStageDefinition {
private final String account;
private final Build buildDefinition;
private final Map<String, Object> buildDefinition;

// There does not seem to be a way to auto-generate a constructor using our current version of Lombok (1.16.20) that
// Jackson can use to deserialize.
public GoogleCloudBuildStageDefinition(
@JsonProperty("account") String account,
@JsonProperty("buildDefinition") Build buildDefinition
@JsonProperty("buildDefinition") Map<String, Object> buildDefinition
) {
this.account = account;
this.buildDefinition = buildDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.netflix.spinnaker.orca.igor.tasks;

import com.google.api.services.cloudbuild.v1.model.Operation;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.Task;
import com.netflix.spinnaker.orca.TaskResult;
Expand All @@ -27,6 +26,7 @@
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.Map;

@Component
@RequiredArgsConstructor
Expand All @@ -36,7 +36,7 @@ public class StartGoogleCloudBuildTask implements Task {
@Override
@Nonnull public TaskResult execute(@Nonnull Stage stage) {
GoogleCloudBuildStageDefinition stageDefinition = stage.mapTo(GoogleCloudBuildStageDefinition.class);
Operation result = igorService.createGoogleCloudBuild(stageDefinition.getAccount(), stageDefinition.getBuildDefinition());
Map<String, Object> result = igorService.createGoogleCloudBuild(stageDefinition.getAccount(), stageDefinition.getBuildDefinition());
return new TaskResult(ExecutionStatus.SUCCEEDED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package com.netflix.spinnaker.orca.igor.pipeline

import com.google.api.services.cloudbuild.v1.model.Build

import com.netflix.spinnaker.orca.igor.tasks.StartGoogleCloudBuildTask
import spock.lang.Specification

import static com.netflix.spinnaker.orca.test.model.ExecutionBuilder.stage

class GoogleCloudBuildStageSpec extends Specification {
def ACCOUNT = "my-account"
def BUILD = new Build()
def BUILD = new HashMap<String, Object>()

def "should start a build"() {
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.netflix.spinnaker.orca.igor.tasks

import com.google.api.services.cloudbuild.v1.model.Build

import com.netflix.spinnaker.orca.TaskResult
import com.netflix.spinnaker.orca.igor.IgorService
import com.netflix.spinnaker.orca.pipeline.model.Execution
Expand All @@ -26,7 +26,7 @@ import spock.lang.Subject

class StartGoogleCloudBuildTaskSpec extends Specification {
def ACCOUNT = "my-account"
def BUILD = new Build()
def BUILD = new HashMap<String, Object>()

Execution execution = Mock(Execution)
IgorService igorService = Mock(IgorService)
Expand Down