Skip to content

Commit

Permalink
Merge branch 'master' into helm-watcher-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
gal-yardeni authored Sep 7, 2020
2 parents b4f06b3 + 1e81c41 commit 3b0e7e5
Show file tree
Hide file tree
Showing 24 changed files with 632 additions and 427 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RUN apt-get update && apt-get install -y \
openjdk-8-jdk \
openjdk-11-jdk \
&& rm -rf /var/lib/apt/lists/*
MAINTAINER sig-platform@spinnaker.io
LABEL maintainer="sig-platform@spinnaker.io"
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV JDK_18 /usr/lib/jvm/java-8-openjdk-amd64
ENV GRADLE_USER_HOME /workspace/.gradle
Expand Down
8 changes: 0 additions & 8 deletions Dockerfile.java8

This file was deleted.

7 changes: 4 additions & 3 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM alpine:3.11
MAINTAINER sig-platform@spinnaker.io
COPY igor-web/build/install/igor /opt/igor
LABEL maintainer="sig-platform@spinnaker.io"
RUN apk --no-cache add --update bash openjdk11-jre
RUN adduser -D -S spinnaker
RUN addgroup -S -g 10111 spinnaker
RUN adduser -S -G spinnaker -u 10111 spinnaker
COPY igor-web/build/install/igor /opt/igor
RUN mkdir -p /opt/igor/plugins && chown -R spinnaker:nogroup /opt/igor/plugins
USER spinnaker
CMD ["/opt/igor/bin/igor"]
6 changes: 3 additions & 3 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM ubuntu:bionic
MAINTAINER sig-platform@spinnaker.io
COPY igor-web/build/install/igor /opt/igor
LABEL maintainer="sig-platform@spinnaker.io"
RUN apt-get update && apt-get -y install openjdk-11-jre-headless wget
RUN adduser --disabled-login --system spinnaker
RUN adduser --system --uid 10111 --group spinnaker
COPY igor-web/build/install/igor /opt/igor
RUN mkdir -p /opt/igor/plugins && chown -R spinnaker:nogroup /opt/igor/plugins
USER spinnaker
CMD ["/opt/igor/bin/igor"]
8 changes: 0 additions & 8 deletions Dockerfile.ubuntu-java8

This file was deleted.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fiatVersion=1.22.0
korkVersion=7.56.0
korkVersion=7.63.0
org.gradle.parallel=true
spinnakerGradleVersion=8.4.0
spinnakerGradleVersion=8.5.0

# To enable a composite reference to a project, set the
# project property `'<projectName>Composite=true'`.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
21 changes: 3 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,29 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GenericBuild {
private boolean building;
Expand Down
14 changes: 8 additions & 6 deletions igor-web/src/main/groovy/com/netflix/spinnaker/igor/Main.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@ package com.netflix.spinnaker.igor

import com.netflix.spinnaker.kork.boot.DefaultPropertiesBuilder
import com.netflix.spinnaker.kork.configserver.ConfigServerBootstrap
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import sun.net.InetAddressCachePolicy

import java.security.Security

/**
* Application entry point.
*/
@Configuration
@EnableAutoConfiguration(exclude = [GroovyTemplateAutoConfiguration])
@EnableConfigurationProperties(IgorConfigurationProperties)
@ComponentScan(['com.netflix.spinnaker.config', 'com.netflix.spinnaker.igor'])
@SpringBootApplication(
scanBasePackages = [
"com.netflix.spinnaker.config",
"com.netflix.spinnaker.igor"
],
exclude = [GroovyTemplateAutoConfiguration]
)
class Main extends SpringBootServletInitializer {

static final Map<String, Object> DEFAULT_PROPS = new DefaultPropertiesBuilder().property("spring.application.name", "igor").build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class GitHubConfig {
}

@Override
void intercept(RequestInterceptor.RequestFacade request) {
request.addQueryParam("access_token", accessToken)
void intercept(RequestFacade request) {
request.addHeader("Authorization", "token " + accessToken)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule
import com.jakewharton.retrofit.Ok3Client
import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.fiat.model.resources.Permissions
import com.netflix.spinnaker.igor.IgorConfigurationProperties
Expand All @@ -30,9 +31,8 @@ import com.netflix.spinnaker.igor.config.client.JenkinsRetrofitRequestIntercepto
import com.netflix.spinnaker.igor.jenkins.client.JenkinsClient
import com.netflix.spinnaker.igor.jenkins.service.JenkinsService
import com.netflix.spinnaker.igor.service.BuildServices
import com.netflix.spinnaker.okhttp.OkHttpMetricsInterceptor
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger
import com.squareup.okhttp.OkHttpClient
import okhttp3.OkHttpClient
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry
Expand Down Expand Up @@ -71,8 +71,8 @@ class JenkinsConfig {

@Bean
@ConditionalOnMissingBean
JenkinsOkHttpClientProvider jenkinsOkHttpClientProvider() {
return new DefaultJenkinsOkHttpClientProvider()
JenkinsOkHttpClientProvider jenkinsOkHttpClientProvider(OkHttpClient okHttpClient) {
return new DefaultJenkinsOkHttpClientProvider(okHttpClient)
}

@Bean
Expand Down Expand Up @@ -132,12 +132,13 @@ class JenkinsConfig {
RequestInterceptor requestInterceptor,
Registry registry,
int timeout = 30000) {
client.setReadTimeout(timeout, TimeUnit.MILLISECONDS)

OkHttpClient.Builder clientBuilder = client.newBuilder().readTimeout(timeout, TimeUnit.MILLISECONDS)

if (host.skipHostnameVerification) {
client.setHostnameVerifier({ hostname, _ ->
true
})
clientBuilder.hostnameVerifier({ hostname, _ ->
true
})
}

TrustManager[] trustManagers = null
Expand Down Expand Up @@ -175,13 +176,7 @@ class JenkinsConfig {
def sslContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagers, trustManagers, null)

client.setSslSocketFactory(sslContext.socketFactory)
}

if (registry == null) {
log.warn("no registry provided, OkHttpMetricsInterceptor will not be created for JenkinsClient")
} else {
client.interceptors().add(new OkHttpMetricsInterceptor({ -> registry }, true))
clientBuilder.sslSocketFactory(sslContext.socketFactory,(X509TrustManager) trustManagers[0])
}

new RestAdapter.Builder()
Expand All @@ -194,7 +189,7 @@ class JenkinsConfig {
}
})
.setLogLevel(RestAdapter.LogLevel.BASIC)
.setClient(new OkClient(client))
.setClient(new Ok3Client(clientBuilder.build()))
.setConverter(new JacksonConverter(getObjectMapper()))
.setLog(new Slf4jRetrofitLogger(JenkinsClient))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
package com.netflix.spinnaker.igor.config.client;

import com.netflix.spinnaker.igor.config.JenkinsProperties;
import com.squareup.okhttp.OkHttpClient;
import okhttp3.OkHttpClient;

public class DefaultJenkinsOkHttpClientProvider implements JenkinsOkHttpClientProvider {

private final OkHttpClient okHttpClient;

public DefaultJenkinsOkHttpClientProvider(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
}

@Override
public OkHttpClient provide(JenkinsProperties.JenkinsHost host) {
return new OkHttpClient();
return okHttpClient;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.netflix.spinnaker.igor.config.client;

import com.netflix.spinnaker.igor.config.JenkinsProperties;
import com.squareup.okhttp.OkHttpClient;
import okhttp3.OkHttpClient;

/** Abstracts away the logic for providing an OkHttpClient for Jenkins services. */
public interface JenkinsOkHttpClientProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,36 @@
package com.netflix.spinnaker.igor.scm.github.client

import com.netflix.spinnaker.igor.scm.github.client.model.CompareCommitsResponse
import com.netflix.spinnaker.igor.scm.github.client.model.GetRepositoryContentResponse
import retrofit.http.GET
import retrofit.http.Path
import retrofit.http.Query

/**
* Interface for interacting with a GitHub REST API
* https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
*/
interface GitHubClient {
@GET('/repos/{projectKey}/{repositorySlug}/compare/{fromCommit}...{toCommit}')
CompareCommitsResponse getCompareCommits(
@Path('projectKey') String projectKey,
@Path('repositorySlug') String repositorySlug,
@Path('fromCommit') String fromCommit,
@Path('toCommit') String toCommit)
@GET('/repos/{projectKey}/{repositorySlug}/compare/{fromCommit}...{toCommit}')
CompareCommitsResponse getCompareCommits(
@Path('projectKey') String projectKey,
@Path('repositorySlug') String repositorySlug,
@Path('fromCommit') String fromCommit,
@Path('toCommit') String toCommit)

@GET('/repos/{projectKey}/{repositorySlug}/contents/{path}')
GetRepositoryContentResponse getFileContent(
@Path('projectKey') String projectKey,
@Path('repositorySlug') String repositorySlug,
@Path(value = 'path', encode = false) String path,
@Query('ref') String ref
)

@GET('/repos/{projectKey}/{repositorySlug}/contents/{path}')
List<GetRepositoryContentResponse> listDirectory(
@Path('projectKey') String projectKey,
@Path('repositorySlug') String repositorySlug,
@Path(value = 'path', encode = false) String path,
@Query('ref') String ref
)
}

Loading

0 comments on commit 3b0e7e5

Please sign in to comment.