Documentation
¶
Overview ¶
Package extractors provides specific metadata extractors for pull requests. Each extractor implements the Extractor interface and handles a specific type of metadata extraction (version, environment, layout, annotations).
Index ¶
- type AdvancedComposer
- type AnnotationExtractor
- type BaseExtractor
- func (be BaseExtractor) DefaultValue() string
- func (be BaseExtractor) ExtractSingleValue(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher, ...) (map[string]string, error)
- func (be BaseExtractor) Name() string
- func (be BaseExtractor) Required() bool
- func (be BaseExtractor) SafeExtract(extractFn func() (map[string]string, error)) (map[string]string, error)
- type Composer
- type EnvironmentExtractor
- type LayoutExtractor
- type MultiExtractor
- type VersionExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvancedComposer ¶
type AdvancedComposer struct {
// contains filtered or unexported fields
}
AdvancedComposer creates a composer that supports Go template syntax.
func NewAdvancedComposer ¶
func NewAdvancedComposer(configs []extraction.LabelTemplate) (*AdvancedComposer, error)
NewAdvancedComposer creates an advanced composer with Go template support.
type AnnotationExtractor ¶
type AnnotationExtractor struct {
BaseExtractor
// contains filtered or unexported fields
}
AnnotationExtractor extracts metadata from PR descriptions using magic comments.
func NewAnnotationExtractor ¶
func NewAnnotationExtractor(required bool, defaultValue string) *AnnotationExtractor
NewAnnotationExtractor creates a new annotation extractor with default patterns.
func NewAnnotationExtractorWithPatterns ¶
func NewAnnotationExtractorWithPatterns(patterns map[string]string, required bool, defaultValue string) (*AnnotationExtractor, error)
NewAnnotationExtractorWithPatterns creates an annotation extractor with custom patterns.
func (*AnnotationExtractor) AddPattern ¶
func (ae *AnnotationExtractor) AddPattern(key, pattern string) error
AddPattern adds a custom annotation pattern.
func (*AnnotationExtractor) Extract ¶
func (ae *AnnotationExtractor) Extract(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher) (map[string]string, error)
Extract extracts metadata from PR description using magic comments.
type BaseExtractor ¶
type BaseExtractor struct {
// contains filtered or unexported fields
}
BaseExtractor provides common functionality for all extractors.
func NewBaseExtractor ¶
func NewBaseExtractor(name string, required bool, defaultValue string) BaseExtractor
NewBaseExtractor creates a new base extractor.
func (BaseExtractor) DefaultValue ¶
func (be BaseExtractor) DefaultValue() string
DefaultValue returns the default value to use if extraction fails.
func (BaseExtractor) ExtractSingleValue ¶
func (be BaseExtractor) ExtractSingleValue(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher, extractFn func() (string, error)) (map[string]string, error)
ExtractSingleValue is a helper for extractors that return a single key-value pair.
func (BaseExtractor) Name ¶
func (be BaseExtractor) Name() string
Name returns the unique name of this extractor.
func (BaseExtractor) Required ¶
func (be BaseExtractor) Required() bool
Required returns true if this extractor must succeed for qualification to pass.
func (BaseExtractor) SafeExtract ¶
func (be BaseExtractor) SafeExtract(extractFn func() (map[string]string, error)) (map[string]string, error)
SafeExtract wraps extraction logic with error handling and default values.
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer implements LabelComposer for rendering label templates.
func NewComposer ¶
func NewComposer(templates []extraction.LabelTemplate) *Composer
NewComposer creates a new label composer with the given templates.
func SimpleComposer ¶
SimpleComposer creates a composer with simple prefix-based templates.
func StandardComposer ¶
func StandardComposer() *Composer
StandardComposer creates a composer with common cd-operator label patterns.
type EnvironmentExtractor ¶
type EnvironmentExtractor struct {
BaseExtractor
// contains filtered or unexported fields
}
EnvironmentExtractor extracts environment information from file paths and branch names.
func NewEnvironmentExtractor ¶
func NewEnvironmentExtractor(required bool, defaultValue string) *EnvironmentExtractor
NewEnvironmentExtractor creates a new environment extractor with default patterns.
func NewEnvironmentExtractorWithPatterns ¶
func NewEnvironmentExtractorWithPatterns(pathPatterns, branchPatterns map[string]string, required bool, defaultValue string) (*EnvironmentExtractor, error)
NewEnvironmentExtractorWithPatterns creates an environment extractor with custom patterns.
func (*EnvironmentExtractor) AddBranchPattern ¶
func (ee *EnvironmentExtractor) AddBranchPattern(env, pattern string) error
AddBranchPattern adds a custom branch pattern for environment detection.
func (*EnvironmentExtractor) AddPathPattern ¶
func (ee *EnvironmentExtractor) AddPathPattern(env, pattern string) error
AddPathPattern adds a custom path pattern for environment detection.
func (*EnvironmentExtractor) Extract ¶
func (ee *EnvironmentExtractor) Extract(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher) (map[string]string, error)
Extract extracts environment information from file paths and branch names.
type LayoutExtractor ¶
type LayoutExtractor struct {
BaseExtractor
}
LayoutExtractor extracts layout type information by analyzing file paths.
func NewLayoutExtractor ¶
func NewLayoutExtractor(required bool, defaultValue string) *LayoutExtractor
NewLayoutExtractor creates a new layout extractor.
func (*LayoutExtractor) Extract ¶
func (le *LayoutExtractor) Extract(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher) (map[string]string, error)
Extract extracts layout information by analyzing file paths.
type MultiExtractor ¶
type MultiExtractor struct {
BaseExtractor
// contains filtered or unexported fields
}
MultiExtractor combines multiple extractors into one.
func NewMultiExtractor ¶
func NewMultiExtractor(name string, extractors []extraction.Extractor) *MultiExtractor
NewMultiExtractor creates a new multi-extractor.
func (*MultiExtractor) Extract ¶
func (me *MultiExtractor) Extract(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher) (map[string]string, error)
Extract runs all child extractors and combines their results.
type VersionExtractor ¶
type VersionExtractor struct {
BaseExtractor
// contains filtered or unexported fields
}
VersionExtractor extracts version information from various file types.
func NewVersionExtractor ¶
func NewVersionExtractor(filePath, key, jsonPath string, required bool, defaultValue string) *VersionExtractor
NewVersionExtractor creates a new version extractor.
func (*VersionExtractor) Extract ¶
func (ve *VersionExtractor) Extract(ctx context.Context, pr github.PullRequest, fetcher extraction.FileFetcher) (map[string]string, error)
Extract extracts version information from the configured file.