Documentation ¶
Index ¶
- func DefaultFuncMap() template.FuncMap
- type BoilerplateMixin
- type Builder
- type CloseFileError
- type CodeFragments
- type CodeFragmentsMap
- type ComponentConfigMixindeprecated
- type CreateDirectoryError
- type CreateFileError
- type DomainMixin
- type ExistsFileError
- type File
- type FileAlreadyExistsError
- type Filesystem
- type HasBoilerplate
- type HasComponentConfigdeprecated
- type HasDomain
- type HasMultiGroup
- type HasProjectName
- type HasRepository
- type HasResource
- type IfExistsAction
- type IfExistsActionMixin
- type Inserter
- type InserterMixin
- type Marker
- type ModelAlreadyExistsError
- type MultiGroupMixin
- type OpenFileError
- type PathMixin
- type ProjectNameMixin
- type ReadFileError
- type RepositoryMixin
- type RequiresValidation
- type ResourceMixin
- type Scaffold
- type ScaffoldOption
- type SetTemplateDefaultsError
- type Template
- type TemplateMixin
- type UnknownIfExistsActionError
- type UseCustomFuncMap
- type ValidateError
- type WriteFileError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultFuncMap ¶
DefaultFuncMap returns the default template.FuncMap for rendering the template.
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 CloseFileError ¶
type CloseFileError struct {
// contains filtered or unexported fields
}
CloseFileError is a wrapper error that will be used for errors when closing a file
func (CloseFileError) Unwrap ¶
func (e CloseFileError) Unwrap() error
Unwrap implements Wrapper interface
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
deprecated
type ComponentConfigMixin struct { // ComponentConfig is the component-config flag ComponentConfig bool }
Deprecated: The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. Fur further information see: https://github.com/kubernetes-sigs/controller-runtime/issues/895 Moreover, it has undergone breaking changes and is no longer functioning as intended. As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature, no longer guaranteeing its functionality from version 3.11.0 onwards.
Please, be aware that it will force Kubebuilder remove this option soon in future release.
ComponentConfigMixin provides templates with a injectable component-config flag field
func (*ComponentConfigMixin) InjectComponentConfig ¶
func (m *ComponentConfigMixin) InjectComponentConfig(flag bool)
InjectComponentConfig implements HasComponentConfig
type CreateDirectoryError ¶
type CreateDirectoryError struct {
// contains filtered or unexported fields
}
CreateDirectoryError is a wrapper error that will be used for errors when creating a directory
func (CreateDirectoryError) Unwrap ¶
func (e CreateDirectoryError) Unwrap() error
Unwrap implements Wrapper interface
type CreateFileError ¶
type CreateFileError struct {
// contains filtered or unexported fields
}
CreateFileError is a wrapper error that will be used for errors when creating a file
func (CreateFileError) Unwrap ¶
func (e CreateFileError) Unwrap() error
Unwrap implements Wrapper interface
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 ExistsFileError ¶
type ExistsFileError struct {
// contains filtered or unexported fields
}
ExistsFileError is a wrapper error that will be used for errors when checking for a file existence
func (ExistsFileError) Unwrap ¶
func (e ExistsFileError) Unwrap() error
Unwrap implements Wrapper interface
type File ¶
type File struct { // Path is the file to write Path string // Contents is the generated output Contents string // IfExistsAction determines what to do if the file exists IfExistsAction IfExistsAction }
File describes a file that will be written
type FileAlreadyExistsError ¶
type FileAlreadyExistsError struct {
// contains filtered or unexported fields
}
FileAlreadyExistsError is returned if the file is expected not to exist but it does
func (FileAlreadyExistsError) Error ¶
func (e FileAlreadyExistsError) Error() string
Error implements error interface
type Filesystem ¶
Filesystem abstracts the underlying disk for scaffolding
type HasBoilerplate ¶
type HasBoilerplate interface { // InjectBoilerplate sets the template boilerplate InjectBoilerplate(string) }
HasBoilerplate allows a boilerplate to be used on a template
type HasComponentConfig
deprecated
type HasComponentConfig interface { // InjectComponentConfig sets the template component-config flag InjectComponentConfig(bool) }
Deprecated: The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. Fur further information see: https://github.com/kubernetes-sigs/controller-runtime/issues/895 Moreover, it has undergone breaking changes and is no longer functioning as intended. As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature, no longer guaranteeing its functionality from version 3.11.0 onwards.
Please, be aware that it will force Kubebuilder remove this option soon in future release.
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 ( // SkipFile skips the file and moves to the next one SkipFile IfExistsAction = iota // Error returns an error and stops processing Error // OverwriteFile truncates and overwrites the existing file OverwriteFile )
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 ModelAlreadyExistsError ¶
type ModelAlreadyExistsError struct {
// contains filtered or unexported fields
}
ModelAlreadyExistsError is returned if the file is expected not to exist but a previous model does
func (ModelAlreadyExistsError) Error ¶
func (e ModelAlreadyExistsError) Error() string
Error implements error interface
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 OpenFileError ¶
type OpenFileError struct {
// contains filtered or unexported fields
}
OpenFileError is a wrapper error that will be used for errors when opening a file
func (OpenFileError) Unwrap ¶
func (e OpenFileError) Unwrap() error
Unwrap implements Wrapper interface
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 ReadFileError ¶
type ReadFileError struct {
// contains filtered or unexported fields
}
ReadFileError is a wrapper error that will be used for errors when reading a file
func (ReadFileError) Unwrap ¶
func (e ReadFileError) Unwrap() error
Unwrap implements Wrapper interface
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 Scaffold ¶
type Scaffold struct {
// contains filtered or unexported fields
}
Scaffold uses templates to scaffold new files
func NewScaffold ¶
func NewScaffold(fs Filesystem, options ...ScaffoldOption) *Scaffold
NewScaffold returns a new Scaffold with the provided plugins
type ScaffoldOption ¶
type ScaffoldOption func(*Scaffold)
ScaffoldOption allows to provide optional arguments to the Scaffold
func WithBoilerplate ¶
func WithBoilerplate(boilerplate string) ScaffoldOption
WithBoilerplate provides the boilerplate to the Scaffold
func WithConfig ¶
func WithConfig(cfg config.Config) ScaffoldOption
WithConfig provides the project configuration to the Scaffold
func WithDirectoryPermissions ¶
func WithDirectoryPermissions(dirPerm os.FileMode) ScaffoldOption
WithDirectoryPermissions sets the permissions for new directories
func WithFilePermissions ¶
func WithFilePermissions(filePerm os.FileMode) ScaffoldOption
WithFilePermissions sets the permissions for new files
func WithResource ¶
func WithResource(resource *resource.Resource) ScaffoldOption
WithResource provides the resource to the Scaffold
type SetTemplateDefaultsError ¶
type SetTemplateDefaultsError struct {
// contains filtered or unexported fields
}
SetTemplateDefaultsError is a wrapper error that will be used for errors returned by Template.SetTemplateDefaults
func (SetTemplateDefaultsError) Unwrap ¶
func (e SetTemplateDefaultsError) Unwrap() error
Unwrap implements Wrapper interface
type Template ¶
type Template interface { Builder // GetBody returns the template body GetBody() string // SetTemplateDefaults sets the default values for templates SetTemplateDefaults() error // SetDelim sets an action delimiters to replace default delimiters: {{ }} SetDelim(left, right string) // GetDelim returns the alternative delimiters GetDelim() (string, string) }
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 // contains filtered or unexported fields }
TemplateMixin is the mixin that should be embedded in Template builders
func (*TemplateMixin) GetBody ¶
func (t *TemplateMixin) GetBody() string
GetBody implements Template
func (*TemplateMixin) GetDelim ¶ added in v3.7.0
func (t *TemplateMixin) GetDelim() (string, string)
GetDelim implements Template
func (*TemplateMixin) SetDelim ¶ added in v3.7.0
func (t *TemplateMixin) SetDelim(left, right string)
SetDelim implements Template
type UnknownIfExistsActionError ¶
type UnknownIfExistsActionError struct {
// contains filtered or unexported fields
}
UnknownIfExistsActionError is returned if the if-exists-action is unknown
func (UnknownIfExistsActionError) Error ¶
func (e UnknownIfExistsActionError) Error() string
Error implements error interface
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.
type ValidateError ¶
type ValidateError struct {
// contains filtered or unexported fields
}
ValidateError is a wrapper error that will be used for errors returned by RequiresValidation.Validate
func (ValidateError) Unwrap ¶
func (e ValidateError) Unwrap() error
Unwrap implements Wrapper interface
type WriteFileError ¶
type WriteFileError struct {
// contains filtered or unexported fields
}
WriteFileError is a wrapper error that will be used for errors when writing a file
func (WriteFileError) Unwrap ¶
func (e WriteFileError) Unwrap() error
Unwrap implements Wrapper interface