Skip to content

Commit

Permalink
chore(*): Apply codestyles to orca (#2915)
Browse files Browse the repository at this point in the history
* chore(*): Fix a few things that break the code formatter

* Remove wildcard imports from kotlin files
* Fix a single line that was intended by an odd number of spaces

* chore(*): Apply codestyles to orca

Run ./gradlew spotlessApply on the entire project

* chore(*): Turn on codestyle enforcement
  • Loading branch information
ezimanyi committed May 14, 2019
1 parent 3eb6da3 commit cd6b6ca
Show file tree
Hide file tree
Showing 579 changed files with 12,017 additions and 9,721 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ allprojects {
subprojects {
apply plugin: "java-library"

spinnakerCodeStyle {
enabled = false
}

if ([korkVersion, keikoVersion, fiatVersion].any { it.endsWith("-SNAPSHOT") }) {
logger.info("Enabling mavenLocal")
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import lombok.Data;

import java.util.List;
import java.util.Map;
import lombok.Data;

@Data
public class BakeManifestRequest {
@JsonProperty("templateRenderer")
String templateRenderer;

@JsonProperty("inputArtifacts")
List<Artifact> inputArtifacts;

List<Artifact> values;

@JsonProperty("outputName")
String outputName;

@JsonProperty("overrides")
Map<String, Object> overrides;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class HelmBakeManifestRequest extends BakeManifestRequest {
@JsonProperty("namespace")
String namespace;

@JsonProperty("outputArtifactName")
String outputArtifactName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
public class BakeManifestStage implements StageDefinitionBuilder {
@Override
public void taskGraph(Stage stage, TaskNode.Builder builder) {
builder.withTask("createBake", CreateBakeManifestTask.class)
builder
.withTask("createBake", CreateBakeManifestTask.class)
.withTask("bindProducedArtifacts", BindProducedArtifactsTask.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.kork.artifacts.model.ExpectedArtifact;
import lombok.Getter;

import java.util.List;
import java.util.Map;
import lombok.Getter;

@Getter
public class BakeManifestContext {
Expand All @@ -33,17 +32,17 @@ public class BakeManifestContext {
private final String outputName;
private final String namespace;

// There does not seem to be a way to auto-generate a constructor using our current version of Lombok (1.16.20) that
// 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 BakeManifestContext(
@JsonProperty("inputArtifacts") List<CreateBakeManifestTask.InputArtifactPair> inputArtifacts,
@JsonProperty("expectedArtifacts") List<ExpectedArtifact> expectedArtifacts,
@JsonProperty("overrides") Map<String, Object> overrides,
@JsonProperty("evaluateOverrideExpressions") Boolean evaluateOverrideExpressions,
@JsonProperty("templateRenderer") String templateRenderer,
@JsonProperty("outputName") String outputName,
@JsonProperty("namespace") String namespace
) {
@JsonProperty("inputArtifacts") List<CreateBakeManifestTask.InputArtifactPair> inputArtifacts,
@JsonProperty("expectedArtifacts") List<ExpectedArtifact> expectedArtifacts,
@JsonProperty("overrides") Map<String, Object> overrides,
@JsonProperty("evaluateOverrideExpressions") Boolean evaluateOverrideExpressions,
@JsonProperty("templateRenderer") String templateRenderer,
@JsonProperty("outputName") String outputName,
@JsonProperty("namespace") String namespace) {
this.inputArtifacts = inputArtifacts;
this.expectedArtifacts = expectedArtifacts;
this.overrides = overrides;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import com.netflix.spinnaker.orca.pipeline.util.ArtifactResolver;
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
Expand All @@ -56,14 +55,11 @@ public long getTimeout() {
@Autowired(required = false)
BakeryService bakery;

@Autowired
ArtifactResolver artifactResolver;
@Autowired ArtifactResolver artifactResolver;

@Autowired
ObjectMapper objectMapper;
@Autowired ObjectMapper objectMapper;

@Autowired
ContextParameterProcessor contextParameterProcessor;
@Autowired ContextParameterProcessor contextParameterProcessor;

@Nonnull
@Override
Expand All @@ -77,20 +73,28 @@ public TaskResult execute(@Nonnull Stage stage) {
throw new IllegalArgumentException("At least one input artifact to bake must be supplied");
}

inputArtifacts = inputArtifactsObj.stream()
.map(p -> {
Artifact a = artifactResolver.getBoundArtifactForId(stage, p.getId());
if (a == null) {
throw new IllegalArgumentException(stage.getExecution().getId() + ": Input artifact " + p.getId() + " could not be found in the execution");
}
a.setArtifactAccount(p.getAccount());
return a;
}).collect(Collectors.toList());
inputArtifacts =
inputArtifactsObj.stream()
.map(
p -> {
Artifact a = artifactResolver.getBoundArtifactForId(stage, p.getId());
if (a == null) {
throw new IllegalArgumentException(
stage.getExecution().getId()
+ ": Input artifact "
+ p.getId()
+ " could not be found in the execution");
}
a.setArtifactAccount(p.getAccount());
return a;
})
.collect(Collectors.toList());

List<ExpectedArtifact> expectedArtifacts = context.getExpectedArtifacts();

if (expectedArtifacts == null || expectedArtifacts.isEmpty()) {
throw new IllegalArgumentException("At least one expected artifact to baked manifest must be supplied");
throw new IllegalArgumentException(
"At least one expected artifact to baked manifest must be supplied");
}

if (expectedArtifacts.size() > 1) {
Expand All @@ -102,11 +106,9 @@ public TaskResult execute(@Nonnull Stage stage) {
Map<String, Object> overrides = context.getOverrides();
Boolean evaluateOverrideExpressions = context.getEvaluateOverrideExpressions();
if (evaluateOverrideExpressions != null && evaluateOverrideExpressions) {
overrides = contextParameterProcessor.process(
overrides,
contextParameterProcessor.buildExecutionContext(stage, true),
true
);
overrides =
contextParameterProcessor.process(
overrides, contextParameterProcessor.buildExecutionContext(stage, true), true);
}

HelmBakeManifestRequest request = new HelmBakeManifestRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package com.netflix.spinnaker.orca.clouddriver;

import com.netflix.spinnaker.orca.clouddriver.config.SelectableService;

import java.util.Collection;
import java.util.Map;

public class DelegatingCloudDriverCacheStatusService
extends DelegatingClouddriverService<CloudDriverCacheStatusService>
implements CloudDriverCacheStatusService {
extends DelegatingClouddriverService<CloudDriverCacheStatusService>
implements CloudDriverCacheStatusService {

public DelegatingCloudDriverCacheStatusService(SelectableService selectableService) {
super(selectableService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
import com.netflix.spinnaker.orca.clouddriver.config.SelectableService;
import com.netflix.spinnaker.orca.clouddriver.model.Task;

import java.util.List;

public class DelegatingCloudDriverTaskStatusService
extends DelegatingClouddriverService<CloudDriverTaskStatusService>
implements CloudDriverTaskStatusService {
extends DelegatingClouddriverService<CloudDriverTaskStatusService>
implements CloudDriverTaskStatusService {

public DelegatingCloudDriverTaskStatusService(SelectableService selectableService) {
super(selectableService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ class DelegatingClouddriverService<T> {
}

T getService() {
SelectableService.Criteria criteria = new SelectableService.Criteria(null, null, null, null, null);
SelectableService.Criteria criteria =
new SelectableService.Criteria(null, null, null, null, null);

ExecutionContext executionContext = ExecutionContext.get();
if (executionContext != null) {
criteria = new SelectableService.Criteria(
executionContext.getApplication(),
executionContext.getAuthenticatedUser(),
executionContext.getExecutionType(),
executionContext.getExecutionId(),
executionContext.getOrigin()
);
criteria =
new SelectableService.Criteria(
executionContext.getApplication(),
executionContext.getAuthenticatedUser(),
executionContext.getExecutionType(),
executionContext.getExecutionId(),
executionContext.getOrigin());
}

return (T) selectableService.getService(criteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
package com.netflix.spinnaker.orca.clouddriver;

import com.netflix.spinnaker.orca.clouddriver.config.SelectableService;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class DelegatingMortService
extends DelegatingClouddriverService<MortService>
implements MortService {
public class DelegatingMortService extends DelegatingClouddriverService<MortService>
implements MortService {

public DelegatingMortService(SelectableService selectableService) {
super(selectableService);
}

@Override
public SecurityGroup getSecurityGroup(String account, String type, String securityGroupName, String region) {
public SecurityGroup getSecurityGroup(
String account, String type, String securityGroupName, String region) {
return getService().getSecurityGroup(account, type, securityGroupName, region);
}

@Override
public SecurityGroup getSecurityGroup(String account, String type, String securityGroupName, String region, String vpcId) {
public SecurityGroup getSecurityGroup(
String account, String type, String securityGroupName, String region, String vpcId) {
return getService().getSecurityGroup(account, type, securityGroupName, region, vpcId);
}

Expand Down
Loading

0 comments on commit cd6b6ca

Please sign in to comment.