Skip to content

Commit

Permalink
feat(history): expose keel history api (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns committed Jun 26, 2019
1 parent 20e2e15 commit de6efc2
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 2 deletions.
1 change: 1 addition & 0 deletions gate-core/gate-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {

implementation "com.netflix.spinnaker.kork:kork-core"
implementation "com.netflix.spinnaker.kork:kork-security"
implementation "com.netflix.spinnaker.kork:kork-manageddelivery"
implementation "com.netflix.spectator:spectator-api"
implementation "com.github.ben-manes.caffeine:guava"
implementation "com.netflix.hystrix:hystrix-core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ServiceConfiguration {
void postConstruct() {
// this check is done in a @PostConstruct to avoid Spring's list merging in @ConfigurationProperties (vs. overriding)
healthCheckableServices = healthCheckableServices ?: [
"orca", "clouddriver", "echo", "igor", "flex", "front50", "mahe", "mine"
"orca", "clouddriver", "echo", "igor", "flex", "front50", "mahe", "mine", "keel"
]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
*
* Copyright 2019 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.gate.services.internal;

import com.netflix.spinnaker.kork.manageddelivery.model.ResourceEvent;
import java.time.Instant;
import java.util.List;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;

public interface KeelService {

@GET("/resources/events/{name}")
List<ResourceEvent> getResourceEvents(@Path("name") String name, @Query("since") Instant since);
}
1 change: 1 addition & 0 deletions gate-web/gate-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
implementation "com.netflix.spinnaker.kork:kork-web"
implementation "com.netflix.spinnaker.kork:kork-secrets-aws"
implementation "com.netflix.spinnaker.kork:kork-core"
implementation "com.netflix.spinnaker.kork:kork-manageddelivery"
implementation "com.netflix.frigga:frigga"
implementation "redis.clients:jedis"
implementation "com.netflix.hystrix:hystrix-core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.netflix.spinnaker.gate.services.internal.EchoService
import com.netflix.spinnaker.gate.services.internal.Front50Service
import com.netflix.spinnaker.gate.services.internal.IgorService
import com.netflix.spinnaker.gate.services.internal.KayentaService
import com.netflix.spinnaker.gate.services.internal.KeelService
import com.netflix.spinnaker.gate.services.internal.MineService
import com.netflix.spinnaker.gate.services.internal.OrcaService
import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector
Expand Down Expand Up @@ -174,6 +175,12 @@ class GateConfig extends RedisHttpSessionConfiguration {
createClient "clouddriver", ClouddriverService, okHttpClient
}

@Bean
@ConditionalOnProperty("services.keel.enabled")
KeelService keelService(OkHttpClient okHttpClient) {
createClient "keel", KeelService, okHttpClient
}

@Bean
ClouddriverServiceSelector clouddriverServiceSelector(ClouddriverService defaultClouddriverService, OkHttpClient okHttpClient) {
// support named clouddriver service clients
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.netflix.spinnaker.gate.controllers;

import com.netflix.spinnaker.gate.services.internal.KeelService;
import com.netflix.spinnaker.kork.manageddelivery.model.ResourceEvent;
import groovy.util.logging.Slf4j;
import io.swagger.annotations.ApiOperation;
import java.time.Instant;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/history")
@RestController
@Slf4j
@ConditionalOnProperty("services.keel.enabled")
public class HistoryController {

private static final Logger log = LoggerFactory.getLogger(HistoryController.class);
private final KeelService keelService;

@Autowired
public HistoryController(KeelService keelService) {
this.keelService = keelService;
}

@ApiOperation(value = "Get history for a resource", response = List.class)
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
List<ResourceEvent> getHistory(
@PathVariable("name") String name,
@RequestParam(value = "since", required = false) Instant since) {
return keelService.getResourceEvents(name, since);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
fiatVersion=1.1.0
enablePublishing=false
spinnakerGradleVersion=6.5.0
korkVersion=5.6.3
korkVersion=5.7.0
includeProviders=basic,iap,ldap,oauth2,saml,x509
org.gradle.parallel=true

0 comments on commit de6efc2

Please sign in to comment.