Add per-report distributor path overrides
This commit is contained in:
@@ -113,10 +113,16 @@ type RecentChangeConfig struct {
|
||||
}
|
||||
|
||||
type ReportConfig struct {
|
||||
DeterministicModules []ModuleConfigItem `yaml:"deterministic_modules"`
|
||||
DeterministicModules []ModuleConfigItem `yaml:"deterministic_modules"`
|
||||
Distributor ReportDistributorConfig `yaml:"distributor"`
|
||||
deterministicModulesSet bool
|
||||
}
|
||||
|
||||
type ReportDistributorConfig struct {
|
||||
PathTemplates []string `yaml:"path_templates"`
|
||||
pathTemplatesSet bool
|
||||
}
|
||||
|
||||
type ModuleConfigItem struct {
|
||||
ID module.ID `yaml:"id"`
|
||||
Options any `yaml:"options,omitempty"`
|
||||
@@ -135,6 +141,10 @@ func (c *ReportConfig) UnmarshalYAML(value *yaml.Node) error {
|
||||
return err
|
||||
}
|
||||
c.deterministicModulesSet = true
|
||||
case "distributor":
|
||||
if err := node.Decode(&c.Distributor); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown report entry field %q", key)
|
||||
}
|
||||
@@ -142,6 +152,30 @@ func (c *ReportConfig) UnmarshalYAML(value *yaml.Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ReportDistributorConfig) UnmarshalYAML(value *yaml.Node) error {
|
||||
if value.Kind != yaml.MappingNode {
|
||||
return fmt.Errorf("report distributor entry must be a mapping")
|
||||
}
|
||||
for i := 0; i < len(value.Content); i += 2 {
|
||||
key := value.Content[i].Value
|
||||
node := value.Content[i+1]
|
||||
switch key {
|
||||
case "path_templates":
|
||||
if err := node.Decode(&c.PathTemplates); err != nil {
|
||||
return err
|
||||
}
|
||||
c.pathTemplatesSet = true
|
||||
default:
|
||||
return fmt.Errorf("unknown report distributor field %q", key)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c ReportDistributorConfig) PathTemplatesSet() bool {
|
||||
return c.pathTemplatesSet
|
||||
}
|
||||
|
||||
func (m *ModuleConfigItem) UnmarshalYAML(value *yaml.Node) error {
|
||||
switch value.Kind {
|
||||
case yaml.ScalarNode:
|
||||
|
||||
Reference in New Issue
Block a user