|
|
@ -40,16 +40,17 @@ type Engine struct {
|
|
|
|
Strict bool
|
|
|
|
Strict bool
|
|
|
|
// In LintMode, some 'required' template values may be missing, so don't fail
|
|
|
|
// In LintMode, some 'required' template values may be missing, so don't fail
|
|
|
|
LintMode bool
|
|
|
|
LintMode bool
|
|
|
|
// the rest config to connect to the kubernetes api
|
|
|
|
// optional provider of clients to talk to the Kubernetes API
|
|
|
|
config *rest.Config
|
|
|
|
clientProvider *ClientProvider
|
|
|
|
// EnableDNS tells the engine to allow DNS lookups when rendering templates
|
|
|
|
// EnableDNS tells the engine to allow DNS lookups when rendering templates
|
|
|
|
EnableDNS bool
|
|
|
|
EnableDNS bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// New creates a new instance of Engine using the passed in rest config.
|
|
|
|
// New creates a new instance of Engine using the passed in rest config.
|
|
|
|
func New(config *rest.Config) Engine {
|
|
|
|
func New(config *rest.Config) Engine {
|
|
|
|
|
|
|
|
var clientProvider ClientProvider = clientProviderFromConfig{config}
|
|
|
|
return Engine{
|
|
|
|
return Engine{
|
|
|
|
config: config,
|
|
|
|
clientProvider: &clientProvider,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -85,10 +86,21 @@ func Render(chrt *chart.Chart, values chartutil.Values) (map[string]string, erro
|
|
|
|
|
|
|
|
|
|
|
|
// RenderWithClient takes a chart, optional values, and value overrides, and attempts to
|
|
|
|
// RenderWithClient takes a chart, optional values, and value overrides, and attempts to
|
|
|
|
// render the Go templates using the default options. This engine is client aware and so can have template
|
|
|
|
// render the Go templates using the default options. This engine is client aware and so can have template
|
|
|
|
// functions that interact with the client
|
|
|
|
// functions that interact with the client.
|
|
|
|
func RenderWithClient(chrt *chart.Chart, values chartutil.Values, config *rest.Config) (map[string]string, error) {
|
|
|
|
func RenderWithClient(chrt *chart.Chart, values chartutil.Values, config *rest.Config) (map[string]string, error) {
|
|
|
|
|
|
|
|
var clientProvider ClientProvider = clientProviderFromConfig{config}
|
|
|
|
return Engine{
|
|
|
|
return Engine{
|
|
|
|
config: config,
|
|
|
|
clientProvider: &clientProvider,
|
|
|
|
|
|
|
|
}.Render(chrt, values)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RenderWithClientProvider takes a chart, optional values, and value overrides, and attempts to
|
|
|
|
|
|
|
|
// render the Go templates using the default options. This engine is client aware and so can have template
|
|
|
|
|
|
|
|
// functions that interact with the client.
|
|
|
|
|
|
|
|
// This function differs from RenderWithClient in that it lets you customize the way a dynamic client is constructed.
|
|
|
|
|
|
|
|
func RenderWithClientProvider(chrt *chart.Chart, values chartutil.Values, clientProvider ClientProvider) (map[string]string, error) {
|
|
|
|
|
|
|
|
return Engine{
|
|
|
|
|
|
|
|
clientProvider: &clientProvider,
|
|
|
|
}.Render(chrt, values)
|
|
|
|
}.Render(chrt, values)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -194,8 +206,8 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render
|
|
|
|
|
|
|
|
|
|
|
|
// If we are not linting and have a cluster connection, provide a Kubernetes-backed
|
|
|
|
// If we are not linting and have a cluster connection, provide a Kubernetes-backed
|
|
|
|
// implementation.
|
|
|
|
// implementation.
|
|
|
|
if !e.LintMode && e.config != nil {
|
|
|
|
if !e.LintMode && e.clientProvider != nil {
|
|
|
|
funcMap["lookup"] = NewLookupFunction(e.config)
|
|
|
|
funcMap["lookup"] = newLookupFunction(*e.clientProvider)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// When DNS lookups are not enabled override the sprig function and return
|
|
|
|
// When DNS lookups are not enabled override the sprig function and return
|
|
|
|