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
2234dc89
Commit
2234dc89
authored
May 20, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm): handle update case on index function
parent
7bd739c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
repo.go
pkg/repo/repo.go
+10
-1
repo_test.go
pkg/repo/repo_test.go
+19
-2
No files found.
pkg/repo/repo.go
View file @
2234dc89
...
...
@@ -115,6 +115,7 @@ func (r *ChartRepository) Index() error {
if
err
!=
nil
{
return
err
}
chartfile
:=
ch
.
Chartfile
()
hash
,
err
:=
generateDigest
(
path
)
if
err
!=
nil
{
...
...
@@ -126,7 +127,15 @@ func (r *ChartRepository) Index() error {
r
.
IndexFile
.
Entries
=
make
(
map
[
string
]
*
ChartRef
)
}
entry
:=
&
ChartRef
{
Chartfile
:
*
chartfile
,
Name
:
chartfile
.
Name
,
URL
:
r
.
URL
,
Created
:
time
.
Now
()
.
UTC
()
.
String
(),
Digest
:
hash
,
Removed
:
false
}
ref
,
ok
:=
r
.
IndexFile
.
Entries
[
key
]
var
created
string
if
ok
&&
ref
.
Created
!=
""
{
created
=
ref
.
Created
}
else
{
created
=
time
.
Now
()
.
UTC
()
.
String
()
}
entry
:=
&
ChartRef
{
Chartfile
:
*
chartfile
,
Name
:
chartfile
.
Name
,
URL
:
r
.
URL
,
Created
:
created
,
Digest
:
hash
,
Removed
:
false
}
r
.
IndexFile
.
Entries
[
key
]
=
entry
...
...
pkg/repo/repo_test.go
View file @
2234dc89
...
...
@@ -107,6 +107,7 @@ func TestIndex(t *testing.T) {
tempIndexPath
:=
filepath
.
Join
(
testRepository
,
indexPath
)
actual
,
err
:=
LoadIndexFile
(
tempIndexPath
)
defer
os
.
Remove
(
tempIndexPath
)
// clean up
if
err
!=
nil
{
t
.
Errorf
(
"Error loading index file %v"
,
err
)
}
...
...
@@ -117,6 +118,7 @@ func TestIndex(t *testing.T) {
t
.
Errorf
(
"Expected 2 charts to be listed in index file but got %v"
,
numEntries
)
}
timestamps
:=
make
(
map
[
string
]
string
)
var
empty
time
.
Time
for
chartName
,
details
:=
range
entries
{
if
details
==
nil
{
...
...
@@ -126,13 +128,28 @@ func TestIndex(t *testing.T) {
if
details
.
Created
==
empty
.
String
()
{
t
.
Errorf
(
"Created timestamp under %s chart entry is nil"
,
chartName
)
}
timestamps
[
chartName
]
=
details
.
Created
if
details
.
Digest
==
""
{
t
.
Errorf
(
"Digest was not set for %s"
,
chartName
)
}
}
//TODO: test update case
if
err
=
cr
.
Index
();
err
!=
nil
{
t
.
Errorf
(
"Error performing index the second time: %v
\n
"
,
err
)
}
second
,
err
:=
LoadIndexFile
(
tempIndexPath
)
if
err
!=
nil
{
t
.
Errorf
(
"Error loading index file second time: %#v
\n
"
,
err
)
}
os
.
Remove
(
tempIndexPath
)
// clean up
for
chart
,
created
:=
range
timestamps
{
v
,
ok
:=
second
.
Entries
[
chart
]
if
!
ok
{
t
.
Errorf
(
"Expected %s chart entry in index file but did not find it"
,
chart
)
}
if
v
.
Created
!=
created
{
t
.
Errorf
(
"Expected Created timestamp to be %s, but got %s for chart %s"
,
created
,
v
.
Created
,
chart
)
}
}
}
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