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
3e5642a4
Commit
3e5642a4
authored
May 09, 2017
by
Taylor Thomas
Committed by
GitHub
May 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2400 from sushilkm/issues/2384
Fixes various issues related to plugin command
parents
5c227bff
084bbfa2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
10 deletions
+67
-10
plugin_remove.go
cmd/helm/plugin_remove.go
+13
-5
installer.go
pkg/plugin/installer/installer.go
+4
-0
local_installer_test.go
pkg/plugin/installer/local_installer_test.go
+2
-2
vcs_installer.go
pkg/plugin/installer/vcs_installer.go
+3
-1
vcs_installer_test.go
pkg/plugin/installer/vcs_installer_test.go
+45
-2
No files found.
cmd/helm/plugin_remove.go
View file @
3e5642a4
...
@@ -16,9 +16,11 @@ limitations under the License.
...
@@ -16,9 +16,11 @@ limitations under the License.
package
main
package
main
import
(
import
(
"errors"
"fmt"
"fmt"
"io"
"io"
"os"
"os"
"strings"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/plugin"
"k8s.io/helm/pkg/plugin"
...
@@ -48,8 +50,8 @@ func newPluginRemoveCmd(out io.Writer) *cobra.Command {
...
@@ -48,8 +50,8 @@ func newPluginRemoveCmd(out io.Writer) *cobra.Command {
}
}
func
(
pcmd
*
pluginRemoveCmd
)
complete
(
args
[]
string
)
error
{
func
(
pcmd
*
pluginRemoveCmd
)
complete
(
args
[]
string
)
error
{
if
err
:=
checkArgsLength
(
len
(
args
),
"plugin"
);
err
!=
nil
{
if
len
(
args
)
==
0
{
return
err
return
err
ors
.
New
(
"please provide plugin name to remove"
)
}
}
pcmd
.
names
=
args
pcmd
.
names
=
args
pcmd
.
home
=
settings
.
Home
pcmd
.
home
=
settings
.
Home
...
@@ -63,15 +65,21 @@ func (pcmd *pluginRemoveCmd) run() error {
...
@@ -63,15 +65,21 @@ func (pcmd *pluginRemoveCmd) run() error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
var
errorPlugins
[]
string
for
_
,
name
:=
range
pcmd
.
names
{
for
_
,
name
:=
range
pcmd
.
names
{
if
found
:=
findPlugin
(
plugins
,
name
);
found
!=
nil
{
if
found
:=
findPlugin
(
plugins
,
name
);
found
!=
nil
{
if
err
:=
removePlugin
(
found
,
pcmd
.
home
);
err
!=
nil
{
if
err
:=
removePlugin
(
found
,
pcmd
.
home
);
err
!=
nil
{
return
err
errorPlugins
=
append
(
errorPlugins
,
fmt
.
Sprintf
(
"Failed to remove plugin %s, got error (%v)"
,
name
,
err
))
}
else
{
fmt
.
Fprintf
(
pcmd
.
out
,
"Removed plugin: %s
\n
"
,
name
)
}
}
fmt
.
Fprintf
(
pcmd
.
out
,
"Removed plugin: %s
\n
"
,
name
)
}
else
{
errorPlugins
=
append
(
errorPlugins
,
fmt
.
Sprintf
(
"Plugin: %s not found"
,
name
))
}
}
}
}
if
len
(
errorPlugins
)
>
0
{
return
fmt
.
Errorf
(
strings
.
Join
(
errorPlugins
,
"
\n
"
))
}
return
nil
return
nil
}
}
...
...
pkg/plugin/installer/installer.go
View file @
3e5642a4
...
@@ -40,6 +40,10 @@ type Installer interface {
...
@@ -40,6 +40,10 @@ type Installer interface {
// Install installs a plugin to $HELM_HOME.
// Install installs a plugin to $HELM_HOME.
func
Install
(
i
Installer
)
error
{
func
Install
(
i
Installer
)
error
{
if
_
,
pathErr
:=
os
.
Stat
(
i
.
Path
());
!
os
.
IsNotExist
(
pathErr
)
{
return
errors
.
New
(
"plugin already exists"
)
}
return
i
.
Install
()
return
i
.
Install
()
}
}
...
...
pkg/plugin/installer/local_installer_test.go
View file @
3e5642a4
...
@@ -31,7 +31,7 @@ func TestLocalInstaller(t *testing.T) {
...
@@ -31,7 +31,7 @@ func TestLocalInstaller(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
os
.
Remove
(
hh
)
defer
os
.
Remove
All
(
hh
)
home
:=
helmpath
.
Home
(
hh
)
home
:=
helmpath
.
Home
(
hh
)
if
err
:=
os
.
MkdirAll
(
home
.
Plugins
(),
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
home
.
Plugins
(),
0755
);
err
!=
nil
{
...
@@ -43,7 +43,7 @@ func TestLocalInstaller(t *testing.T) {
...
@@ -43,7 +43,7 @@ func TestLocalInstaller(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
os
.
Remove
(
tdir
)
defer
os
.
Remove
All
(
tdir
)
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
tdir
,
"plugin.yaml"
),
[]
byte
{},
0644
);
err
!=
nil
{
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
tdir
,
"plugin.yaml"
),
[]
byte
{},
0644
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
pkg/plugin/installer/vcs_installer.go
View file @
3e5642a4
...
@@ -16,6 +16,7 @@ limitations under the License.
...
@@ -16,6 +16,7 @@ limitations under the License.
package
installer
// import "k8s.io/helm/pkg/plugin/installer"
package
installer
// import "k8s.io/helm/pkg/plugin/installer"
import
(
import
(
"fmt"
"os"
"os"
"sort"
"sort"
...
@@ -112,7 +113,8 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
...
@@ -112,7 +113,8 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
return
ver
,
nil
return
ver
,
nil
}
}
}
}
return
""
,
nil
return
""
,
fmt
.
Errorf
(
"requested version %q does not exist for plugin %q"
,
i
.
Version
,
i
.
Repo
.
Remote
())
}
}
// setVersion attempts to checkout the version
// setVersion attempts to checkout the version
...
...
pkg/plugin/installer/vcs_installer_test.go
View file @
3e5642a4
...
@@ -16,8 +16,10 @@ limitations under the License.
...
@@ -16,8 +16,10 @@ limitations under the License.
package
installer
// import "k8s.io/helm/pkg/plugin/installer"
package
installer
// import "k8s.io/helm/pkg/plugin/installer"
import
(
import
(
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"testing"
"testing"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/helmpath"
...
@@ -51,7 +53,7 @@ func TestVCSInstaller(t *testing.T) {
...
@@ -51,7 +53,7 @@ func TestVCSInstaller(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
os
.
Remove
(
hh
)
defer
os
.
Remove
All
(
hh
)
home
:=
helmpath
.
Home
(
hh
)
home
:=
helmpath
.
Home
(
hh
)
if
err
:=
os
.
MkdirAll
(
home
.
Plugins
(),
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
home
.
Plugins
(),
0755
);
err
!=
nil
{
...
@@ -59,8 +61,9 @@ func TestVCSInstaller(t *testing.T) {
...
@@ -59,8 +61,9 @@ func TestVCSInstaller(t *testing.T) {
}
}
source
:=
"https://github.com/adamreese/helm-env"
source
:=
"https://github.com/adamreese/helm-env"
testRepoPath
,
_
:=
filepath
.
Abs
(
"../testdata/plugdir/echo"
)
repo
:=
&
testRepo
{
repo
:=
&
testRepo
{
local
:
"../testdata/plugdir/echo"
,
local
:
testRepoPath
,
tags
:
[]
string
{
"0.1.0"
,
"0.1.1"
},
tags
:
[]
string
{
"0.1.0"
,
"0.1.1"
},
}
}
...
@@ -87,4 +90,44 @@ func TestVCSInstaller(t *testing.T) {
...
@@ -87,4 +90,44 @@ func TestVCSInstaller(t *testing.T) {
if
i
.
Path
()
!=
home
.
Path
(
"plugins"
,
"helm-env"
)
{
if
i
.
Path
()
!=
home
.
Path
(
"plugins"
,
"helm-env"
)
{
t
.
Errorf
(
"expected path '$HELM_HOME/plugins/helm-env', got %q"
,
i
.
Path
())
t
.
Errorf
(
"expected path '$HELM_HOME/plugins/helm-env', got %q"
,
i
.
Path
())
}
}
// Install again to test plugin exists error
if
err
:=
Install
(
i
);
err
==
nil
{
t
.
Error
(
"expected error for plugin exists, got none"
)
}
else
if
err
.
Error
()
!=
"plugin already exists"
{
t
.
Errorf
(
"expected error for plugin exists, got (%v)"
,
err
)
}
}
func
TestVCSInstallerNonExistentVersion
(
t
*
testing
.
T
)
{
hh
,
err
:=
ioutil
.
TempDir
(
""
,
"helm-home-"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
RemoveAll
(
hh
)
home
:=
helmpath
.
Home
(
hh
)
if
err
:=
os
.
MkdirAll
(
home
.
Plugins
(),
0755
);
err
!=
nil
{
t
.
Fatalf
(
"Could not create %s: %s"
,
home
.
Plugins
(),
err
)
}
source
:=
"https://github.com/adamreese/helm-env"
version
:=
"0.2.0"
i
,
err
:=
NewForSource
(
source
,
version
,
home
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %s"
,
err
)
}
// ensure a VCSInstaller was returned
_
,
ok
:=
i
.
(
*
VCSInstaller
)
if
!
ok
{
t
.
Error
(
"expected a VCSInstaller"
)
}
if
err
:=
Install
(
i
);
err
==
nil
{
t
.
Error
(
"expected error for version does not exists, got none"
)
}
else
if
err
.
Error
()
!=
fmt
.
Sprintf
(
"requested version %q does not exist for plugin %q"
,
version
,
source
)
{
t
.
Errorf
(
"expected error for version does not exists, got (%v)"
,
err
)
}
}
}
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