Skip to content

Commit

Permalink
feat(artifact): expose get single artifact (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored Sep 30, 2019
1 parent b3ca343 commit 482bf0e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
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;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

@RestController
Expand Down Expand Up @@ -82,4 +88,14 @@ List<String> getVersionsOfArtifactForProvider(
@RequestParam(required = false) String releaseStatus) {
return artifactService.getVersionsOfArtifactForProvider(provider, packageName, releaseStatus);
}

@ApiOperation(
value = "Retrieve the specified artifact version for an artifact provider and package name")
@RequestMapping(value = "/{provider}/{packageName}/{version:.+}", method = RequestMethod.GET)
Map<String, Object> getArtifact(
@PathVariable String provider,
@PathVariable String packageName,
@PathVariable String version) {
return artifactService.getArtifactByVersion(provider, packageName, version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ private static HystrixCommand<Void> voidCommand(String type, Callable<Void> work
return HystrixFactory.newVoidCommand(GROUP, type, work);
}

private static HystrixCommand<Map<String, Object>> mapCommand(
String type, Callable<Map<String, Object>> work) {
return HystrixFactory.newMapCommand(GROUP, type, work);
}

public List<Map> getArtifactCredentials(String selectorKey) {
return mapListCommand(
"artifactCredentials",
Expand Down Expand Up @@ -110,4 +115,17 @@ public List<String> getVersionsOfArtifactForProvider(
() -> igorService.get().getArtifactVersions(provider, packageName, releaseStatus))
.execute();
}

public Map<String, Object> getArtifactByVersion(
String provider, String packageName, String version) {
if (!igorService.isPresent()) {
throw new IllegalStateException(
"Cannot fetch artifact versions because Igor is not enabled.");
}

return mapCommand(
"artifactFromVersion",
() -> igorService.get().getArtifactByVersion(provider, packageName, version))
.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.netflix.spinnaker.gate.services.internal


import retrofit.http.EncodedPath
import retrofit.http.GET
import retrofit.http.Path
Expand Down Expand Up @@ -75,6 +76,11 @@ interface IgorService {
@Path("packageName") String packageName,
@Query("releaseStatus") String releaseStatus);

@GET('/artifacts/{provider}/{packageName}/{version}')
Map<String, Object> getArtifactByVersion(@Path("provider") String provider,
@Path("packageName") String packageName,
@Path("version") String version);

@GET('/concourse/{buildMaster}/teams/{team}/pipelines/{pipeline}/resources')
List<String> getConcourseResources(@Path("buildMaster") String buildMaster, @Path("team") String team, @Path("pipeline") String pipeline);
}

0 comments on commit 482bf0e

Please sign in to comment.