Skip to content

Commit

Permalink
refactor(*): Pull jenkins out into separate module; create new core a…
Browse files Browse the repository at this point in the history
…bstractions
  • Loading branch information
robzienert committed Jan 29, 2020
1 parent 2247dc9 commit 36c14fd
Show file tree
Hide file tree
Showing 122 changed files with 2,820 additions and 2,010 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
fiatVersion=1.13.1
enablePublishing=false
korkVersion=7.15.1
spinnakerGradleVersion=7.0.1
spinnakerGradleVersion=7.5.1
org.gradle.parallel=true
3 changes: 3 additions & 0 deletions igor-core/igor-core.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"

implementation "com.netflix.spinnaker.fiat:fiat-core:$fiatVersion"
implementation "com.netflix.spinnaker.kork:kork-artifacts"
implementation "com.netflix.spinnaker.kork:kork-core"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class BuildProperties {
*/
private int pollInterval = 60;

/** TODO(jc): Please document */
/** TODO(jc): Please document TODO(rz): Duration */
private int lookBackWindowMins = 10 * 60 * 60;

/** TODO(jc): Please document */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Netflix, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,13 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.igor.jenkins.client.model.TestResults;
import java.util.List;
import java.util.Map;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GenericBuild {
private boolean building;
Expand All @@ -36,7 +37,7 @@ public class GenericBuild {

private Result result;
private List<GenericArtifact> artifacts;
private List<TestResults> testResults;
private List<? extends TestResult> testResults;
private String url;
private String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lombok.Getter;
import lombok.experimental.Wither;

/** TODO(rz): Rename to GitRevision. */
@Getter
@EqualsAndHashCode(of = "sha1")
@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2016 Google, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
Expand All @@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.build.model;

package com.netflix.spinnaker.igor.history.model

abstract class Event {
}
public interface TestResult {}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright 2019 Schibsted ASA.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2019 Google, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
Expand All @@ -16,12 +16,11 @@

package com.netflix.spinnaker.igor.exceptions;

import static org.springframework.http.HttpStatus.NOT_FOUND;

import com.netflix.spinnaker.kork.web.exceptions.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(NOT_FOUND)
@ResponseStatus(HttpStatus.NOT_FOUND)
public class ArtifactNotFoundException extends NotFoundException {
public ArtifactNotFoundException(
String master, String job, Integer buildNumber, String fileName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2019 Google, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
Expand All @@ -18,6 +18,7 @@

import com.netflix.spinnaker.kork.web.exceptions.InvalidRequestException;

/** TODO(rz): Sparsely used, but primarily just Jenkins. */
public class BuildJobError extends InvalidRequestException {
public BuildJobError(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2019 Google, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
Expand All @@ -16,6 +16,7 @@

package com.netflix.spinnaker.igor.exceptions;

/** TODO(rz): Document. SpinnakerException. */
public class QueuedJobDeterminationError extends RuntimeException {
public QueuedJobDeterminationError(String msg) {
super(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;

@EqualsAndHashCode(callSuper = true)
@RequiredArgsConstructor
@Data
public class ArtifactoryEvent extends Event {
public class ArtifactoryEvent implements Event {
private final Content content;
private final Map<String, String> details =
ImmutableMap.<String, String>builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Schibsted ASA.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,16 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.history.model;

package com.netflix.spinnaker.igor.history.model
/** TODO(rz): Documnt. */
public interface BuildContent {

/**
* TODO(rz): Cannot move to kork-core due to Jenkins dependency
*/
class GenericBuildEvent extends Event{
GenericBuildContent content
Map details = [
type : 'build',
source: 'igor'
]
String UNDEFINED_TYPE = "undefined";

default String getType() {
return UNDEFINED_TYPE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.history.model;

import java.util.HashMap;
import java.util.Map;

/** TODO(rz): Documnt. */
public interface BuildEvent<T extends BuildContent> extends Event {

T getContent();

default Map<?, ?> getDetails() {
Map<String, String> d = new HashMap<>();
d.put("type", "build");
d.put("source", "igor");
return d;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.netflix.spinnaker.igor.history.model

import com.netflix.spinnaker.igor.build.model.GenericArtifact

class DockerEvent extends Event {
class DockerEvent implements Event {
Content content
GenericArtifact artifact

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.netflix.spinnaker.igor.history.model;

import lombok.AllArgsConstructor;
import lombok.Data;

/** Move any invocation of this class to a monitor-specific BuildContent implementation. */
@Deprecated
@Data
@AllArgsConstructor
public class EmptyBuildContent implements BuildContent {

public static String TYPE = "empty";

@Override
public String getType() {
return TYPE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.netflix.spinnaker.igor.history.model;

/** TODO(rz): Document. */
public interface Event {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.igor.history.model;

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

/** Move any invocation of this class to a monitor-specific BuildContent implementation. */
@Deprecated
@Data
@AllArgsConstructor
public class GenericBuildEvent implements BuildEvent<EmptyBuildContent> {
private EmptyBuildContent content;
private Map<?, ?> details;

public GenericBuildEvent(EmptyBuildContent content) {
this.content = content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface PollingMonitor extends ApplicationListener<RemoteStatusChangedE

Long getLastPoll();

/** TODO(rz): Duration. This value is used as seconds. */
int getPollInterval();

boolean isPollingEnabled();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright 2019 Schibsted ASA.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -64,4 +63,8 @@ public interface BuildOperations extends BuildService {
List<?> getBuilds(String job);

JobConfiguration getJobConfig(String jobName);

default void stopRunningBuild(String jobName, int buildNumber) {
throw new UnsupportedOperationException("build service has not implemented build stopping yet");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.service;

/** Additional operations for {@link BuildService}s that support build queuing. */
public interface BuildQueueOperations<T> extends BuildOperations {
/** Get the queued build at {@code queueId}. */
T getQueuedBuild(String queueId);

/**
* Stop a queued build at {@code queueId}.
*
* <p>Will not wait for a result. Must be idempotent.
*/
default void stopQueuedBuild(String jobName, String queueId, int buildNumber) {
// Do nothing.
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Schibsted ASA.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,7 +17,6 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.netflix.spinnaker.fiat.model.resources.Permissions;
import com.netflix.spinnaker.igor.model.BuildServiceProvider;

/**
* Interface representing a Build Service host (CI) and the permissions needed to access it. Most
Expand Down
Loading

0 comments on commit 36c14fd

Please sign in to comment.