templates

package
v0.14.0-rc.10.badger2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAll

func LoadAll(t *Templates) (err error)

LoadAll preloads all templates in memory. It returns an error if an error is found parsing at least one template.

Types

type Output

type Output struct {
	Name    string       `json:"name"`
	Type    TemplateType `json:"type"`
	Path    string       `json:"path"`
	Comment string       `json:"comment"`
	Content []byte       `json:"content"`
}

Output represents the text representation of a rendered template.

func (*Output) Write

func (o *Output) Write() error

Write writes the Output to the filesystem as a directory, file or snippet.

type SSHTemplates

type SSHTemplates struct {
	User []Template `json:"user"`
	Host []Template `json:"host"`
}

SSHTemplates contains the templates defining ssh configuration files.

func (*SSHTemplates) Validate

func (t *SSHTemplates) Validate() (err error)

Validate returns an error if a template is not valid.

type Step

type Step struct {
	SSH StepSSH
}

Step represents the default variables available in the CA.

type StepSSH

type StepSSH struct {
	HostKey           ssh.PublicKey
	UserKey           ssh.PublicKey
	HostFederatedKeys []ssh.PublicKey
	UserFederatedKeys []ssh.PublicKey
}

StepSSH holds SSH-related values for the CA.

type Template

type Template struct {
	*template.Template
	Name         string       `json:"name"`
	Type         TemplateType `json:"type"`
	TemplatePath string       `json:"template"`
	Path         string       `json:"path"`
	Comment      string       `json:"comment"`
	Content      []byte       `json:"-"`
}

Template represents on template file.

func (*Template) Load

func (t *Template) Load() error

Load loads the template in memory, returns an error if the parsing of the template fails.

func (*Template) LoadBytes

func (t *Template) LoadBytes(b []byte) error

func (*Template) Output

func (t *Template) Output(data interface{}) (Output, error)

Output renders the template and returns a template.Output struct or an error.

func (*Template) Render

func (t *Template) Render(data interface{}) ([]byte, error)

Render executes the template with the given data and returns the rendered version.

func (*Template) Validate

func (t *Template) Validate() error

Validate returns an error if the template is not valid.

type TemplateType

type TemplateType string

TemplateType defines how a template will be written in disk.

const (
	// Snippet will mark a template as a part of a file.
	Snippet TemplateType = "snippet"
	// File will mark a templates as a full file.
	File TemplateType = "file"
	// Directory will mark a template as a directory.
	Directory TemplateType = "directory"
)

type Templates

type Templates struct {
	SSH  *SSHTemplates          `json:"ssh,omitempty"`
	Data map[string]interface{} `json:"data,omitempty"`
}

Templates is a collection of templates and variables.

func (*Templates) Validate

func (t *Templates) Validate() (err error)

Validate returns an error if a template is not valid.

Jump to

Keyboard shortcuts

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