Documentation
¶
Index ¶
- func GetAllBuiltinTemplates() (map[TemplateType]map[string]string, error)
- func GetBuiltinChangelogTemplate(name string) (string, error)
- func GetBuiltinCommitTemplate(name string) (string, error)
- func GetBuiltinReleaseNotesTemplate(name string) (string, error)
- func GetBuiltinReleaseTemplate(name string) (string, error)
- func GetBuiltinTagTemplate(name string) (string, error)
- func GetBuiltinTemplate(templateType TemplateType, name string) (string, error)
- func GetDefaultChangelogTemplate() (string, error)
- func GetDefaultCommitTemplate() (string, error)
- func GetDefaultReleaseNotesTemplate() (string, error)
- func GetDefaultReleaseTemplate() (string, error)
- func GetDefaultTagTemplate() (string, error)
- func ListBuiltinTemplates(templateType TemplateType) ([]string, error)
- func MustParse(name, content string) *template.Template
- func ParseWithFunctions(name, content string, funcMap template.FuncMap) (*template.Template, error)
- func RenderReleaseNotes(entries []history.Entry) (string, error)
- func RenderReleaseNotesWithTemplate(entries []history.Entry, templateSource string) (string, error)
- type SourceType
- type TemplateLoader
- func (l *TemplateLoader) GetAuthToken() string
- func (l *TemplateLoader) Load(source string, expectedType ...TemplateType) (string, error)
- func (l *TemplateLoader) LoadInline(content string) (string, error)
- func (l *TemplateLoader) SetAuthToken(token string)
- func (l *TemplateLoader) SetBaseDir(dir string)
- func (l *TemplateLoader) SetTimeout(timeout time.Duration)
- type TemplateParser
- type TemplateRenderer
- func (r *TemplateRenderer) MustRender(templateContent string, ctx interface{}) string
- func (r *TemplateRenderer) Render(templateContent string, ctx interface{}) (string, error)
- func (r *TemplateRenderer) RenderParsed(tmpl *template.Template, ctx interface{}) (string, error)
- func (r *TemplateRenderer) RenderWithName(name, templateContent string, ctx interface{}) (string, error)
- func (r *TemplateRenderer) SetTimeout(timeout time.Duration)
- type TemplateType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllBuiltinTemplates ¶
func GetAllBuiltinTemplates() (map[TemplateType]map[string]string, error)
GetAllBuiltinTemplates returns a map of all builtin templates (used for testing/docs) Returns map[type][name]content
func GetBuiltinChangelogTemplate ¶
GetBuiltinChangelogTemplate retrieves a builtin changelog template by name
func GetBuiltinCommitTemplate ¶
GetBuiltinCommitTemplate retrieves a builtin commit message template by name
func GetBuiltinReleaseNotesTemplate ¶
GetBuiltinReleaseNotesTemplate retrieves a builtin release notes template by name
func GetBuiltinReleaseTemplate ¶
GetBuiltinReleaseTemplate retrieves a builtin release template by name
func GetBuiltinTagTemplate ¶
GetBuiltinTagTemplate retrieves a builtin tag template by name
func GetBuiltinTemplate ¶
func GetBuiltinTemplate(templateType TemplateType, name string) (string, error)
GetBuiltinTemplate retrieves a builtin template by type and name
func GetDefaultChangelogTemplate ¶
GetDefaultChangelogTemplate returns the default changelog template
func GetDefaultCommitTemplate ¶
GetDefaultCommitTemplate returns the default commit message template
func GetDefaultReleaseNotesTemplate ¶
GetDefaultReleaseNotesTemplate returns the default release notes template
func GetDefaultReleaseTemplate ¶
GetDefaultReleaseTemplate returns the default release template
func GetDefaultTagTemplate ¶
GetDefaultTagTemplate returns the default tag template
func ListBuiltinTemplates ¶
func ListBuiltinTemplates(templateType TemplateType) ([]string, error)
ListBuiltinTemplates lists available builtin templates for a given type
func ParseWithFunctions ¶
ParseWithFunctions parses a template with custom functions
func RenderReleaseNotes ¶
RenderReleaseNotes renders release notes using the default template
func RenderReleaseNotesWithTemplate ¶
RenderReleaseNotesWithTemplate renders release notes using a specific template templateSource can be: - "builtin:default" or "builtin:grouped" - builtin templates - "file:/path/to/template.tmpl" - file path - "https://example.com/template.tmpl" - remote URL - inline template content (multiline string) - "changelog" - auto-maps to changelog template for multi-version - "release-notes" - auto-maps to release-notes template for single-version
Types ¶
type SourceType ¶
type SourceType int
SourceType represents the type of template source
const ( SourceTypeBuiltin SourceType = iota SourceTypeFile SourceTypeGit SourceTypeHTTPS SourceTypeInline )
func DetectSourceType ¶
func DetectSourceType(source string) (SourceType, string)
DetectSourceType detects the template source type and extracts the target
type TemplateLoader ¶
type TemplateLoader struct {
// contains filtered or unexported fields
}
TemplateLoader handles loading templates from various sources
func NewTemplateLoader ¶
func NewTemplateLoader() *TemplateLoader
NewTemplateLoader creates a new template loader
func (*TemplateLoader) GetAuthToken ¶
func (l *TemplateLoader) GetAuthToken() string
GetAuthToken returns the current authentication token
func (*TemplateLoader) Load ¶
func (l *TemplateLoader) Load(source string, expectedType ...TemplateType) (string, error)
Load loads a template from the specified source For builtin templates, expectedType specifies which type directory to search
func (*TemplateLoader) LoadInline ¶
func (l *TemplateLoader) LoadInline(content string) (string, error)
LoadInline loads an inline template (no source prefix parsing)
func (*TemplateLoader) SetAuthToken ¶
func (l *TemplateLoader) SetAuthToken(token string)
SetAuthToken sets the authentication token for remote sources
func (*TemplateLoader) SetBaseDir ¶
func (l *TemplateLoader) SetBaseDir(dir string)
SetBaseDir sets the base directory for resolving relative file paths
func (*TemplateLoader) SetTimeout ¶
func (l *TemplateLoader) SetTimeout(timeout time.Duration)
SetTimeout sets the timeout for remote operations
type TemplateParser ¶
type TemplateParser struct {
// contains filtered or unexported fields
}
TemplateParser handles parsing go templates with Sprig functions
func NewTemplateParser ¶
func NewTemplateParser() *TemplateParser
NewTemplateParser creates a new template parser with safe Sprig functions
func (*TemplateParser) AddFunction ¶
func (p *TemplateParser) AddFunction(name string, fn interface{})
AddFunction adds a custom function to the function map
func (*TemplateParser) Parse ¶
func (p *TemplateParser) Parse(name, content string) (*template.Template, error)
Parse parses a template string and returns a compiled template
func (*TemplateParser) SetOption ¶
func (p *TemplateParser) SetOption(key, value string)
SetOption sets a template option (e.g., "missingkey=error")
type TemplateRenderer ¶
type TemplateRenderer struct {
// contains filtered or unexported fields
}
TemplateRenderer handles rendering templates with context and timeout
func NewTemplateRenderer ¶
func NewTemplateRenderer() *TemplateRenderer
NewTemplateRenderer creates a new template renderer
func (*TemplateRenderer) MustRender ¶
func (r *TemplateRenderer) MustRender(templateContent string, ctx interface{}) string
MustRender renders a template and panics on error (useful for testing)
func (*TemplateRenderer) Render ¶
func (r *TemplateRenderer) Render(templateContent string, ctx interface{}) (string, error)
Render renders a template string with the given context
func (*TemplateRenderer) RenderParsed ¶
func (r *TemplateRenderer) RenderParsed(tmpl *template.Template, ctx interface{}) (string, error)
RenderParsed renders a pre-parsed template with the given context
func (*TemplateRenderer) RenderWithName ¶
func (r *TemplateRenderer) RenderWithName(name, templateContent string, ctx interface{}) (string, error)
RenderWithName renders a template with a specific name (useful for error messages)
func (*TemplateRenderer) SetTimeout ¶
func (r *TemplateRenderer) SetTimeout(timeout time.Duration)
SetTimeout sets the maximum time allowed for template rendering
type TemplateType ¶
type TemplateType string
TemplateType represents the type/purpose of a template
const ( TemplateTypeChangelog TemplateType = "changelog" TemplateTypeTag TemplateType = "tag" TemplateTypeRelease TemplateType = "release" TemplateTypeReleaseNotes TemplateType = "releasenotes" TemplateTypeCommit TemplateType = "commit" )