-
Notifications
You must be signed in to change notification settings - Fork 11
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
UPSTREAM: <carry>: Update ArtifactView enum to allow pipelines artifacts api to have optional content disposition #118
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -41,6 +41,7 @@ type ObjectStoreInterface interface { | |||||
GetFromYamlFile(o interface{}, filePath string) error | ||||||
GetPipelineKey(pipelineId string) string | ||||||
GetSignedUrl(bucketConfig *objectstore.Config, secret *v1.Secret, expirySeconds time.Duration, artifactURI string) (string, error) | ||||||
GetSignedUrlWithoutContentDisposition(bucketConfig *objectstore.Config, secret *v1.Secret, expirySeconds time.Duration, artifactURI string) (string, error) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we make this more configurable? For example, the following would allow further customizations without having to add a new method for each variation.
Suggested change
|
||||||
GetObjectSize(bucketConfig *objectstore.Config, secret *v1.Secret, artifactURI string) (int64, error) | ||||||
} | ||||||
|
||||||
|
@@ -143,6 +144,27 @@ func (m *MinioObjectStore) GetSignedUrl(bucketConfig *objectstore.Config, secret | |||||
return "", err | ||||||
} | ||||||
reqParams := make(url.Values) | ||||||
reqParams.Set("response-content-disposition", "attachment; filename=\""+key+"\"") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you go with my comment of having the method This will reduce code duplication. |
||||||
signedUrl, err := s3Client.Presign("GET", bucketConfig.BucketName, key, expirySeconds, reqParams) | ||||||
if err != nil { | ||||||
return "", util.Wrap(err, "Failed to generate signed url") | ||||||
} | ||||||
|
||||||
return signedUrl.String(), nil | ||||||
} | ||||||
|
||||||
func (m *MinioObjectStore) GetSignedUrlWithoutContentDisposition(bucketConfig *objectstore.Config, secret *v1.Secret, expirySeconds time.Duration, artifactURI string) (string, error) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the plan for test coverage of this method since the tests I see are mocking this out? Is this a separate task for an integration test? |
||||||
s3Client, err := buildClientFromConfig(bucketConfig, secret) | ||||||
if err != nil { | ||||||
return "", err | ||||||
} | ||||||
|
||||||
key, err := objectstore.ArtifactKeyFromURI(artifactURI) | ||||||
if err != nil { | ||||||
return "", err | ||||||
} | ||||||
reqParams := make(url.Values) | ||||||
reqParams.Set("response-content-disposition", "inline") | ||||||
signedUrl, err := s3Client.Presign("GET", bucketConfig.BucketName, key, expirySeconds, reqParams) | ||||||
if err != nil { | ||||||
return "", util.Wrap(err, "Failed to generate signed url") | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional, but rather than a bool, you could replace
includeShareUrl
andincludeRenderUrl
with a single argument of typeGetArtifactRequest_ArtifactView
since it doesn't seem like this will ever need to generate more than one. This would allow for additional options in the future.