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
ee7fe7c7
Commit
ee7fe7c7
authored
Oct 19, 2016
by
Adnan Abdulhussein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(repo): ensure index generates in the right order
parent
313a9dc4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
17 deletions
+57
-17
repo_index.go
cmd/helm/repo_index.go
+1
-0
repo_index_test.go
cmd/helm/repo_index_test.go
+33
-3
compressedchart-0.2.0.tgz
cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz
+0
-0
compressedchart-0.3.0.tgz
cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz
+0
-0
index.go
pkg/repo/index.go
+4
-1
index_test.go
pkg/repo/index_test.go
+6
-6
repo_test.go
pkg/repo/repo_test.go
+7
-1
local-index.yaml
pkg/repo/testdata/local-index.yaml
+6
-6
sprocket-1.1.0.tgz
pkg/repo/testdata/repository/sprocket-1.1.0.tgz
+0
-0
No files found.
cmd/helm/repo_index.go
View file @
ee7fe7c7
...
...
@@ -94,5 +94,6 @@ func index(dir, url, mergeTo string) error {
}
i
.
Merge
(
i2
)
}
i
.
SortEntries
()
return
i
.
WriteFile
(
out
,
0755
)
}
cmd/helm/repo_index_test.go
View file @
ee7fe7c7
...
...
@@ -38,6 +38,10 @@ func TestRepoIndexCmd(t *testing.T) {
if
err
:=
os
.
Link
(
"testdata/testcharts/compressedchart-0.1.0.tgz"
,
comp
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
comp2
:=
filepath
.
Join
(
dir
,
"compressedchart-0.2.0.tgz"
)
if
err
:=
os
.
Link
(
"testdata/testcharts/compressedchart-0.2.0.tgz"
,
comp2
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
buf
:=
bytes
.
NewBuffer
(
nil
)
c
:=
newRepoIndexCmd
(
buf
)
...
...
@@ -57,16 +61,32 @@ func TestRepoIndexCmd(t *testing.T) {
t
.
Errorf
(
"expected 1 entry, got %d: %#v"
,
len
(
index
.
Entries
),
index
.
Entries
)
}
vs
:=
index
.
Entries
[
"compressedchart"
]
if
len
(
vs
)
!=
2
{
t
.
Errorf
(
"expected 2 versions, got %d: %#v"
,
len
(
vs
),
vs
)
}
expectedVersion
:=
"0.2.0"
if
vs
[
0
]
.
Version
!=
expectedVersion
{
t
.
Errorf
(
"expected %q, got %q"
,
expectedVersion
,
vs
[
0
]
.
Version
)
}
// Test with `--merge`
// Remove first
chart
.
// Remove first
two charts
.
if
err
:=
os
.
Remove
(
comp
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Add another chart.
if
err
:=
os
.
Remove
(
comp2
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Add a new chart and a new version of an existing chart
if
err
:=
os
.
Link
(
"testdata/testcharts/reqtest-0.1.0.tgz"
,
filepath
.
Join
(
dir
,
"reqtest-0.1.0.tgz"
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
os
.
Link
(
"testdata/testcharts/compressedchart-0.3.0.tgz"
,
filepath
.
Join
(
dir
,
"compressedchart-0.3.0.tgz"
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
c
.
ParseFlags
([]
string
{
"--merge"
,
destIndex
})
if
err
:=
c
.
RunE
(
c
,
[]
string
{
dir
});
err
!=
nil
{
...
...
@@ -79,6 +99,16 @@ func TestRepoIndexCmd(t *testing.T) {
}
if
len
(
index
.
Entries
)
!=
2
{
t
.
Errorf
(
"expected 2 entry, got %d: %#v"
,
len
(
index
.
Entries
),
index
.
Entries
)
t
.
Errorf
(
"expected 2 entries, got %d: %#v"
,
len
(
index
.
Entries
),
index
.
Entries
)
}
vs
=
index
.
Entries
[
"compressedchart"
]
if
len
(
vs
)
!=
3
{
t
.
Errorf
(
"expected 3 versions, got %d: %#v"
,
len
(
vs
),
vs
)
}
expectedVersion
=
"0.3.0"
if
vs
[
0
]
.
Version
!=
expectedVersion
{
t
.
Errorf
(
"expected %q, got %q"
,
expectedVersion
,
vs
[
0
]
.
Version
)
}
}
cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz
0 → 100644
View file @
ee7fe7c7
File added
cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz
0 → 100644
View file @
ee7fe7c7
File added
pkg/repo/index.go
View file @
ee7fe7c7
...
...
@@ -95,6 +95,7 @@ func NewIndexFile() *IndexFile {
}
// Add adds a file to the index
// This can leave the index in an unsorted state
func
(
i
IndexFile
)
Add
(
md
*
chart
.
Metadata
,
filename
,
baseURL
,
digest
string
)
{
u
:=
filename
if
baseURL
!=
""
{
...
...
@@ -176,6 +177,8 @@ func (i IndexFile) WriteFile(dest string, mode os.FileMode) error {
//
// If one of the entries in the given index does _not_ already exist, it is added.
// In all other cases, the existing record is preserved.
//
// This can leave the index in an unsorted state
func
(
i
*
IndexFile
)
Merge
(
f
*
IndexFile
)
{
for
_
,
cvs
:=
range
f
.
Entries
{
for
_
,
cv
:=
range
cvs
{
...
...
@@ -202,7 +205,7 @@ type ChartVersion struct {
//
// It indexes only charts that have been packaged (*.tgz).
//
//
It writes the results to dir/index.yaml.
//
The index returned will be in an unsorted state
func
IndexDirectory
(
dir
,
baseURL
string
)
(
*
IndexFile
,
error
)
{
archives
,
err
:=
filepath
.
Glob
(
filepath
.
Join
(
dir
,
"*.tgz"
))
if
err
!=
nil
{
...
...
pkg/repo/index_test.go
View file @
ee7fe7c7
...
...
@@ -197,12 +197,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata
:
&
chart
.
Metadata
{
Name
:
"nginx"
,
Description
:
"string"
,
Version
:
"0.
1
.0"
,
Version
:
"0.
2
.0"
,
Keywords
:
[]
string
{
"popular"
,
"web server"
,
"proxy"
},
Home
:
"https://github.com/something"
,
Home
:
"https://github.com/something
/else
"
,
},
URLs
:
[]
string
{
"http://storage.googleapis.com/kubernetes-charts/nginx-0.
1
.0.tgz"
,
"http://storage.googleapis.com/kubernetes-charts/nginx-0.
2
.0.tgz"
,
},
Digest
:
"sha256:1234567890abcdef"
,
},
...
...
@@ -210,12 +210,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata
:
&
chart
.
Metadata
{
Name
:
"nginx"
,
Description
:
"string"
,
Version
:
"0.
2
.0"
,
Version
:
"0.
1
.0"
,
Keywords
:
[]
string
{
"popular"
,
"web server"
,
"proxy"
},
Home
:
"https://github.com/something
/else
"
,
Home
:
"https://github.com/something"
,
},
URLs
:
[]
string
{
"http://storage.googleapis.com/kubernetes-charts/nginx-0.
2
.0.tgz"
,
"http://storage.googleapis.com/kubernetes-charts/nginx-0.
1
.0.tgz"
,
},
Digest
:
"sha256:1234567890abcdef"
,
},
...
...
pkg/repo/repo_test.go
View file @
ee7fe7c7
...
...
@@ -133,7 +133,7 @@ func TestLoadChartRepository(t *testing.T) {
t
.
Errorf
(
"Problem loading chart repository from %s: %v"
,
testRepository
,
err
)
}
paths
:=
[]
string
{
filepath
.
Join
(
testRepository
,
"frobnitz-1.2.3.tgz"
),
filepath
.
Join
(
testRepository
,
"sprocket-1.2.0.tgz"
)}
paths
:=
[]
string
{
filepath
.
Join
(
testRepository
,
"frobnitz-1.2.3.tgz"
),
filepath
.
Join
(
testRepository
,
"sprocket-1.
1.0.tgz"
),
filepath
.
Join
(
testRepository
,
"sprocket-1.
2.0.tgz"
)}
if
cr
.
RootPath
!=
testRepository
{
t
.
Errorf
(
"Expected %s as RootPath but got %s"
,
testRepository
,
cr
.
RootPath
)
...
...
@@ -211,6 +211,12 @@ func verifyIndex(t *testing.T, actual *IndexFile) {
Version
:
"1.2.0"
,
},
},
{
Metadata
:
&
chart
.
Metadata
{
Name
:
"sprocket"
,
Version
:
"1.1.0"
,
},
},
},
}
...
...
pkg/repo/testdata/local-index.yaml
View file @
ee7fe7c7
...
...
@@ -2,22 +2,22 @@ apiVersion: v1
entries
:
nginx
:
-
urls
:
-
http://storage.googleapis.com/kubernetes-charts/nginx-0.
1
.0.tgz
-
http://storage.googleapis.com/kubernetes-charts/nginx-0.
2
.0.tgz
name
:
nginx
description
:
string
version
:
0.
1
.0
home
:
https://github.com/something
version
:
0.
2
.0
home
:
https://github.com/something
/else
digest
:
"
sha256:1234567890abcdef"
keywords
:
-
popular
-
web server
-
proxy
-
urls
:
-
http://storage.googleapis.com/kubernetes-charts/nginx-0.
2
.0.tgz
-
http://storage.googleapis.com/kubernetes-charts/nginx-0.
1
.0.tgz
name
:
nginx
description
:
string
version
:
0.
2
.0
home
:
https://github.com/something
/else
version
:
0.
1
.0
home
:
https://github.com/something
digest
:
"
sha256:1234567890abcdef"
keywords
:
-
popular
...
...
pkg/repo/testdata/repository/sprocket-1.1.0.tgz
0 → 100644
View file @
ee7fe7c7
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