templates

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 9 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 CopyAndApply

func CopyAndApply(logger shared.BaseLogger, fs FileSystem, root shared.Dir, destination shared.Dir, obj any) error

func CopyAndApplyTemplate

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

func CopyAndReplace

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

func CopyAndVisit

func CopyAndVisit(logger shared.BaseLogger, fs FileSystem, root shared.Dir, destination shared.Dir, visitor FileVisitor) error

func Walk

func Walk(logger shared.BaseLogger, fs FileSystem, root shared.Dir, ignore Ignore, 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 DirReader

type DirReader struct {
}

func NewDirReader

func NewDirReader() *DirReader

func (*DirReader) AbsoluteDir

func (dr *DirReader) AbsoluteDir(dir shared.Dir) string

func (*DirReader) AbsoluteFile

func (dr *DirReader) AbsoluteFile(f shared.File) string

func (*DirReader) ReadDir

func (dr *DirReader) ReadDir(dir shared.Dir) ([]os.DirEntry, error)

func (*DirReader) ReadFile

func (dr *DirReader) ReadFile(file shared.File) ([]byte, error)

type FSReader

type FSReader struct {
	FS fs.FS
}

func NewEmbeddedFileSystem

func NewEmbeddedFileSystem(fsys fs.FS) *FSReader

func (*FSReader) Absolute

func (fr *FSReader) Absolute(dir shared.Dir) string

func (*FSReader) AbsoluteDir

func (fr *FSReader) AbsoluteDir(dir shared.Dir) string

func (*FSReader) AbsoluteFile

func (fr *FSReader) AbsoluteFile(f shared.File) string

func (*FSReader) Copy

func (fr *FSReader) Copy(s string, file string) error

func (*FSReader) ReadDir

func (fr *FSReader) ReadDir(dir shared.Dir) ([]os.DirEntry, error)

func (*FSReader) ReadFile

func (fr *FSReader) ReadFile(file shared.File) ([]byte, error)

type FileSystem

type FileSystem interface {
	AbsoluteFile(f shared.File) string
	AbsoluteDir(dir shared.Dir) string
	ReadDir(dir shared.Dir) ([]os.DirEntry, error)
	ReadFile(file shared.File) ([]byte, error)
}

type FileVisitor

type FileVisitor interface {
	Apply(path shared.File, to shared.Dir) error
	Ignore(file shared.File) bool
}

type Ignore

type Ignore interface {
	Ignore(file shared.File) bool
}

type NoOpIgnore

type NoOpIgnore struct{}

func (NoOpIgnore) Ignore

func (n NoOpIgnore) Ignore(file shared.File) bool

type Replacer

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

type S

type S = string

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
}

Jump to

Keyboard shortcuts

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