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
415e52bf
Commit
415e52bf
authored
Feb 19, 2017
by
Amanda Cameron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for sub-directory scanning as in issue #1401
parent
a9f0be9b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
19 deletions
+61
-19
save.go
pkg/chartutil/save.go
+8
-0
chartrepo_test.go
pkg/repo/chartrepo_test.go
+11
-2
index.go
pkg/repo/index.go
+19
-2
index_test.go
pkg/repo/index_test.go
+23
-15
zarthal-1.0.0.tgz
pkg/repo/testdata/repository/universe/zarthal-1.0.0.tgz
+0
-0
No files found.
pkg/chartutil/save.go
View file @
415e52bf
...
...
@@ -115,6 +115,14 @@ func Save(c *chart.Chart, outDir string) (string, error) {
filename
:=
fmt
.
Sprintf
(
"%s-%s.tgz"
,
cfile
.
Name
,
cfile
.
Version
)
filename
=
filepath
.
Join
(
outDir
,
filename
)
if
stat
,
err
:=
os
.
Stat
(
filepath
.
Dir
(
filename
));
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
filename
),
0755
);
!
os
.
IsExist
(
err
)
{
return
""
,
err
}
}
else
if
!
stat
.
IsDir
()
{
return
""
,
fmt
.
Errorf
(
"is not a directory: %s"
,
filepath
.
Dir
(
filename
))
}
f
,
err
:=
os
.
Create
(
filename
)
if
err
!=
nil
{
return
""
,
err
...
...
pkg/repo/chartrepo_test.go
View file @
415e52bf
...
...
@@ -54,6 +54,7 @@ func TestLoadChartRepository(t *testing.T) {
filepath
.
Join
(
testRepository
,
"frobnitz-1.2.3.tgz"
),
filepath
.
Join
(
testRepository
,
"sprocket-1.1.0.tgz"
),
filepath
.
Join
(
testRepository
,
"sprocket-1.2.0.tgz"
),
filepath
.
Join
(
testRepository
,
"universe/zarthal-1.0.0.tgz"
),
}
if
r
.
Config
.
Name
!=
testRepository
{
...
...
@@ -118,8 +119,8 @@ func verifyIndex(t *testing.T, actual *IndexFile) {
}
entries
:=
actual
.
Entries
if
numEntries
:=
len
(
entries
);
numEntries
!=
2
{
t
.
Errorf
(
"Expected
2
charts to be listed in index file but got %v"
,
numEntries
)
if
numEntries
:=
len
(
entries
);
numEntries
!=
3
{
t
.
Errorf
(
"Expected
3
charts to be listed in index file but got %v"
,
numEntries
)
}
expects
:=
map
[
string
]
ChartVersions
{
...
...
@@ -145,6 +146,14 @@ func verifyIndex(t *testing.T, actual *IndexFile) {
},
},
},
"zarthal"
:
{
{
Metadata
:
&
chart
.
Metadata
{
Name
:
"zarthal"
,
Version
:
"1.0.0"
,
},
},
},
}
for
name
,
versions
:=
range
expects
{
...
...
pkg/repo/index.go
View file @
415e52bf
...
...
@@ -231,9 +231,26 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
if
err
!=
nil
{
return
nil
,
err
}
moreArchives
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
dir
,
"**/*.tgz"
))
if
err
!=
nil
{
return
nil
,
err
}
archives
=
append
(
archives
,
moreArchives
...
)
index
:=
NewIndexFile
()
for
_
,
arch
:=
range
archives
{
fname
:=
filepath
.
Base
(
arch
)
fname
,
err
:=
filepath
.
Rel
(
dir
,
arch
)
if
err
!=
nil
{
return
index
,
err
}
var
parentDir
string
parentDir
,
fname
=
filepath
.
Split
(
fname
)
parentURL
,
err
:=
urlutil
.
URLJoin
(
baseURL
,
parentDir
)
if
err
!=
nil
{
parentURL
=
filepath
.
Join
(
baseURL
,
parentDir
)
}
c
,
err
:=
chartutil
.
Load
(
arch
)
if
err
!=
nil
{
// Assume this is not a chart.
...
...
@@ -243,7 +260,7 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
if
err
!=
nil
{
return
index
,
err
}
index
.
Add
(
c
.
Metadata
,
fname
,
base
URL
,
hash
)
index
.
Add
(
c
.
Metadata
,
fname
,
parent
URL
,
hash
)
}
return
index
,
nil
}
...
...
pkg/repo/index_test.go
View file @
415e52bf
...
...
@@ -278,27 +278,35 @@ func TestIndexDirectory(t *testing.T) {
t
.
Fatal
(
err
)
}
if
l
:=
len
(
index
.
Entries
);
l
!=
2
{
t
.
Fatalf
(
"Expected
2
entries, got %d"
,
l
)
if
l
:=
len
(
index
.
Entries
);
l
!=
3
{
t
.
Fatalf
(
"Expected
3
entries, got %d"
,
l
)
}
// Other things test the entry generation more thoroughly. We just test a
// few fields.
cname
:=
"frobnitz"
frobs
,
ok
:=
index
.
Entries
[
cname
]
if
!
ok
{
t
.
Fatalf
(
"Could not read chart %s"
,
cname
)
}
frob
:=
frobs
[
0
]
if
len
(
frob
.
Digest
)
==
0
{
t
.
Errorf
(
"Missing digest of file %s."
,
frob
.
Name
)
corpus
:=
[]
struct
{
chartName
,
downloadLink
string
}{
{
"frobnitz"
,
"http://localhost:8080/frobnitz-1.2.3.tgz"
},
{
"zarthal"
,
"http://localhost:8080/universe/zarthal-1.0.0.tgz"
},
}
if
frob
.
URLs
[
0
]
!=
"http://localhost:8080/frobnitz-1.2.3.tgz"
{
t
.
Errorf
(
"Unexpected URLs: %v"
,
frob
.
URLs
)
}
if
frob
.
Name
!=
"frobnitz"
{
t
.
Errorf
(
"Expected frobnitz, got %q"
,
frob
.
Name
)
for
_
,
test
:=
range
corpus
{
cname
:=
test
.
chartName
frobs
,
ok
:=
index
.
Entries
[
cname
]
if
!
ok
{
t
.
Fatalf
(
"Could not read chart %s"
,
cname
)
}
frob
:=
frobs
[
0
]
if
len
(
frob
.
Digest
)
==
0
{
t
.
Errorf
(
"Missing digest of file %s."
,
frob
.
Name
)
}
if
frob
.
URLs
[
0
]
!=
test
.
downloadLink
{
t
.
Errorf
(
"Unexpected URLs: %v"
,
frob
.
URLs
)
}
if
frob
.
Name
!=
cname
{
t
.
Errorf
(
"Expected %q, got %q"
,
cname
,
frob
.
Name
)
}
}
}
...
...
pkg/repo/testdata/repository/universe/zarthal-1.0.0.tgz
0 → 100644
View file @
415e52bf
File added
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