diff --git a/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/config/ClouddriverConfiguration.kt b/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/config/ClouddriverConfiguration.kt index c22daf26..6ebba24f 100644 --- a/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/config/ClouddriverConfiguration.kt +++ b/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/config/ClouddriverConfiguration.kt @@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.netflix.spinnaker.okhttp.SpinnakerRequestInterceptor import com.netflix.spinnaker.swabbie.clouddriver.CloudDriverService import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import @@ -30,7 +29,6 @@ import retrofit.RestAdapter import retrofit.client.Client import retrofit.converter.JacksonConverter -@ConditionalOnExpression("!\${eddaEndpoints.enabled:false}") @Configuration @Import(RetrofitConfiguration::class) open class ClouddriverConfiguration { diff --git a/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/swabbie/clouddriver/ClouddriverAccountProvider.kt b/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/swabbie/clouddriver/ClouddriverAccountProvider.kt index 951f22e7..540470fe 100644 --- a/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/swabbie/clouddriver/ClouddriverAccountProvider.kt +++ b/swabbie-clouddriver/src/main/kotlin/com/netflix/spinnaker/swabbie/clouddriver/ClouddriverAccountProvider.kt @@ -20,10 +20,8 @@ import com.netflix.spinnaker.swabbie.AccountProvider import com.netflix.spinnaker.swabbie.InMemoryCache import com.netflix.spinnaker.swabbie.model.Account import com.netflix.spinnaker.swabbie.model.SpinnakerAccount -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean import org.springframework.stereotype.Component -@ConditionalOnBean(CloudDriverService::class) @Component class ClouddriverAccountProvider( private val accountCache: InMemoryCache @@ -31,7 +29,6 @@ class ClouddriverAccountProvider( override fun getAccounts(): Set = accountCache.get() } -@ConditionalOnBean(CloudDriverService::class) @Component class ClouddriverAccountCache( cloudDriverService: CloudDriverService diff --git a/swabbie-core/src/main/kotlin/com/netflix/spinnaker/swabbie/Cacheable.kt b/swabbie-core/src/main/kotlin/com/netflix/spinnaker/swabbie/Cacheable.kt index 37d46e41..534b0ef8 100644 --- a/swabbie-core/src/main/kotlin/com/netflix/spinnaker/swabbie/Cacheable.kt +++ b/swabbie-core/src/main/kotlin/com/netflix/spinnaker/swabbie/Cacheable.kt @@ -39,7 +39,7 @@ open class InMemoryCache( private val cache = AtomicReference>() - @Scheduled(fixedDelay = 15 * 60 * 1000L) //TODO: make configurable + @Scheduled(fixedDelay = 60 * 60 * 1000L) //TODO: make configurable private fun refresh() { try { cache.set(source) diff --git a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/config/EddaConfiguration.kt b/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/config/EddaConfiguration.kt index c75129c3..05b1c1ec 100644 --- a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/config/EddaConfiguration.kt +++ b/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/config/EddaConfiguration.kt @@ -18,17 +18,13 @@ package com.netflix.spinnaker.config import com.fasterxml.jackson.databind.ObjectMapper import com.netflix.spinnaker.swabbie.AccountProvider -import com.netflix.spinnaker.swabbie.edda.EddaEndpointsService import com.netflix.spinnaker.swabbie.edda.EddaService import com.netflix.spinnaker.swabbie.model.Account import com.netflix.spinnaker.swabbie.retrofit.SwabbieRetrofitConfiguration -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import -import retrofit.Endpoint import retrofit.Endpoints import retrofit.RequestInterceptor import retrofit.RestAdapter @@ -63,27 +59,6 @@ open class EddaConfiguration { } }.flatten() } - - @ConditionalOnExpression("\${eddaEndpoints.enabled:false}") - @Bean - open fun eddaEndpointsEndpoint(@Value("\${eddaEndpoints.baseUrl}") eddaEndpointsBaseUrl: String) : Endpoint { - return Endpoints.newFixedEndpoint(eddaEndpointsBaseUrl)!! - } - - @ConditionalOnExpression("\${eddaEndpoints.enabled:false}") - @Bean - open fun eddaEndpointsService(eddaEndpointsEndpoint: Endpoint, - objectMapper: ObjectMapper, - retrofitClient: Client, - spinnakerRequestInterceptor: RequestInterceptor, - retrofitLogLevel: RestAdapter.LogLevel) = RestAdapter.Builder() - .setRequestInterceptor(spinnakerRequestInterceptor) - .setEndpoint(eddaEndpointsEndpoint) - .setClient(retrofitClient) - .setLogLevel(retrofitLogLevel) - .setConverter(JacksonConverter(objectMapper)) - .build() - .create(EddaEndpointsService::class.java) } data class EddaApiClient( diff --git a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/EddaEndpointsService.kt b/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/EddaEndpointsService.kt deleted file mode 100644 index 0250c5c6..00000000 --- a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/EddaEndpointsService.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.netflix.spinnaker.swabbie.edda - -import retrofit.http.GET - -interface EddaEndpointsService { - @GET("/api/v1/edda/endpoints.json") - fun getEddaEndpoints(): EddaEndpointsContainer - - data class EddaEndpointsContainer( - val edda_endpoints: EddaEndpoints - ) { - data class EddaEndpoints( - val by_account: List?, - val by_cluster: List? - ) - - fun get(): List = edda_endpoints.by_cluster ?: emptyList() - } -} diff --git a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/providers/EddaAccountProvider.kt b/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/providers/EddaAccountProvider.kt deleted file mode 100644 index fef0b6ef..00000000 --- a/swabbie-edda/src/main/kotlin/com/netflix/spinnaker/swabbie/edda/providers/EddaAccountProvider.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.netflix.spinnaker.swabbie.edda.providers - -import com.netflix.spinnaker.swabbie.AccountProvider -import com.netflix.spinnaker.swabbie.InMemoryCache -import com.netflix.spinnaker.swabbie.edda.EddaEndpointsService -import com.netflix.spinnaker.swabbie.model.Account -import com.netflix.spinnaker.swabbie.model.Region -import com.netflix.spinnaker.swabbie.model.SpinnakerAccount -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression -import org.springframework.context.annotation.Lazy -import org.springframework.stereotype.Component - -@ConditionalOnExpression("\${eddaEndpoints.enabled:false}") -@Component -class EddaAccountProvider( - private val eddaEndpointsService: EddaEndpointsService, - @Lazy private val accountCache: InMemoryCache -) : AccountProvider { - override fun getAccounts(): Set = accountCache.get() - - fun load(): Set { - return eddaEndpointsService.getEddaEndpoints().get() - .asSequence() - .mapNotNull { endpointToAccount(it) } - .toSet() - } - - // i.e. "http://edda-account.region.foo.bar.com", - private fun endpointToAccount(endpoint: String): SpinnakerAccount? { - val regex = """^https?://edda-([\w\-]+)\.([\w\-]+)\..*$""".toRegex() - val match = regex.matchEntire(endpoint) ?: return null - val (account, region) = match.destructured - - return SpinnakerAccount(true, null, "aws", account, endpoint, listOf(Region(false, region))) - } -} - -@ConditionalOnExpression("\${eddaEndpoints.enabled:false}") -@Component -class EddaAccountCache( - eddaAccountProvider: EddaAccountProvider -) : InMemoryCache(eddaAccountProvider.load())