diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy index 0cf4e3a95..f63b1d365 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy @@ -16,6 +16,7 @@ package com.netflix.spinnaker.igor.config +import com.fasterxml.jackson.databind.ObjectMapper import com.jakewharton.retrofit.Ok3Client import com.netflix.spinnaker.config.DefaultServiceEndpoint import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider @@ -30,6 +31,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import retrofit.Endpoints import retrofit.RestAdapter +import retrofit.converter.JacksonConverter @Configuration @ConditionalOnProperty(['services.clouddriver.base-url', 'docker-registry.enabled']) @@ -42,9 +44,12 @@ class DockerRegistryConfig { } @Bean - ClouddriverService dockerRegistryProxyService(OkHttpClientProvider clientProvider, - IgorConfigurationProperties igorConfigurationProperties, - RestAdapter.LogLevel retrofitLogLevel) { + ClouddriverService dockerRegistryProxyService( + OkHttpClientProvider clientProvider, + IgorConfigurationProperties igorConfigurationProperties, + RestAdapter.LogLevel retrofitLogLevel, + ObjectMapper objectMapper + ) { def address = igorConfigurationProperties.services.clouddriver.baseUrl ?: 'none' if (address == 'none') { null @@ -54,6 +59,7 @@ class DockerRegistryConfig { .setEndpoint(Endpoints.newFixedEndpoint(address)) .setClient(new Ok3Client(clientProvider.getClient(new DefaultServiceEndpoint("clouddriver", address)))) .setLogLevel(retrofitLogLevel) + .setConverter(new JacksonConverter(objectMapper)) .setLog(new Slf4jRetrofitLogger(ClouddriverService)) .build() .create(ClouddriverService) diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/EchoConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/EchoConfig.groovy index 36f340f20..d5c4caca0 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/EchoConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/EchoConfig.groovy @@ -16,6 +16,7 @@ package com.netflix.spinnaker.igor.config +import com.fasterxml.jackson.databind.ObjectMapper import com.jakewharton.retrofit.Ok3Client import com.netflix.spinnaker.config.DefaultServiceEndpoint import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider @@ -27,6 +28,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import retrofit.Endpoints import retrofit.RestAdapter +import retrofit.converter.JacksonConverter /** * history service configuration @@ -35,9 +37,12 @@ import retrofit.RestAdapter @Configuration class EchoConfig { @Bean - EchoService echoService(OkHttpClientProvider okHttpClientProvider, - IgorConfigurationProperties igorConfigurationProperties, - RestAdapter.LogLevel retrofitLogLevel) { + EchoService echoService( + OkHttpClientProvider okHttpClientProvider, + IgorConfigurationProperties igorConfigurationProperties, + RestAdapter.LogLevel retrofitLogLevel, + ObjectMapper objectMapper + ) { String address = igorConfigurationProperties.services.echo.baseUrl ?: 'none' if (address == 'none') { @@ -47,6 +52,7 @@ class EchoConfig { new RestAdapter.Builder() .setEndpoint(Endpoints.newFixedEndpoint(address)) .setClient(new Ok3Client(okHttpClientProvider.getClient(new DefaultServiceEndpoint("echo", address)))) + .setConverter(new JacksonConverter(objectMapper)) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(EchoService)) .build() diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java index a73ece757..84f3c65e8 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java @@ -16,6 +16,7 @@ */ package com.netflix.spinnaker.igor.config; +import com.fasterxml.jackson.databind.ObjectMapper; import com.jakewharton.retrofit.Ok3Client; import com.netflix.spectator.api.Registry; import com.netflix.spinnaker.config.DefaultServiceEndpoint; @@ -39,6 +40,7 @@ import org.springframework.scheduling.TaskScheduler; import retrofit.Endpoints; import retrofit.RestAdapter; +import retrofit.converter.JacksonConverter; @Configuration @ConditionalOnProperty("services.front50.base-url") @@ -54,7 +56,8 @@ public PluginCache pluginCache( public PluginReleaseService pluginReleaseService( OkHttpClientProvider clientProvider, IgorConfigurationProperties properties, - RestAdapter.LogLevel retrofitLogLevel) { + RestAdapter.LogLevel retrofitLogLevel, + ObjectMapper objectMapper) { String address = properties.getServices().getFront50().getBaseUrl(); Front50Service front50Service = @@ -65,6 +68,7 @@ public PluginReleaseService pluginReleaseService( clientProvider.getClient(new DefaultServiceEndpoint("front50", address)))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(Front50Service.class)) + .setConverter(new JacksonConverter(objectMapper)) .build() .create(Front50Service.class); diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy index 1db2e990c..1c8894a88 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy @@ -8,6 +8,7 @@ */ package com.netflix.spinnaker.igor.config +import com.fasterxml.jackson.databind.ObjectMapper import com.jakewharton.retrofit.Ok3Client import com.netflix.spinnaker.config.DefaultServiceEndpoint import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider @@ -26,6 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import retrofit.converter.JacksonConverter import java.util.concurrent.TimeUnit @@ -42,28 +44,37 @@ import retrofit.RestAdapter class WerckerConfig { @Bean Map werckerMasters( - BuildServices buildServices, - WerckerCache cache, - IgorConfigurationProperties igorConfigurationProperties, - OkHttpClientProvider clientProvider, - @Valid WerckerProperties werckerProperties, - RestAdapter.LogLevel retrofitLogLevel) { + BuildServices buildServices, + WerckerCache cache, + IgorConfigurationProperties igorConfigurationProperties, + OkHttpClientProvider clientProvider, + @Valid WerckerProperties werckerProperties, + RestAdapter.LogLevel retrofitLogLevel, + ObjectMapper objectMapper + ) { log.debug "creating werckerMasters" Map werckerMasters = werckerProperties?.masters?.collectEntries { WerckerHost host -> log.debug "bootstrapping Wercker ${host.address} as ${host.name}" - [(host.name): new WerckerService(host, cache, werckerClient(host, igorConfigurationProperties.getClient().timeout, clientProvider, retrofitLogLevel), host.permissions.build())] + [(host.name): new WerckerService(host, cache, werckerClient(host, igorConfigurationProperties.getClient().timeout, clientProvider, retrofitLogLevel, objectMapper), host.permissions.build())] } buildServices.addServices(werckerMasters) werckerMasters } - static WerckerClient werckerClient(WerckerHost host, int timeout = 30000, OkHttpClientProvider clientProvider, RestAdapter.LogLevel retrofitLogLevel) { + static WerckerClient werckerClient( + WerckerHost host, + int timeout = 30000, + OkHttpClientProvider clientProvider, + RestAdapter.LogLevel retrofitLogLevel, + ObjectMapper objectMapper + ) { OkHttpClient client = clientProvider.getClient(new DefaultServiceEndpoint(host.name, host.address, false)) client = client.newBuilder().readTimeout(timeout, TimeUnit.MILLISECONDS).build() return new RestAdapter.Builder() .setLog(new Slf4jRetrofitLogger(WerckerService)) .setLogLevel(retrofitLogLevel) + .setConverter(new JacksonConverter(objectMapper)) .setEndpoint(Endpoints.newFixedEndpoint(host.address)) .setClient(new Ok3Client(client)) .build() diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy index a4c79c8ed..6463b825f 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy @@ -9,6 +9,8 @@ */ package com.netflix.spinnaker.igor.wercker +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.ObjectMapper import com.netflix.spinnaker.config.okhttp3.InsecureOkHttpClientBuilderProvider import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider import com.netflix.spinnaker.igor.config.* @@ -29,8 +31,13 @@ class WerckerClientSpec extends Specification { @Shared MockWebServer server + @Shared + ObjectMapper objectMapper + void setup() { server = new MockWebServer() + objectMapper = new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) } void cleanup() { @@ -101,7 +108,7 @@ class WerckerClientSpec extends Specification { ) server.start() def host = new WerckerHost(name: 'werckerMaster', address: server.url('/').toString()) - client = new WerckerConfig().werckerClient(host, 30000, new OkHttpClientProvider([new InsecureOkHttpClientBuilderProvider(new OkHttpClient())]), RestAdapter.LogLevel.BASIC) + client = new WerckerConfig().werckerClient(host, 30000, new OkHttpClientProvider([new InsecureOkHttpClientBuilderProvider(new OkHttpClient())]), RestAdapter.LogLevel.BASIC, objectMapper) } String read(String fileName) {