Documentation ¶
Index ¶
Constants ¶
const ( // EmbedDirectory is main embed directory with predefined templates. EmbedDirectory = `embed` // Extension is a common extension for all template files used for generation project. Extension = `gotmpl` )
Variables ¶
This section is empty.
Functions ¶
func NewTemplate ¶
NewTemplate return built-in go *template.Template.
func ProvideEmbedFS ¶ added in v1.1.0
func ProvideEmbedFS(directory BoxDirectory) (fs.ReadFileFS, error)
ProvideEmbedFS return fs.ReadFileFS, which contains embed built-in template files.
Types ¶
type Box ¶ added in v1.1.0
type Box struct {
// contains filtered or unexported fields
}
Box is a BoxInterface implementation. Contains information about embed and os filesystem.
type BoxDirectory ¶ added in v1.1.0
type BoxDirectory string
BoxDirectory is an alias for string type, determine where placed builtin layout templates.
type BoxInterface ¶ added in v1.1.0
BoxInterface is a common interface for read file content of templates, builtin and passed by values/args.
func NewBox ¶
func NewBox(embedFS fs.ReadFileFS, osFS afero.Fs) BoxInterface
NewBox return BoxInterface, which contains embed built-in template files.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is built-in generator.Generator implementation. Used to generate common/base layout for project.
func NewGenerator ¶
func NewGenerator(renderer RendererInterface, filesystem afero.Fs, options ...Option) *Generator
NewGenerator return Generator
func (*Generator) Run ¶
func (g *Generator) Run(_ context.Context, options generator.RunOptions, values generator.RunValues) (generator.RunResult, error)
Run performs main process of generation. Current steps:
- make cleanup working directory if called
- prepare file list for generation
- process each file/template
type Option ¶
type Option func(options *Options)
Option allows setting optional Generator Options.
func WithCleanup ¶
WithCleanup specifies Options.Cleanup value, allow cleanup working directory before generation start.
func WithTemplateDockerfile ¶
WithTemplateDockerfile specifies custom Dockerfile template path.
func WithTemplateMakefile ¶
WithTemplateMakefile specifies custom Makefile template path.
type Options ¶
Options provides additional Generator settings, such as generator Cleanup or Templates.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is built-in RendererInterface implementation.
type RendererInterface ¶
type RendererInterface interface {
Render(source string, values generator.RunValues) ([]byte, error)
}
RendererInterface define common interface for rendering templates.
func NewRenderer ¶
func NewRenderer(box BoxInterface, ti TemplateInterface) RendererInterface
NewRenderer return implementation of RendererInterface.