Skip to content

Commit

Permalink
Move DefaultConfig closer to Config
Browse files Browse the repository at this point in the history
That way it becomes clear what we treat as the default config.
  • Loading branch information
knl committed Feb 13, 2020
1 parent 92eba6e commit 8d0a10c
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ type Config struct { // nolint
AggregateStrategyContexts []contextDescriptor // PULLEY_STRATEGY_AGGREGATE_REPO_REGEX_<int> = repo_regex && PULLEY_STRATEGY_AGGREGATE_CONTEXT_REGEX_<int> = regex
}

func DefaultConfig() *Config {
var descriptors []contextDescriptor
descriptors = append(descriptors, contextDescriptor{
repo: regexp.MustCompile(".*"),
context: regexp.MustCompile(":all-jobs$"),
})

return &Config{
Host: "localhost",
Port: "1701",
WebhookPath: "",
WebhookToken: make([]byte, 0),
Strategy: AggregateStrategy,
AggregateStrategyContexts: descriptors,
MetricsPath: "metrics",
TrackBuildTimes: false,
}
}

type ContextChecker func(repo, context string) bool

func (config *Config) DefaultContextChecker() ContextChecker {
Expand Down Expand Up @@ -128,25 +147,6 @@ func processAggregateStrategyContexts() ([]contextDescriptor, error) {
return descriptors, nil
}

func DefaultConfig() *Config {
var descriptors []contextDescriptor
descriptors = append(descriptors, contextDescriptor{
repo: regexp.MustCompile(".*"),
context: regexp.MustCompile(":all-jobs$"),
})

return &Config{
Host: "localhost",
Port: "1701",
WebhookPath: "",
WebhookToken: make([]byte, 0),
Strategy: AggregateStrategy,
AggregateStrategyContexts: descriptors,
MetricsPath: "metrics",
TrackBuildTimes: false,
}
}

// Setup configurations with environment variables
func Setup() (*Config, error) {
config := DefaultConfig()
Expand Down

0 comments on commit 8d0a10c

Please sign in to comment.