Documentation
¶
Index ¶
- func DefaultFuncMap() template.FuncMap
- func IsSetTemplateDefaultsError(err error) bool
- func IsValidateError(err error) bool
- func NewSetTemplateDefaultsError(err error) error
- func NewValidateError(err error) error
- type BoilerplateMixin
- type Builder
- type CodeFragments
- type CodeFragmentsMap
- type ComponentConfigMixin
- type DomainMixin
- type File
- type HasBoilerplate
- type HasComponentConfig
- type HasDomain
- type HasMultiGroup
- type HasProjectName
- type HasRepository
- type HasResource
- type IfExistsAction
- type IfExistsActionMixin
- type Inserter
- type InserterMixin
- type Marker
- type MultiGroupMixin
- type PathMixin
- type ProjectNameMixin
- type RepositoryMixin
- type RequiresValidation
- type ResourceMixin
- type Template
- type TemplateMixin
- type UseCustomFuncMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultFuncMap ¶
DefaultFuncMap returns the default template.FuncMap for rendering the template.
func IsSetTemplateDefaultsError ¶
IsSetTemplateDefaultsError checks if the error was returned by Template.SetTemplateDefaults
func IsValidateError ¶
IsValidateError checks if the error was returned by RequiresValidation.Validate
func NewSetTemplateDefaultsError ¶
NewSetTemplateDefaultsError wraps an error to specify it was returned by Template.SetTemplateDefaults
func NewValidateError ¶
NewValidateError wraps an error to specify it was returned by RequiresValidation.Validate
Types ¶
type BoilerplateMixin ¶
type BoilerplateMixin struct {
// Boilerplate is the contents of a Boilerplate go header file
Boilerplate string
}
BoilerplateMixin provides templates with a injectable boilerplate field
func (*BoilerplateMixin) InjectBoilerplate ¶
func (m *BoilerplateMixin) InjectBoilerplate(boilerplate string)
InjectBoilerplate implements HasBoilerplate
type Builder ¶
type Builder interface {
// GetPath returns the path to the file location
GetPath() string
// GetIfExistsAction returns the behavior when creating a file that already exists
GetIfExistsAction() IfExistsAction
}
Builder defines the basic methods that any file builder must implement
type CodeFragments ¶
type CodeFragments []string
CodeFragments represents a set of code fragments A code fragment is a piece of code provided as a Go string, it may have multiple lines
type CodeFragmentsMap ¶
type CodeFragmentsMap map[Marker]CodeFragments
CodeFragmentsMap binds Markers and CodeFragments together
type ComponentConfigMixin ¶
type ComponentConfigMixin struct {
// ComponentConfig is the component-config flag
ComponentConfig bool
}
ComponentConfigMixin provides templates with a injectable component-config flag field
func (*ComponentConfigMixin) InjectComponentConfig ¶
func (m *ComponentConfigMixin) InjectComponentConfig(flag bool)
InjectComponentConfig implements HasComponentConfig
type DomainMixin ¶
type DomainMixin struct {
// Domain is the domain for the APIs
Domain string
}
DomainMixin provides templates with a injectable domain field
func (*DomainMixin) InjectDomain ¶
func (m *DomainMixin) InjectDomain(domain string)
InjectDomain implements HasDomain
type File ¶
type File struct {
// Path is the file to write
Path string `json:"path,omitempty"`
// Contents is the generated output
Contents string `json:"contents,omitempty"`
// IfExistsAction determines what to do if the file exists
IfExistsAction IfExistsAction `json:"ifExistsAction,omitempty"`
}
File describes a file that will be written
type HasBoilerplate ¶
type HasBoilerplate interface {
// InjectBoilerplate sets the template boilerplate
InjectBoilerplate(string)
}
HasBoilerplate allows a boilerplate to be used on a template
type HasComponentConfig ¶
type HasComponentConfig interface {
// InjectComponentConfig sets the template component-config flag
InjectComponentConfig(bool)
}
HasComponentConfig allows the component-config flag to be used on a template
type HasDomain ¶
type HasDomain interface {
// InjectDomain sets the template domain
InjectDomain(string)
}
HasDomain allows the domain to be used on a template
type HasMultiGroup ¶
type HasMultiGroup interface {
// InjectMultiGroup sets the template multi-group flag
InjectMultiGroup(bool)
}
HasMultiGroup allows the multi-group flag to be used on a template
type HasProjectName ¶
type HasProjectName interface {
// InjectProjectName sets the template project name.
InjectProjectName(string)
}
HasProjectName allows a project name to be used on a template.
type HasRepository ¶
type HasRepository interface {
// InjectRepository sets the template repository
InjectRepository(string)
}
HasRepository allows the repository to be used on a template
type HasResource ¶
type HasResource interface {
// InjectResource sets the template resource
InjectResource(*resource.Resource)
}
HasResource allows a resource to be used on a template
type IfExistsAction ¶
type IfExistsAction int
IfExistsAction determines what to do if the scaffold file already exists
const ( // Skip skips the file and moves to the next one Skip IfExistsAction = iota // Error returns an error and stops processing Error // Overwrite truncates and overwrites the existing file Overwrite )
type IfExistsActionMixin ¶
type IfExistsActionMixin struct {
// IfExistsAction determines what to do if the file exists
IfExistsAction IfExistsAction
}
IfExistsActionMixin provides file builders with a if-exists-action field
func (*IfExistsActionMixin) GetIfExistsAction ¶
func (t *IfExistsActionMixin) GetIfExistsAction() IfExistsAction
GetIfExistsAction implements Builder
type Inserter ¶
type Inserter interface {
Builder
// GetMarkers returns the different markers where code fragments will be inserted
GetMarkers() []Marker
// GetCodeFragments returns a map that binds markers to code fragments
GetCodeFragments() CodeFragmentsMap
}
Inserter is a file builder that inserts code fragments in marked positions
type InserterMixin ¶
type InserterMixin struct {
PathMixin
}
InserterMixin is the mixin that should be embedded in Inserter builders
func (*InserterMixin) GetIfExistsAction ¶
func (t *InserterMixin) GetIfExistsAction() IfExistsAction
GetIfExistsAction implements Builder
type Marker ¶
type Marker struct {
// contains filtered or unexported fields
}
Marker represents a machine-readable comment that will be used for scaffolding purposes
func NewMarkerFor ¶
NewMarkerFor creates a new marker customized for the specific file Supported file extensions: .go, .yaml, .yml
func (Marker) EqualsLine ¶
EqualsLine compares a marker with a string representation to check if they are the same marker
type MultiGroupMixin ¶
type MultiGroupMixin struct {
// MultiGroup is the multi-group flag
MultiGroup bool
}
MultiGroupMixin provides templates with a injectable multi-group flag field
func (*MultiGroupMixin) InjectMultiGroup ¶
func (m *MultiGroupMixin) InjectMultiGroup(flag bool)
InjectMultiGroup implements HasMultiGroup
type PathMixin ¶
type PathMixin struct {
// Path is the of the file
Path string
}
PathMixin provides file builders with a path field
type ProjectNameMixin ¶
type ProjectNameMixin struct {
ProjectName string
}
ProjectNameMixin provides templates with an injectable project name field.
func (*ProjectNameMixin) InjectProjectName ¶
func (m *ProjectNameMixin) InjectProjectName(projectName string)
InjectProjectName implements HasProjectName.
type RepositoryMixin ¶
type RepositoryMixin struct {
// Repo is the go project package path
Repo string
}
RepositoryMixin provides templates with a injectable repository field
func (*RepositoryMixin) InjectRepository ¶
func (m *RepositoryMixin) InjectRepository(repository string)
InjectRepository implements HasRepository
type RequiresValidation ¶
type RequiresValidation interface {
Builder
// Validate returns true if the template has valid values
Validate() error
}
RequiresValidation is a file builder that requires validation
type ResourceMixin ¶
ResourceMixin provides templates with a injectable resource field
func (*ResourceMixin) InjectResource ¶
func (m *ResourceMixin) InjectResource(res *resource.Resource)
InjectResource implements HasResource
type Template ¶
type Template interface {
Builder
// GetBody returns the template body
GetBody() string
// SetTemplateDefaults sets the default values for templates
SetTemplateDefaults() error
}
Template is file builder based on a file template
type TemplateMixin ¶
type TemplateMixin struct {
PathMixin
IfExistsActionMixin
// TemplateBody is the template body to execute
TemplateBody string
}
TemplateMixin is the mixin that should be embedded in Template builders
func (*TemplateMixin) GetBody ¶
func (t *TemplateMixin) GetBody() string
GetBody implements Template
type UseCustomFuncMap ¶
type UseCustomFuncMap interface {
// GetFuncMap returns a custom FuncMap.
GetFuncMap() template.FuncMap
}
UseCustomFuncMap allows a template to use a custom template.FuncMap instead of the default FuncMap.