Commit bb84f9c2 authored by Matt Butcher's avatar Matt Butcher Committed by GitHub

Merge pull request #830 from technosophos/fix/non-default-engine

fix(tiller): allow different template engine
parents 3e480723 76f4ee1e
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"k8s.io/helm/cmd/tiller/environment" "k8s.io/helm/cmd/tiller/environment"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services" "k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/storage" "k8s.io/helm/pkg/storage"
...@@ -29,10 +30,6 @@ func init() { ...@@ -29,10 +30,6 @@ func init() {
services.RegisterReleaseServiceServer(rootServer, srv) services.RegisterReleaseServiceServer(rootServer, srv)
} }
type releaseServer struct {
env *environment.Environment
}
var ( var (
// errNotImplemented is a temporary error for uninmplemented callbacks. // errNotImplemented is a temporary error for uninmplemented callbacks.
errNotImplemented = errors.New("not implemented") errNotImplemented = errors.New("not implemented")
...@@ -45,6 +42,10 @@ var ( ...@@ -45,6 +42,10 @@ var (
// ListDefaultLimit is the default limit for number of items returned in a list. // ListDefaultLimit is the default limit for number of items returned in a list.
var ListDefaultLimit int64 = 512 var ListDefaultLimit int64 = 512
type releaseServer struct {
env *environment.Environment
}
func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream services.ReleaseService_ListReleasesServer) error { func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream services.ReleaseService_ListReleasesServer) error {
rels, err := s.env.Releases.List() rels, err := s.env.Releases.List()
if err != nil { if err != nil {
...@@ -184,6 +185,18 @@ func (s *releaseServer) uniqName(start string) (string, error) { ...@@ -184,6 +185,18 @@ func (s *releaseServer) uniqName(start string) (string, error) {
return "ERROR", errors.New("no available release name found") return "ERROR", errors.New("no available release name found")
} }
func (s *releaseServer) engine(ch *chart.Chart) environment.Engine {
renderer := s.env.EngineYard.Default()
if ch.Metadata.Engine != "" {
if r, ok := s.env.EngineYard.Get(ch.Metadata.Engine); ok {
renderer = r
} else {
log.Printf("warning: %s requested non-existent template engine %s", ch.Metadata.Name, ch.Metadata.Engine)
}
}
return renderer
}
func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallReleaseRequest) (*services.InstallReleaseResponse, error) { func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallReleaseRequest) (*services.InstallReleaseResponse, error) {
if req.Chart == nil { if req.Chart == nil {
return nil, errMissingChart return nil, errMissingChart
...@@ -211,7 +224,9 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea ...@@ -211,7 +224,9 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
if err != nil { if err != nil {
return nil, err return nil, err
} }
files, err := s.env.EngineYard.Default().Render(req.Chart, vals)
renderer := s.engine(req.Chart)
files, err := renderer.Render(req.Chart, vals)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment