From 913905a54fd27e9bc388f50b4fd2e5951ea27aea Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 12 Apr 2016 16:58:53 -0600 Subject: [PATCH] fix(tiller): change environment.Engine signature --- cmd/tiller/environment/environment.go | 5 ++++- cmd/tiller/environment/environment_test.go | 10 +++++----- pkg/engine/engine_test.go | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/tiller/environment/environment.go b/cmd/tiller/environment/environment.go index e92eb77cc..f7d863b6d 100644 --- a/cmd/tiller/environment/environment.go +++ b/cmd/tiller/environment/environment.go @@ -17,10 +17,13 @@ func (y EngineYard) Get(k string) (Engine, bool) { // For some engines, "rendering" includes both compiling and executing. (Other // engines do not distinguish between phases.) // +// The engine returns a map where the key is the named output entity (usually +// a file name) and the value is the rendered content of the template. +// // An Engine must be capable of executing multiple concurrent requests, but // without tainting one request's environment with data from another request. type Engine interface { - Render(*hapi.Chart, *hapi.Values) ([]byte, error) + Render(*hapi.Chart, *hapi.Values) (map[string]string, error) } // ReleaseStorage represents a storage engine for a Release. diff --git a/cmd/tiller/environment/environment_test.go b/cmd/tiller/environment/environment_test.go index df240f209..e42376f6e 100644 --- a/cmd/tiller/environment/environment_test.go +++ b/cmd/tiller/environment/environment_test.go @@ -7,10 +7,10 @@ import ( ) type mockEngine struct { - out []byte + out map[string]string } -func (e *mockEngine) Render(chrt *hapi.Chart, v *hapi.Values) ([]byte, error) { +func (e *mockEngine) Render(chrt *hapi.Chart, v *hapi.Values) (map[string]string, error) { return e.out, nil } @@ -39,7 +39,7 @@ var _ ReleaseStorage = &mockReleaseStorage{} var _ KubeClient = &mockKubeClient{} func TestEngine(t *testing.T) { - eng := &mockEngine{out: []byte("test")} + eng := &mockEngine{out: map[string]string{"albatross": "test"}} env := New() env.EngineYard = EngineYard(map[string]Engine{"test": eng}) @@ -48,8 +48,8 @@ func TestEngine(t *testing.T) { t.Errorf("failed to get engine from EngineYard") } else if out, err := engine.Render(&hapi.Chart{}, &hapi.Values{}); err != nil { t.Errorf("unexpected template error: %s", err) - } else if string(out) != "test" { - t.Errorf("expected 'test', got %q", string(out)) + } else if out["albatross"] != "test" { + t.Errorf("expected 'test', got %q", out["albatross"]) } } diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index b0a00794b..613804ef3 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -4,8 +4,12 @@ import ( "fmt" "sync" "testing" + + "github.com/deis/tiller/cmd/tiller/environment" ) +var _ environment.Engine = &Engine{} + func TestEngine(t *testing.T) { e := New()