templates

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate

func ApplyTemplate(t string, data any) (string, error)

ApplyTemplate takes a YAML template as []byte, populates it using data, and returns the result as a string.

func ApplyTemplateFrom added in v0.0.26

func ApplyTemplateFrom(ctx context.Context, fs shared.FileSystem, f string, obj any) (string, error)

func Copy added in v0.0.13

func Copy(ctx context.Context, fs shared.FileSystem, f shared.File, destination shared.File) error

func CopyAndApply

func CopyAndApply(ctx context.Context, fs shared.FileSystem, root shared.Dir, destination shared.Dir, obj any) error

func CopyAndApplyTemplate

func CopyAndApplyTemplate(ctx context.Context, fs shared.FileSystem, f shared.File, destination shared.File, obj any) error

func CopyAndReplace

func CopyAndReplace(ctx context.Context, fs shared.FileSystem, f shared.File, destination shared.File, replacer Replacer) error

func CopyAndVisit

func CopyAndVisit(ctx context.Context, fs shared.FileSystem, root shared.Dir, destination shared.Dir, visitor FileVisitor) error

func Walk

func Walk(ctx context.Context, fs shared.FileSystem, root shared.Dir, pathSelect shared.PathSelect, files *[]shared.File, dirs *[]shared.Dir) error

Types

type AlreadyExistError

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

func (AlreadyExistError) Error

func (a AlreadyExistError) Error() string

type FileVisitor

type FileVisitor interface {
	shared.PathSelect
	Apply(ctx context.Context, from shared.File, to shared.Dir) error
}

type Replacer

type Replacer interface {
	Do([]byte) ([]byte, error)
}

type ServiceReplacer

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

func NewServiceReplacer

func NewServiceReplacer(gen *generation.Service) *ServiceReplacer

func (*ServiceReplacer) Do

func (r *ServiceReplacer) Do(content []byte) ([]byte, error)

type Source

type Source interface {
	ReadDir(dir shared.Dir) ([]os.DirEntry, error)
	ReadFile(file shared.File) ([]byte, error)
	Next() Source
}

type Templator added in v0.1.18

type Templator struct {
	PathSelect shared.PathSelect
	Override   shared.Override
}

func (*Templator) CopyAndApply added in v0.1.18

func (t *Templator) CopyAndApply(ctx context.Context, fs shared.FileSystem, root shared.Dir, destination shared.Dir, obj any) error

func (*Templator) Keep added in v0.1.20

func (t *Templator) Keep(name string) bool

func (*Templator) Replace added in v0.1.18

func (t *Templator) Replace(p string) bool

Jump to

Keyboard shortcuts

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