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
223c89e6
Commit
223c89e6
authored
Apr 14, 2018
by
Arash Deshmeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm): support removing multiple repositories with repo remove command
Signed-off-by:
Arash Deshmeh
<
adeshmeh@ca.ibm.com
>
parent
506ed05b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
5 deletions
+74
-5
repo_remove.go
cmd/helm/repo_remove.go
+10
-5
repo_remove_test.go
cmd/helm/repo_remove_test.go
+64
-0
No files found.
cmd/helm/repo_remove.go
View file @
223c89e6
...
...
@@ -41,13 +41,18 @@ func newRepoRemoveCmd(out io.Writer) *cobra.Command {
Aliases
:
[]
string
{
"rm"
},
Short
:
"remove a chart repository"
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
err
:=
checkArgsLength
(
len
(
args
),
"name of chart repository"
);
err
!=
nil
{
return
err
if
len
(
args
)
==
0
{
return
fmt
.
Errorf
(
"need at least one argument, name of chart repository"
)
}
remove
.
name
=
args
[
0
]
remove
.
home
=
settings
.
Home
return
remove
.
run
()
remove
.
home
=
settings
.
Home
for
i
:=
0
;
i
<
len
(
args
);
i
++
{
remove
.
name
=
args
[
i
]
if
err
:=
remove
.
run
();
err
!=
nil
{
return
err
}
}
return
nil
},
}
...
...
cmd/helm/repo_remove_test.go
View file @
223c89e6
...
...
@@ -18,6 +18,7 @@ package main
import
(
"bytes"
"io/ioutil"
"os"
"strings"
"testing"
...
...
@@ -79,3 +80,66 @@ func TestRepoRemove(t *testing.T) {
t
.
Errorf
(
"%s was not successfully removed from repositories list"
,
testName
)
}
}
func
TestRepoRemove_NoArguments
(
t
*
testing
.
T
)
{
cmd
:=
newRepoRemoveCmd
(
ioutil
.
Discard
)
if
err
:=
cmd
.
RunE
(
cmd
,
[]
string
{});
err
==
nil
{
t
.
Errorf
(
"Expected an error since no repo names were provided"
)
}
}
func
TestRepoRemove_MultipleRepos
(
t
*
testing
.
T
)
{
ts
,
thome
,
err
:=
repotest
.
NewTempServer
(
"testdata/testserver/*.*"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
hh
:=
helmpath
.
Home
(
thome
)
cleanup
:=
resetEnv
()
defer
func
()
{
ts
.
Stop
()
os
.
RemoveAll
(
thome
.
String
())
cleanup
()
}()
if
err
:=
ensureTestHome
(
hh
,
t
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
settings
.
Home
=
thome
repoFoo
:=
testName
+
"foo"
repoBar
:=
testName
+
"bar"
if
err
:=
addRepository
(
repoFoo
,
ts
.
URL
(),
""
,
""
,
hh
,
""
,
""
,
""
,
true
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
addRepository
(
repoBar
,
ts
.
URL
(),
""
,
""
,
hh
,
""
,
""
,
""
,
true
);
err
!=
nil
{
t
.
Error
(
err
)
}
b
:=
bytes
.
NewBuffer
(
nil
)
cmd
:=
newRepoRemoveCmd
(
b
)
if
err
:=
cmd
.
RunE
(
cmd
,
[]
string
{
repoFoo
,
repoBar
});
err
!=
nil
{
t
.
Error
(
err
)
}
if
!
strings
.
Contains
(
b
.
String
(),
repoFoo
)
{
t
.
Errorf
(
"Expected %q in output, found: %q"
,
repoFoo
,
b
.
String
())
}
if
!
strings
.
Contains
(
b
.
String
(),
repoBar
)
{
t
.
Errorf
(
"Expected %q in output, found: %q"
,
repoBar
,
b
.
String
())
}
f
,
err
:=
repo
.
LoadRepositoriesFile
(
hh
.
RepositoryFile
())
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
f
.
Has
(
repoFoo
)
{
t
.
Errorf
(
"%s was not successfully removed from repositories list"
,
repoFoo
)
}
if
f
.
Has
(
repoBar
)
{
t
.
Errorf
(
"%s was not successfully removed from repositories list"
,
repoBar
)
}
}
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