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
141e0155
Commit
141e0155
authored
Mar 22, 2018
by
Helgi Þorbjörnsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create index.yaml if missing when running repo index --merge
Fixes #3682
parent
48e70399
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
repo_index.go
cmd/helm/repo_index.go
+11
-3
repo_index_test.go
cmd/helm/repo_index_test.go
+30
-0
No files found.
cmd/helm/repo_index.go
View file @
141e0155
...
...
@@ -19,6 +19,7 @@ package main
import
(
"fmt"
"io"
"os"
"path/filepath"
"github.com/spf13/cobra"
...
...
@@ -86,9 +87,16 @@ func index(dir, url, mergeTo string) error {
return
err
}
if
mergeTo
!=
""
{
i2
,
err
:=
repo
.
LoadIndexFile
(
mergeTo
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Merge failed: %s"
,
err
)
// if index.yaml is missing then create an empty one to merge into
var
i2
*
repo
.
IndexFile
if
_
,
err
:=
os
.
Stat
(
mergeTo
);
os
.
IsNotExist
(
err
)
{
i2
=
repo
.
NewIndexFile
()
i2
.
WriteFile
(
mergeTo
,
0755
)
}
else
{
i2
,
err
=
repo
.
LoadIndexFile
(
mergeTo
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Merge failed: %s"
,
err
)
}
}
i
.
Merge
(
i2
)
}
...
...
cmd/helm/repo_index_test.go
View file @
141e0155
...
...
@@ -112,6 +112,36 @@ func TestRepoIndexCmd(t *testing.T) {
if
vs
[
0
]
.
Version
!=
expectedVersion
{
t
.
Errorf
(
"expected %q, got %q"
,
expectedVersion
,
vs
[
0
]
.
Version
)
}
// test that index.yaml gets generated on merge even when it doesn't exist
if
err
:=
os
.
Remove
(
destIndex
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
c
.
ParseFlags
([]
string
{
"--merge"
,
destIndex
})
if
err
:=
c
.
RunE
(
c
,
[]
string
{
dir
});
err
!=
nil
{
t
.
Error
(
err
)
}
_
,
err
=
repo
.
LoadIndexFile
(
destIndex
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// verify it didn't create an empty index.yaml and the merged happened
if
len
(
index
.
Entries
)
!=
2
{
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
)
}
}
func
linkOrCopy
(
old
,
new
string
)
error
{
...
...
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