Skip to content

Commit

Permalink
feat(artifacts): allow release status to be propagated to artifact se…
Browse files Browse the repository at this point in the history
…rvice (#471)
  • Loading branch information
emjburns committed Jun 26, 2019
1 parent 42c3c7a commit d902588
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jun 24 19:58:20 UTC 2019
fiatVersion=1.1.0
enablePublishing=false
korkVersion=5.6.3
korkVersion=5.7.0
spinnakerGradleVersion=6.5.0
org.gradle.parallel=true
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
Expand All @@ -43,13 +44,15 @@ public ArtifactController(ArtifactServices artifactServices) {

@GetMapping("/{provider}/{name}")
public List<String> getVersions(
@PathVariable("provider") String provider, @PathVariable("name") String name) {
@PathVariable("provider") String provider,
@PathVariable("name") String name,
@RequestParam(value = "releaseStatus", required = false) String releaseStatus) {
ArtifactService artifactService = getService(provider);
return artifactService.getArtifactVersions(name);
return artifactService.getArtifactVersions(name, releaseStatus);
}

@GetMapping("/{provider}/{name}/{version:.+}")
public Artifact getVersions(
public Artifact getArtifact(
@PathVariable("provider") String provider,
@PathVariable("name") String name,
@PathVariable("version") String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface ArtifactService {

/** Used to populate the manual trigger dropdown with options */
@Nonnull
List<String> getArtifactVersions(@Nonnull String name);
List<String> getArtifactVersions(@Nonnull String name, String releaseStatus);

/** Used to fetch a specific artifact for decorating a trigger */
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,25 @@ class ArtifactServiceSpec extends Specification {
def "service finds artifact versions"() {
when:
def service = artifactServices.getService("artifactory")
def versions = service.getArtifactVersions("test")
def versions = service.getArtifactVersions("test", null)

then:
assertThat(versions).isNotNull()
assertThat(versions).isNotEmpty()
versions.size() > 0
}

def "service finds only snapshot artifacts"() {
when:
def service = artifactServices.getService("artifactory")
def versions = service.getArtifactVersions("test", "snapshot")

then:
assertThat(versions).isNotNull()
assertThat(versions).isNotEmpty()
versions.size() == 1
}

def "service finds artifact"() {
when:
def service = artifactServices.getService("artifactory")
Expand All @@ -75,7 +86,7 @@ class ArtifactServiceSpec extends Specification {
def "versions list is empty when no versions found"() {
when:
def service = artifactServices.getService("artifactory")
def versions = service.getArtifactVersions("blah")
def versions = service.getArtifactVersions("blah", "")

then:
assertThat(versions).isNotNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ public ArtifactServiceProvider artifactServiceProvider() {
}

@Override
public List<String> getArtifactVersions(String name) {
public List<String> getArtifactVersions(String name, String releaseStatus) {
if (!name.equals("test")) {
return Collections.emptyList();
}
List<String> versions = new ArrayList<>();
versions.add("v0.1.0");
versions.add("v0.2.0");
versions.add("v0.3.0");
versions.add("v0.4.0");
if (releaseStatus == null || releaseStatus.isEmpty() || releaseStatus.contains("final")) {
versions.add("v0.1.0");
versions.add("v0.2.0");
versions.add("v0.3.0");
versions.add("v0.4.0");
}
if (releaseStatus == null || releaseStatus.isEmpty() || releaseStatus.contains("snapshot")) {
versions.add("v0.5.0~SNAPSHOT");
}
return versions;
}

Expand Down

0 comments on commit d902588

Please sign in to comment.