template

package
v0.24.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2020 The UnDistro authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjs added in v0.19.3

func GetObjs(fs fs.FS, dir, tplName string, vars map[string]interface{}) ([]unstructured.Unstructured, error)

func SetVariablesFromEnvVar

func SetVariablesFromEnvVar(ctx context.Context, input VariablesInput) error

Types

type BufferPool

type BufferPool struct {
	// contains filtered or unexported fields
}

BufferPool implements a pool of bytes.Buffers in the form of a bounded channel. Pulled from the github.com/oxtoacart/bpool package (Apache licensed).

func NewBufferPool

func NewBufferPool(size int) (bp *BufferPool)

NewBufferPool creates a new BufferPool bounded to the given size.

func (*BufferPool) Get

func (bp *BufferPool) Get() (b *bytes.Buffer)

Get gets a Buffer from the BufferPool, or creates a new one if none are available in the pool.

func (*BufferPool) Put

func (bp *BufferPool) Put(b *bytes.Buffer)

Put returns the given Buffer to the BufferPool.

type Engine

type Engine interface {
	Render(io.Writer, interface{}) error
}

Engine is the generic interface for all responses.

type Options

type Options struct {
	// Filesystem to load templates. Default clustertemplates Dir
	Filesystem fs.FS
	Root       string
	// Funcs is a slice of FuncMaps to apply to the template upon compilation. This is useful for helper functions. Defaults to [].
	Funcs []template.FuncMap
}

Options is a struct for specifying configuration options for the render.Render object.

type Render

type Render struct {
	// contains filtered or unexported fields
}

Render is a service that provides functions for easily writing templates out to a writer.

func New

func New(options ...Options) (*Render, error)

New constructs a new Render instance with the supplied options.

func (*Render) Render

func (r *Render) Render(w io.Writer, e Engine, data interface{}) error

Render is the generic function called by ClusterTemplate, and can be called by custom implementations.

func (*Render) TemplateLookup

func (r *Render) TemplateLookup(t string) *template.Template

TemplateLookup is a wrapper around template.Lookup and returns the template with the given name that is associated with t, or nil if there is no such template.

func (*Render) YAML

func (r *Render) YAML(w io.Writer, name string, binding interface{}) error

YAML builds up the response from the specified template and bindings.

type VariablesInput

type VariablesInput struct {
	ClientSet      client.Client
	NamespacedName types.NamespacedName
	EnvVars        []corev1.EnvVar
	Variables      map[string]interface{}
	// contains filtered or unexported fields
}

type YAML

type YAML struct {
	Name      string
	Templates *template.Template
}

YAML built-in renderer.

func (YAML) Render

func (y YAML) Render(w io.Writer, binding interface{}) error

Render a HTML response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL