From a6556b4982bf411e34504af7293a1456da868ef5 Mon Sep 17 00:00:00 2001 From: Sushil Kumar Date: Thu, 25 May 2017 15:01:44 -0700 Subject: [PATCH] Check existence of $HELM_HOME/plugins before installing plugin Fixes https://github.com/kubernetes/helm/issues/2488 --- pkg/plugin/installer/installer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/plugin/installer/installer.go b/pkg/plugin/installer/installer.go index 9b0c9a23b..4cc19ce28 100644 --- a/pkg/plugin/installer/installer.go +++ b/pkg/plugin/installer/installer.go @@ -19,6 +19,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "k8s.io/helm/pkg/helm/helmpath" @@ -42,6 +43,10 @@ type Installer interface { // Install installs a plugin to $HELM_HOME. func Install(i Installer) error { + if _, pathErr := os.Stat(path.Dir(i.Path())); os.IsNotExist(pathErr) { + return errors.New(`plugin home "$HELM_HOME/plugins" does not exists`) + } + if _, pathErr := os.Stat(i.Path()); !os.IsNotExist(pathErr) { return errors.New("plugin already exists") }