mirror of https://github.com/helm/helm
parent
0868355d3e
commit
7a0413344e
@ -1,2 +1,6 @@
|
|||||||
# tiller
|
# tiller
|
||||||
helmd
|
helmd
|
||||||
|
|
||||||
|
# Runtime Requirements
|
||||||
|
|
||||||
|
- kubectl 1.2 or later
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package environment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/deis/tiller/pkg/hapi"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EngineYard maps engine names to engine implementations.
|
||||||
|
type EngineYard map[string]Engine
|
||||||
|
|
||||||
|
func (y EngineYard) Get(k string) (Engine, bool) {
|
||||||
|
e, ok := y[k]
|
||||||
|
return e, ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// Engine represents a template engine that can render templates.
|
||||||
|
//
|
||||||
|
// For some engines, "rendering" includes both compiling and executing. (Other
|
||||||
|
// engines do not distinguish between phases.)
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleaseStorage represents a storage engine for a Release.
|
||||||
|
//
|
||||||
|
// Release storage must be concurrency safe.
|
||||||
|
type ReleaseStorage interface {
|
||||||
|
Get(key string) (*hapi.Release, error)
|
||||||
|
Set(key string, val *hapi.Release) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// KubeClient represents a client capable of communicating with the Kubernetes API.
|
||||||
|
//
|
||||||
|
// A KubeClient must be concurrency safe.
|
||||||
|
type KubeClient interface {
|
||||||
|
Install(manifest []byte) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Environment provides the context for executing a client request.
|
||||||
|
//
|
||||||
|
// All services in a context are concurrency safe.
|
||||||
|
type Environment struct {
|
||||||
|
// EngineYard provides access to the known template engines.
|
||||||
|
EngineYard EngineYard
|
||||||
|
// Releases stores records of releases.
|
||||||
|
Releases ReleaseStorage
|
||||||
|
// KubeClient is a Kubernetes API client.
|
||||||
|
KubeClient KubeClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns an environment initialized with the defaults.
|
||||||
|
func New() *Environment {
|
||||||
|
return &Environment{}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package environment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/deis/tiller/pkg/hapi"
|
||||||
|
)
|
||||||
|
|
||||||
|
type mockEngine struct {
|
||||||
|
out []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *mockEngine) Render(chrt *hapi.Chart, v *hapi.Values) ([]byte, error) {
|
||||||
|
return e.out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ Engine = &mockEngine{}
|
||||||
|
|
||||||
|
func TestEngine(t *testing.T) {
|
||||||
|
eng := &mockEngine{out: []byte("test")}
|
||||||
|
|
||||||
|
env := New()
|
||||||
|
env.EngineYard = EngineYard(map[string]Engine{"test": eng})
|
||||||
|
|
||||||
|
if engine, ok := env.EngineYard.Get("test"); !ok {
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue