template

package
v1.12.1-0...-676f45f Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandConfigSpec

func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, bool, error)

ExpandConfigSpec expands the template inside the config payload, if any. Templating is evaluated on the agent-side.

func ExpandContainerSpec

func ExpandContainerSpec(n *api.NodeDescription, t *api.Task) (*api.ContainerSpec, error)

ExpandContainerSpec expands templated fields in the runtime using the task state and the node where it is scheduled to run. Templating is all evaluated on the agent-side, before execution.

Note that these are projected only on runtime values, since active task values are typically manipulated in the manager.

func ExpandSecretSpec

func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.SecretSpec, error)

ExpandSecretSpec expands the template inside the secret payload, if any. Templating is evaluated on the agent-side.

func NewTemplatedDependencyGetter

func NewTemplatedDependencyGetter(dependencies exec.DependencyGetter, t *api.Task, node *api.NodeDescription) exec.DependencyGetter

NewTemplatedDependencyGetter returns a DependencyGetter that evaluates templates.

func NewTemplatedSecretGetter

func NewTemplatedSecretGetter(dependencies exec.DependencyGetter, t *api.Task, node *api.NodeDescription) exec.SecretGetter

NewTemplatedSecretGetter returns a SecretGetter that evaluates templates.

Types

type Context

type Context struct {
	Service struct {
		ID     string
		Name   string
		Labels map[string]string
	}

	Node struct {
		ID       string
		Hostname string
		Platform Platform
	}

	Task struct {
		ID   string
		Name string
		Slot string
	}
}

Context defines the strict set of values that can be injected into a template expression in SwarmKit data structure. NOTE: Be very careful adding any fields to this structure with types that have methods defined on them. The template would be able to invoke those methods.

func NewContext

func NewContext(n *api.NodeDescription, t *api.Task) (ctx Context)

NewContext returns a new template context from the data available in the task and the node where it is scheduled to run. The provided context can then be used to populate runtime values in a ContainerSpec.

func (*Context) Expand

func (ctx *Context) Expand(s string) (string, error)

Expand treats the string s as a template and populates it with values from the context.

type PayloadContext

type PayloadContext struct {
	Context
	// contains filtered or unexported fields
}

PayloadContext provides a context for expanding a config or secret payload. NOTE: Be very careful adding any fields to this structure with types that have methods defined on them. The template would be able to invoke those methods.

func NewPayloadContextFromTask

func NewPayloadContextFromTask(node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (ctx PayloadContext)

NewPayloadContextFromTask returns a new template context from the data available in the task and the node where it is scheduled to run. This context also provides access to the configs and secrets that the task has access to. The provided context can then be used to populate runtime values in a templated config or secret.

func (*PayloadContext) Expand

func (ctx *PayloadContext) Expand(s string) (string, error)

Expand treats the string s as a template and populates it with values from the context.

type Platform

type Platform struct {
	Architecture string
	OS           string
}

Platform holds information about the underlying platform of the node

type TemplatedConfigGetter

type TemplatedConfigGetter interface {
	exec.ConfigGetter

	// GetAndFlagSecretData returns the interpolated config, and also
	// returns true if the config has been interpolated with data from a
	// secret. In this case, the config should be handled specially and
	// should not be written to disk.
	GetAndFlagSecretData(configID string) (*api.Config, bool, error)
}

TemplatedConfigGetter is a ConfigGetter with an additional method to expose whether a config contains sensitive data.

func NewTemplatedConfigGetter

func NewTemplatedConfigGetter(dependencies exec.DependencyGetter, t *api.Task, node *api.NodeDescription) TemplatedConfigGetter

NewTemplatedConfigGetter returns a ConfigGetter that evaluates templates.

Jump to

Keyboard shortcuts

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