Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
b5f1ad49
Commit
b5f1ad49
authored
Mar 21, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle storage object urls in Locator
parent
49795ad9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
+56
-6
locator.go
pkg/chart/locator.go
+42
-6
locator_test.go
pkg/chart/locator_test.go
+14
-0
No files found.
pkg/chart/locator.go
View file @
b5f1ad49
...
...
@@ -34,6 +34,8 @@ var ErrRemote = errors.New("cannot use remote Locator as local")
const
(
SchemeHTTP
=
"http"
SchemeHTTPS
=
"https"
SchemeGS
=
"gs"
SchemeS3
=
"s3"
SchemeHelm
=
"helm"
SchemeFile
=
"file"
)
...
...
@@ -85,6 +87,7 @@ func Parse(path string) (*Locator, error) {
if
len
(
parts
)
<
3
{
return
nil
,
fmt
.
Errorf
(
"both bucket and chart name are required in %s: %s"
,
path
,
u
.
Path
)
}
// Need to parse opaque data into bucket and chart.
return
&
Locator
{
Scheme
:
u
.
Scheme
,
...
...
@@ -115,6 +118,26 @@ func Parse(path string) (*Locator, error) {
Version
:
version
,
original
:
path
,
},
nil
case
SchemeGS
,
SchemeS3
:
// Long name
parts
:=
strings
.
SplitN
(
u
.
Path
,
"/"
,
2
)
if
len
(
parts
)
<
2
{
return
nil
,
fmt
.
Errorf
(
"chart name is required in %s"
,
path
)
}
name
,
version
,
err
:=
parseTarName
(
parts
[
1
])
if
err
!=
nil
{
return
nil
,
err
}
return
&
Locator
{
Scheme
:
u
.
Scheme
,
Host
:
u
.
Scheme
,
Bucket
:
u
.
Host
,
Name
:
name
,
Version
:
version
,
original
:
path
,
},
nil
case
SchemeFile
:
return
&
Locator
{
LocalRef
:
u
.
Path
,
...
...
@@ -153,6 +176,7 @@ func (u *Locator) Short() (string, error) {
if
u
.
IsLocal
()
{
return
""
,
ErrLocal
}
fname
:=
fmt
.
Sprintf
(
"%s/%s/%s"
,
u
.
Host
,
u
.
Bucket
,
u
.
Name
)
return
(
&
url
.
URL
{
Scheme
:
SchemeHelm
,
...
...
@@ -171,18 +195,30 @@ func (u *Locator) Long(secure bool) (string, error) {
return
""
,
ErrLocal
}
scheme
:=
SchemeHTTPS
if
!
secure
{
scheme
=
SchemeHTTP
scheme
:=
u
.
Scheme
host
:=
u
.
Host
switch
scheme
{
case
SchemeGS
,
SchemeS3
:
host
=
""
case
SchemeHTTP
,
SchemeHTTPS
,
SchemeHelm
:
switch
host
{
case
SchemeGS
,
SchemeS3
:
scheme
=
host
host
=
""
default
:
scheme
=
SchemeHTTPS
if
!
secure
{
scheme
=
SchemeHTTP
}
}
}
fname
:=
fmt
.
Sprintf
(
"%s/%s-%s.tgz"
,
u
.
Bucket
,
u
.
Name
,
u
.
Version
)
fname
:=
fmt
.
Sprintf
(
"%s/%s-%s.tgz"
,
u
.
Bucket
,
u
.
Name
,
u
.
Version
)
return
(
&
url
.
URL
{
Scheme
:
scheme
,
Host
:
u
.
H
ost
,
Host
:
h
ost
,
Path
:
fname
,
})
.
String
(),
nil
}
// parseTarName parses a long-form tarfile name.
...
...
pkg/chart/locator_test.go
View file @
b5f1ad49
...
...
@@ -64,8 +64,12 @@ func TestShort(t *testing.T) {
tests
:=
map
[
string
]
string
{
"https://example.com/foo/bar-1.2.3.tgz"
:
"helm:example.com/foo/bar#1.2.3"
,
"http://example.com/foo/bar-1.2.3.tgz"
:
"helm:example.com/foo/bar#1.2.3"
,
"gs://foo/bar-1.2.3.tgz"
:
"helm:gs/foo/bar#1.2.3"
,
"s3://foo/bar-1.2.3.tgz"
:
"helm:s3/foo/bar#1.2.3"
,
"helm:example.com/foo/bar#1.2.3"
:
"helm:example.com/foo/bar#1.2.3"
,
"helm:example.com/foo/bar#>1.2.3"
:
"helm:example.com/foo/bar#%3E1.2.3"
,
"helm:gs/foo/bar#1.2.3"
:
"helm:gs/foo/bar#1.2.3"
,
"helm:s3/foo/bar#>1.2.3"
:
"helm:s3/foo/bar#%3E1.2.3"
,
}
for
start
,
expect
:=
range
tests
{
...
...
@@ -74,6 +78,9 @@ func TestShort(t *testing.T) {
t
.
Errorf
(
"Failed to parse: %s"
,
err
)
continue
}
t
.
Logf
(
"Parsed reference %s into locator %#v"
,
start
,
u
)
short
,
err
:=
u
.
Short
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to generate short: %s"
,
err
)
...
...
@@ -103,8 +110,12 @@ func TestLong(t *testing.T) {
tests
:=
map
[
string
]
string
{
"https://example.com/foo/bar-1.2.3.tgz"
:
"https://example.com/foo/bar-1.2.3.tgz"
,
"http://example.com/foo/bar-1.2.3.tgz"
:
"https://example.com/foo/bar-1.2.3.tgz"
,
"gs://foo/bar-1.2.3.tgz"
:
"gs://foo/bar-1.2.3.tgz"
,
"s3://foo/bar-1.2.3.tgz"
:
"s3://foo/bar-1.2.3.tgz"
,
"helm:example.com/foo/bar#1.2.3"
:
"https://example.com/foo/bar-1.2.3.tgz"
,
"helm:example.com/foo/bar#>1.2.3"
:
"https://example.com/foo/bar-%3E1.2.3.tgz"
,
"helm:gs/foo/bar#1.2.3"
:
"gs://foo/bar-1.2.3.tgz"
,
"helm:s3/foo/bar#>1.2.3"
:
"s3://foo/bar-%3E1.2.3.tgz"
,
}
for
start
,
expect
:=
range
tests
{
...
...
@@ -114,6 +125,9 @@ func TestLong(t *testing.T) {
t
.
Errorf
(
"Failed to parse: %s"
,
err
)
continue
}
t
.
Logf
(
"Parsed reference %s into locator %#v"
,
start
,
u
)
long
,
err
:=
u
.
Long
(
true
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to generate long: %s"
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment