package template

import "github.com/hashicorp/vault/sdk/helper/template"

Index

Types

type Opt

type Opt func(*StringTemplate) error

func Function

func Function(name string, f interface{}) Opt

Function allows the user to specify functions for use in the template. If the name provided is a function that already exists in the function map, this will override the previously specified function.

func Template

func Template(rawTemplate string) Opt

type StringTemplate

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

StringTemplate creates strings based on the provided template. This uses the go templating language, so anything that adheres to that language will function in this struct. There are several custom functions available for use in the template: - random

- truncate

- truncate_sha256

- uppercase

- lowercase

- replace

- sha256

- base64

- unix_time

- unix_time_millis

- timestamp

- uuid

func NewTemplate

func NewTemplate(opts ...Opt) (up StringTemplate, err error)

NewTemplate creates a StringTemplate. No arguments are required as this has reasonable defaults for all values. The default template is specified in the DefaultTemplate constant.

func (StringTemplate) Generate

func (up StringTemplate) Generate(data interface{}) (string, error)

Generate based on the provided template

Source Files

funcs.go template.go

Version
v0.18.0 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 month ago

Tools for package owners.