Skip to content

Commit

Permalink
chore(logs): allow anonymous front50 artifact fetching (#5066)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreynaud authored Nov 5, 2020
1 parent beb4286 commit aa95418
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions clouddriver-artifacts/clouddriver-artifacts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
implementation "com.netflix.spinnaker.kork:kork-artifacts"
implementation "com.netflix.spinnaker.kork:kork-annotations"
implementation "com.netflix.spinnaker.kork:kork-exceptions"
implementation "com.netflix.spinnaker.kork:kork-security"
implementation "com.oracle.oci.sdk:oci-java-sdk-core"
implementation "com.squareup.okhttp:okhttp"
implementation "com.sun.jersey:jersey-client:1.9.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.netflix.spinnaker.clouddriver.core.services.Front50Service;
import com.netflix.spinnaker.kork.annotations.NonnullByDefault;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -65,17 +66,25 @@ public InputStream download(Artifact artifact) throws IOException {
}

Map pipelineTemplate;
reference = reference.substring(URL_PREFIX.length());
if (reference.contains("@sha256:")) {
SplitResult result = splitReferenceOnToken(reference, "@sha256:");
String artifactId = reference.substring(URL_PREFIX.length());
if (artifactId.contains("@sha256:")) {
SplitResult result = splitReferenceOnToken(artifactId, "@sha256:");
pipelineTemplate =
front50Service.getV2PipelineTemplate(result.pipelineTemplateId, "", result.version);
} else if (reference.contains(":")) {
SplitResult result = splitReferenceOnToken(reference, ":");
AuthenticatedRequest.allowAnonymous(
() ->
front50Service.getV2PipelineTemplate(
result.pipelineTemplateId, "", result.version));
} else if (artifactId.contains(":")) {
SplitResult result = splitReferenceOnToken(artifactId, ":");
pipelineTemplate =
front50Service.getV2PipelineTemplate(result.pipelineTemplateId, result.version, "");
AuthenticatedRequest.allowAnonymous(
() ->
front50Service.getV2PipelineTemplate(
result.pipelineTemplateId, result.version, ""));
} else {
pipelineTemplate = front50Service.getV2PipelineTemplate(reference, "", "");
pipelineTemplate =
AuthenticatedRequest.allowAnonymous(
() -> front50Service.getV2PipelineTemplate(artifactId, "", ""));
}

return new ByteArrayInputStream(objectMapper.writeValueAsBytes(pipelineTemplate));
Expand Down

0 comments on commit aa95418

Please sign in to comment.