From d902588154b96a8a96c64ba9c584d5032071f315 Mon Sep 17 00:00:00 2001 From: Emily Burns Date: Wed, 26 Jun 2019 14:36:18 -0700 Subject: [PATCH] feat(artifacts): allow release status to be propagated to artifact service (#471) --- gradle.properties | 2 +- .../igor/artifacts/ArtifactController.java | 9 ++++++--- .../spinnaker/igor/artifacts/ArtifactService.java | 2 +- .../igor/artifacts/ArtifactServiceSpec.groovy | 15 +++++++++++++-- .../igor/artifacts/TestArtifactService.java | 15 ++++++++++----- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index c23fb853c..b601955f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactController.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactController.java index c4e6cf3f5..35a3b60ab 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactController.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactController.java @@ -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; /** @@ -43,13 +44,15 @@ public ArtifactController(ArtifactServices artifactServices) { @GetMapping("/{provider}/{name}") public List 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) { diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactService.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactService.java index 8ad41799e..6e22ceebd 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactService.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/artifacts/ArtifactService.java @@ -33,7 +33,7 @@ public interface ArtifactService { /** Used to populate the manual trigger dropdown with options */ @Nonnull - List getArtifactVersions(@Nonnull String name); + List getArtifactVersions(@Nonnull String name, String releaseStatus); /** Used to fetch a specific artifact for decorating a trigger */ @Nonnull diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/artifacts/ArtifactServiceSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/artifacts/ArtifactServiceSpec.groovy index c5f937b46..69da8a650 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/artifacts/ArtifactServiceSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/artifacts/ArtifactServiceSpec.groovy @@ -53,7 +53,7 @@ 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() @@ -61,6 +61,17 @@ class ArtifactServiceSpec extends Specification { 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") @@ -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() diff --git a/igor-web/src/test/java/com/netflix/spinnaker/igor/artifacts/TestArtifactService.java b/igor-web/src/test/java/com/netflix/spinnaker/igor/artifacts/TestArtifactService.java index c3071efd9..1f58af9d1 100644 --- a/igor-web/src/test/java/com/netflix/spinnaker/igor/artifacts/TestArtifactService.java +++ b/igor-web/src/test/java/com/netflix/spinnaker/igor/artifacts/TestArtifactService.java @@ -31,15 +31,20 @@ public ArtifactServiceProvider artifactServiceProvider() { } @Override - public List getArtifactVersions(String name) { + public List getArtifactVersions(String name, String releaseStatus) { if (!name.equals("test")) { return Collections.emptyList(); } List 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; }