-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package main | ||
|
||
import "github.com/hypnoglow/helm-s3/internal/awsutil" | ||
|
||
type printer interface { | ||
Printf(format string, v ...interface{}) | ||
PrintErrf(format string, i ...interface{}) | ||
} | ||
|
||
// escapeIfRelative escapes chart filename if it is indexed as relative. | ||
// | ||
// Note: we escape filename only if 'relative' is set for a few reasons: | ||
// - Full URLs don't need to be escaped because with full URLs in the index | ||
// the charts can be downloaded only with this plugin; | ||
// - Even if we escape the filename here, the code in Index.Add and | ||
// Index.AddOrReplace (in particular, the call to urlutil.URLJoin) will | ||
// break the URL, e.g. the escaped filename "petstore-1.0.0%2B102.tgz" | ||
// with the "s3://example-bucket" baseURL will become | ||
// "s3://example-bucket/petstore-1.0.0%252B102.tgz". | ||
// So if we ever decide to escape, we need to fix this. | ||
func escapeIfRelative(filename string, relative bool) string { | ||
if !relative { | ||
return filename | ||
} | ||
|
||
return awsutil.EscapePath(filename) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package awsutil | ||
|
||
import "github.com/aws/aws-sdk-go/private/protocol/rest" | ||
|
||
// EscapePath escapes URL path according to AWS escaping rules. | ||
// | ||
// This func can be used to escape S3 object keys for HTTP access. | ||
func EscapePath(path string) string { | ||
return rest.EscapePath(path, true) | ||
} |