Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(logs): allow anonymous front50 artifact fetching #5066

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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