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

chore(spotless): upgrade spinnaker gradle plugin #3838

Merged
merged 1 commit into from
Jul 28, 2020
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ keikoVersion=3.8.0
korkVersion=7.56.0
kotlinVersion=1.3.72
org.gradle.parallel=true
spinnakerGradleVersion=8.3.0
spinnakerGradleVersion=8.4.0

# To enable a composite reference to a project, set the
# project property `'<projectName>Composite=true'`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public TaskResult execute(@Nonnull StageExecution stage) {
suppliers.stream()
.flatMap(
supplier ->
supplier.getConditions(ctx.getCluster(), ctx.getRegion(), ctx.getAccount())
supplier
.getConditions(ctx.getCluster(), ctx.getRegion(), ctx.getAccount())
.stream())
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public Collection<ImageDetails> byTags(
Map<String, String> tags,
List<String> warningsCollector) {
List<AliCloudImage> allMatchedImages =
oortService.findImage(getCloudProvider(), packageName, null, null, prefixTags(tags))
oortService
.findImage(getCloudProvider(), packageName, null, null, prefixTags(tags))
.stream()
.map(image -> objectMapper.convertValue(image, AliCloudImage.class))
.sorted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ private String getChangeSetInfo(Map stack, Map context, String field) {
String changeSetName = (String) context.get("changeSetName");
log.debug("Getting change set status from stack for changeset {}: {}", changeSetName, stack);
return Optional.ofNullable((List<Map<String, ?>>) stack.get("changeSets"))
.orElse(Collections.emptyList()).stream()
.orElse(Collections.emptyList())
.stream()
.filter(changeSet -> changeSet.get("name").equals(changeSetName))
.findFirst()
.map(changeSet -> (String) changeSet.get(field))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public Collection<ImageDetails> byTags(
Map<String, String> tags,
List<String> warningsCollector) {
List<GoogleImage> allMatchedImages =
oortService.findImage(getCloudProvider(), packageName, null, null, prefixTags(tags))
oortService
.findImage(getCloudProvider(), packageName, null, null, prefixTags(tags))
.stream()
.map(image -> objectMapper.convertValue(image, GoogleImage.class))
.sorted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public Collection<ImageDetails> byTags(
StageData stageData = (StageData) stage.mapTo(StageData.class);

List<OracleImage> allMatchedImages =
oortService.findImage(getCloudProvider(), packageName, null, null, prefixTags(freeformTags))
oortService
.findImage(getCloudProvider(), packageName, null, null, prefixTags(freeformTags))
.stream()
.map(imageAsMap -> objectMapper.convertValue(imageAsMap, OracleImage.class))
.sorted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ class DynamicStageResolver(
*/
private fun validatePreferences(duplicates: Map<String, MutableList<StageDefinitionBuilder>>) {
duplicates.forEach { duplicate ->
val pref = getPreference(duplicate.key)
val pref = getPreference(duplicate.key)

if (pref == NO_PREFERENCE) {
throw NoPreferenceConfigPresentException(duplicate.key)
}
if (pref == NO_PREFERENCE) {
throw NoPreferenceConfigPresentException(duplicate.key)
}

// Ensure the preference is actually valid: Is there a StageDefinitionBuilder with a matching canonical name?
duplicate.value.map { it.extensionClass.canonicalName }.let {
if (!it.contains(pref)) {
throw InvalidStageDefinitionBuilderPreference(duplicate.key, pref, it)
}
// Ensure the preference is actually valid: Is there a StageDefinitionBuilder with a matching canonical name?
duplicate.value.map { it.extensionClass.canonicalName }.let {
if (!it.contains(pref)) {
throw InvalidStageDefinitionBuilderPreference(duplicate.key, pref, it)
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class DelegatingApplicationEventMulticaster(
return true
}
if (listener is InspectableApplicationListenerMethodAdapter &&
listener.getMethod().getAnnotation(Sync::class.java) != null) {
listener.getMethod().getAnnotation(Sync::class.java) != null
) {
return true
}
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public static List<Map<String, Object>> deployedServerGroups(
task -> Optional.ofNullable(task.results).orElse(emptyList()).stream())
.flatMap(
result ->
Optional.ofNullable(result.deployments).orElse(emptyList())
Optional.ofNullable(result.deployments)
.orElse(emptyList())
.stream())
.collect(Collectors.toList());
deployDetails.put("deployments", deployments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ abstract class BuildInfo<A>(
open val scm: List<SourceControl>? = emptyList(),
open val building: Boolean = false
) {
var fullDisplayName: String? = null
get() = field ?: "$name#$number"
var fullDisplayName: String? = null
get() = field ?: "$name#$number"
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ constructor(
@param:JsonProperty("building") override var building: Boolean = false,
@param:JsonProperty("timestamp") val timestamp: Long?
) :
BuildInfo<JenkinsArtifact>(name, number, url, result, artifacts, scm, building) {

@JvmOverloads
constructor(
name: String,
number: Int,
url: String,
result: String,
artifacts: List<JenkinsArtifact> = emptyList(),
scm: List<SourceControl> = emptyList()
) : this(name, number, url, result, artifacts, scm, false, null)
BuildInfo<JenkinsArtifact>(name, number, url, result, artifacts, scm, building) {

@JvmOverloads
constructor(
name: String,
number: Int,
url: String,
result: String,
artifacts: List<JenkinsArtifact> = emptyList(),
scm: List<SourceControl> = emptyList()
) : this(name, number, url, result, artifacts, scm, false, null)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,40 @@ class TriggerDeserializer :
get("repository").textValue(),
get("tag").textValue()
)
looksLikeConcourse() -> ConcourseTrigger(
get("type").textValue(),
get("correlationId")?.textValue(),
get("user")?.textValue() ?: "[anonymous]",
get("parameters")?.mapValue(parser) ?: mutableMapOf(),
get("artifacts")?.listValue(parser) ?: mutableListOf(),
get("notifications")?.listValue(parser) ?: mutableListOf(),
get("rebake")?.booleanValue() == true,
get("dryRun")?.booleanValue() == true,
get("strategy")?.booleanValue() == true
).apply {
buildInfo = get("buildInfo")?.parseValue(parser)
properties = get("properties")?.parseValue(parser) ?: mutableMapOf()
}
looksLikeJenkins() -> JenkinsTrigger(
get("type").textValue(),
get("correlationId")?.textValue(),
get("user")?.textValue() ?: "[anonymous]",
get("parameters")?.mapValue(parser) ?: mutableMapOf(),
get("artifacts")?.listValue(parser) ?: mutableListOf(),
get("notifications")?.listValue(parser) ?: mutableListOf(),
get("rebake")?.booleanValue() == true,
get("dryRun")?.booleanValue() == true,
get("strategy")?.booleanValue() == true,
get("master").textValue(),
get("job").textValue(),
get("buildNumber").intValue(),
get("propertyFile")?.textValue()
).apply {
buildInfo = get("buildInfo")?.parseValue(parser)
properties = get("properties")?.mapValue(parser) ?: mutableMapOf()
}
looksLikeConcourse() ->
ConcourseTrigger(
get("type").textValue(),
get("correlationId")?.textValue(),
get("user")?.textValue() ?: "[anonymous]",
get("parameters")?.mapValue(parser) ?: mutableMapOf(),
get("artifacts")?.listValue(parser) ?: mutableListOf(),
get("notifications")?.listValue(parser) ?: mutableListOf(),
get("rebake")?.booleanValue() == true,
get("dryRun")?.booleanValue() == true,
get("strategy")?.booleanValue() == true
).apply {
buildInfo = get("buildInfo")?.parseValue(parser)
properties = get("properties")?.parseValue(parser) ?: mutableMapOf()
}
looksLikeJenkins() ->
JenkinsTrigger(
get("type").textValue(),
get("correlationId")?.textValue(),
get("user")?.textValue() ?: "[anonymous]",
get("parameters")?.mapValue(parser) ?: mutableMapOf(),
get("artifacts")?.listValue(parser) ?: mutableListOf(),
get("notifications")?.listValue(parser) ?: mutableListOf(),
get("rebake")?.booleanValue() == true,
get("dryRun")?.booleanValue() == true,
get("strategy")?.booleanValue() == true,
get("master").textValue(),
get("job").textValue(),
get("buildNumber").intValue(),
get("propertyFile")?.textValue()
).apply {
buildInfo = get("buildInfo")?.parseValue(parser)
properties = get("properties")?.mapValue(parser) ?: mutableMapOf()
}
looksLikePipeline() -> PipelineTrigger(
get("type").textValue(),
get("correlationId")?.textValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ class DualExecutionRepository(
buildTimeEndBoundary,
executionCriteria
)
.plus(previous.retrievePipelinesForPipelineConfigIdsBetweenBuildTimeBoundary(
pipelineConfigIds,
buildTimeStartBoundary,
buildTimeEndBoundary,
executionCriteria)
.plus(
previous.retrievePipelinesForPipelineConfigIdsBetweenBuildTimeBoundary(
pipelineConfigIds,
buildTimeStartBoundary,
buildTimeEndBoundary,
executionCriteria
)
).distinctBy { it.id }
}

Expand All @@ -235,11 +237,13 @@ class DualExecutionRepository(
buildTimeStartBoundary,
buildTimeEndBoundary,
executionCriteria
).plus(previous.retrieveAllPipelinesForPipelineConfigIdsBetweenBuildTimeBoundary(
pipelineConfigIds,
buildTimeStartBoundary,
buildTimeEndBoundary,
executionCriteria)
).plus(
previous.retrieveAllPipelinesForPipelineConfigIdsBetweenBuildTimeBoundary(
pipelineConfigIds,
buildTimeStartBoundary,
buildTimeEndBoundary,
executionCriteria
)
).distinctBy { it.id }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class InMemoryExecutionRepository : ExecutionRepository {

override fun retrieveAllApplicationNames(executionType: ExecutionType?): MutableList<String> {
return if (executionType == null) {
pipelines.values + orchestrations.values
} else {
storageFor(executionType).values
}
pipelines.values + orchestrations.values
} else {
storageFor(executionType).values
}
.map { it.application }
.toMutableList()
}

override fun retrieveAllApplicationNames(executionType: ExecutionType?, minExecutions: Int): MutableList<String> {
return if (executionType == null) {
pipelines.values + orchestrations.values
} else {
storageFor(executionType).values
}
pipelines.values + orchestrations.values
} else {
storageFor(executionType).values
}
.groupBy { it.application }
.filter { it.value.size >= minExecutions }
.keys
Expand Down Expand Up @@ -88,8 +88,10 @@ class InMemoryExecutionRepository : ExecutionRepository {
override fun resume(type: ExecutionType, id: String, user: String?, ignoreCurrentStatus: Boolean) {
retrieve(type, id).also {
if (!ignoreCurrentStatus && it.status != ExecutionStatus.PAUSED) {
throw UnresumablePipelineException("Unable to resume pipeline that is not PAUSED " +
"(executionId: ${it.id}, currentStatus: ${it.status}")
throw UnresumablePipelineException(
"Unable to resume pipeline that is not PAUSED " +
"(executionId: ${it.id}, currentStatus: ${it.status}"
)
}
it.status = ExecutionStatus.RUNNING
it.paused?.resumedBy = user
Expand Down Expand Up @@ -135,8 +137,10 @@ class InMemoryExecutionRepository : ExecutionRepository {
override fun pause(type: ExecutionType, id: String, user: String?) {
retrieve(type, id).also {
if (it.status != ExecutionStatus.RUNNING) {
throw UnpausablePipelineException("Unable to pause pipeline that is not RUNNING " +
"(executionId: ${it.id}, currentStatus: ${it.status})")
throw UnpausablePipelineException(
"Unable to pause pipeline that is not RUNNING " +
"(executionId: ${it.id}, currentStatus: ${it.status})"
)
}
it.status = ExecutionStatus.PAUSED
it.paused = PipelineExecution.PausedDetails().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@ private List<Artifact> getPriorArtifacts(Map<String, Object> pipeline) {

private Optional<PipelineExecution> getExecutionForPipelineId(
String pipelineId, ExecutionCriteria criteria) {
return executionRepository.retrievePipelinesForPipelineConfigId(pipelineId, criteria)
.subscribeOn(Schedulers.io()).toList().toBlocking().single().stream()
return executionRepository
.retrievePipelinesForPipelineConfigId(pipelineId, criteria)
.subscribeOn(Schedulers.io())
.toList()
.toBlocking()
.single()
.stream()
.min(startTimeOrId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class GremlinConfiguration {
val mapper = OrcaObjectMapper
.newInstance()
.setPropertyNamingStrategy(
PropertyNamingStrategy.SNAKE_CASE)
PropertyNamingStrategy.SNAKE_CASE
)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) // we want Instant serialized as ISO string
return RestAdapter.Builder()
.setRequestInterceptor(spinnakerRequestInterceptor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ class MessageFlagger(val clock: Clock, val props: FlaggerProperties) {
mutex.lock()
val matches = queue.filter { it.timestamp.isAfter(timeCutoff) && it.hash == hash }
if (matches.count() >= props.threshold) {
throw MessageFlaggedException("Event '$event' with fingerprint '${event.fingerprint}' has been encountered " +
"${matches.count()} times in the last ${props.lookbackSeconds}s")
throw MessageFlaggedException(
"Event '$event' with fingerprint '${event.fingerprint}' has been encountered " +
"${matches.count()} times in the last ${props.lookbackSeconds}s"
)
}

queue.add(TimestampedHash(now, hash))
} finally {
mutex.unlock()
mutex.unlock()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class RunCanaryIntervalsStage(private val clock: Clock) : StageDefinitionBuilder
val canaryConfig = parent.mapTo<KayentaCanaryContext>("/canaryConfig")

val lifetime: Duration = if (canaryConfig.endTime != null) {
Duration.ofMinutes((canaryConfig.startTime ?: Instant.now(clock))
.until(canaryConfig.endTime, ChronoUnit.MINUTES))
Duration.ofMinutes(
(canaryConfig.startTime ?: Instant.now(clock))
.until(canaryConfig.endTime, ChronoUnit.MINUTES)
)
} else if (canaryConfig.lifetime != null) {
canaryConfig.lifetime
} else {
Expand Down Expand Up @@ -227,12 +229,12 @@ data class DeployedServerGroupContext @JsonCreator constructor(
companion object {
fun from(data: Map<String, String>): DeployedServerGroupContext {
return DeployedServerGroupContext(
data["controlLocation"].orEmpty(),
data["controlScope"].orEmpty(),
data["controlAccountId"],
data["experimentLocation"].orEmpty(),
data["experimentScope"].orEmpty(),
data["experimentAccountId"]
data["controlLocation"].orEmpty(),
data["controlScope"].orEmpty(),
data["controlAccountId"],
data["experimentLocation"].orEmpty(),
data["experimentScope"].orEmpty(),
data["experimentAccountId"]
)
}
}
Expand Down
Loading