extractors

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

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

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.

func (*AdvancedComposer) Compose

func (ac *AdvancedComposer) Compose(metadata map[string]string) (map[string]string, error)

Compose renders advanced templates using Go template syntax.

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

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

func SimpleComposer(prefix string, metadataKeys []string) *Composer

SimpleComposer creates a composer with simple prefix-based templates.

func StandardComposer

func StandardComposer() *Composer

StandardComposer creates a composer with common cd-operator label patterns.

func (*Composer) Compose

func (c *Composer) Compose(metadata map[string]string) (map[string]string, error)

Compose renders label templates using extracted metadata. Returns a map of label names to their rendered values.

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

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

Extract extracts layout information by analyzing file paths.

func (*LayoutExtractor) WithFiles

func (le *LayoutExtractor) WithFiles(files []string) map[string]string

WithFiles creates a layout extractor that uses the provided file list. This is useful for testing and when file list is available from another source.

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

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

Extract extracts version information from the configured file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL