tpl

package
v1.15.11 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Example
{ //nolint:testableexamples
	ctx := config.NewContextInMemory()
	tpl := `Password-value of existing entry: {{ getpw "foo" }}
Password-value of the new entry: {{ .Content }}
Md5sum of the new password: {{ .Content | md5sum }}
Sha1sum of the new password: {{ .Content | sha1sum }}
Blake3 of the new password: {{ .Content | blake3 }}
Md5crypt of the new password: {{ .Content | md5crypt }}
SSHA of the new password: {{ .Content | ssha }}
SSHA256 of the new password: {{ .Content | ssha256 }}
SSHA512 of the new password: {{ .Content | ssha512 }}
Argon2i of the new password: {{ .Content | argon2i }}
Argon2id of the new password: {{ .Content | argon2id }}
Bcrypt of the new password: {{ .Content | bcrypt }}
`
	kv := kvMock{}

	// Arguments: context, template string, name of the secret, generated password, kv store
	buf, err := Execute(ctx, tpl, "example", []byte("bar"), kv)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(buf))
}
Output:

Index

Examples

Constants

View Source
const (
	FuncMd5sum        = "md5sum"
	FuncSha1sum       = "sha1sum"
	FuncSha256sum     = "sha256sum"
	FuncSha512sum     = "sha512sum"
	FuncBlake3        = "blake3"
	FuncMd5Crypt      = "md5crypt"
	FuncSSHA          = "ssha"
	FuncSSHA256       = "ssha256"
	FuncSSHA512       = "ssha512"
	FuncGet           = "get"
	FuncGetPassword   = "getpw"
	FuncGetValue      = "getval"
	FuncGetValues     = "getvals"
	FuncArgon2i       = "argon2i"
	FuncArgon2id      = "argon2id"
	FuncBcrypt        = "bcrypt"
	FuncJoin          = "join"
	FuncRoundDuration = "roundDuration"
	FuncDate          = "date"
	FuncTruncate      = "truncate"
)

These constants defined the template function names used.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, tpl, name string, content []byte, s kvstore) ([]byte, error)

Execute executes the given template.

func PublicFuncMap added in v1.15.3

func PublicFuncMap() template.FuncMap

PublicFuncMap returns a template.FuncMap with useful template functions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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