tmpl

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tmpl provides templating utilities for goreleaser.

Index

Constants

View Source
const (
	KeyOS      = "Os"
	KeyArch    = "Arch"
	KeyAmd64   = "Amd64"
	Key386     = "I386"
	KeyArm     = "Arm"
	KeyArm64   = "Arm64"
	KeyMips    = "Mips"
	KeyPpc64   = "Ppc64"
	KeyRiscv64 = "Riscv64"
)

Template fields names used in build targets and more.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error is returned on any template error.

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() error

type ExpectedSingleEnvErr

type ExpectedSingleEnvErr struct{}

func (ExpectedSingleEnvErr) Error

func (e ExpectedSingleEnvErr) Error() string

type Fields

type Fields map[string]interface{}

Fields that will be available to the template engine.

type SliceOpt

type SliceOpt func(*sliceOptions)

SliceOpt is a [Slice] option.

func NonEmpty

func NonEmpty() SliceOpt

NonEmpty filters out empty items.

func WithPrefix

func WithPrefix(prefix string) SliceOpt

WithPrefix pretend a prefix to every item.

type Template

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

Template holds data that can be applied to a template string.

func New

func New(ctx *context.Context) *Template

New Template.

func (*Template) Apply

func (t *Template) Apply(s string) (string, error)

Apply applies the given string against the Fields stored in the template.

func (*Template) ApplyAll

func (t *Template) ApplyAll(sps ...*string) error

ApplyAll applies all the given strings against the Fields stored in the template. Application stops as soon as an error is encountered.

func (*Template) ApplySingleEnvOnly

func (t *Template) ApplySingleEnvOnly(s string) (string, error)

ApplySingleEnvOnly enforces template to only contain a single environment variable and nothing else.

func (*Template) Bool

func (t *Template) Bool(s string) (bool, error)

Bool Apply the given string, and converts it to a bool.

func (*Template) Slice

func (t *Template) Slice(in []string, opts ...SliceOpt) ([]string, error)

Slice applies to all items in the given input.

func (*Template) WithArtifact

func (t *Template) WithArtifact(a *artifact.Artifact) *Template

WithArtifact populates Fields from the artifact.

func (*Template) WithBuildOptions

func (t *Template) WithBuildOptions(opts build.Options) *Template

func (*Template) WithEnv

func (t *Template) WithEnv(e map[string]string) *Template

WithEnv overrides template's env field with the given environment map.

func (*Template) WithEnvS

func (t *Template) WithEnvS(envs []string) *Template

WithEnvS overrides template's env field with the given KEY=VALUE list of environment variables.

func (*Template) WithExtraFields

func (t *Template) WithExtraFields(f Fields) *Template

WithExtraFields allows to add new more custom fields to the template. It will override fields with the same name.

Jump to

Keyboard shortcuts

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