|
|
@ -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) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer os.Remove(hh)
|
|
|
|
defer os.RemoveAll(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) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
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)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|