Skip to content

Commit

Permalink
feat(artifacts): Add type parameter to ArtifactService
Browse files Browse the repository at this point in the history
  • Loading branch information
luispollo committed Jul 21, 2020
1 parent b9bdb3c commit af347c1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ public ArtifactController(ArtifactServices artifactServices) {
public List<String> getVersions(
@PathVariable("provider") String provider,
@PathVariable("name") String name,
@RequestParam(value = "releaseStatus", required = false) String releaseStatus) {
@RequestParam(value = "releaseStatus", required = false) String releaseStatus,
@RequestParam(value = "type", required = false, defaultValue = "deb") String type) {
ArtifactService artifactService = getService(provider);
return artifactService.getArtifactVersions(name, releaseStatus);
return artifactService.getArtifactVersions(type, name, releaseStatus);
}

@GetMapping("/{provider}/{name}/{version:.+}")
public Artifact getArtifact(
@PathVariable("provider") String provider,
@PathVariable("name") String name,
@PathVariable("version") String version) {
@PathVariable("version") String version,
@RequestParam(value = "type", required = false, defaultValue = "deb") String type) {
ArtifactService artifactService = getService(provider);
return artifactService.getArtifact(name, version);
return artifactService.getArtifact(type, name, version);
}

private ArtifactService getService(String serviceName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,26 @@ public interface ArtifactService {

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

/** Used to fetch a specific artifact for decorating a trigger */
@Nonnull
Artifact getArtifact(@Nonnull String name, @Nonnull String version);
Artifact getArtifact(@Nonnull String type, @Nonnull String name, @Nonnull String version);

/**
* Used to populate the manual trigger dropdown with options (backwards-compatibility for Debian)
*/
@Nonnull
default List<String> getArtifactVersions(@Nonnull String name, String releaseStatus) {
return getArtifactVersions("deb", name, releaseStatus);
}

/**
* Used to fetch a specific artifact for decorating a trigger (backwards-compatibility for Debian)
*/
@Nonnull
default Artifact getArtifact(@Nonnull String name, @Nonnull String version) {
return getArtifact("deb", name, version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ArtifactServiceProvider artifactServiceProvider() {
}

@Override
public List<String> getArtifactVersions(String name, String releaseStatus) {
public List<String> getArtifactVersions(String type, String name, String releaseStatus) {
if (!name.equals("test")) {
return Collections.emptyList();
}
Expand All @@ -49,7 +49,7 @@ public List<String> getArtifactVersions(String name, String releaseStatus) {
}

@Override
public Artifact getArtifact(String name, String version) {
public Artifact getArtifact(String type, String name, String version) {
if (!name.equals("test") && !version.equals("v0.4.0")) {
throw new NotFoundException("Artifact not found");
}
Expand Down

0 comments on commit af347c1

Please sign in to comment.