package graphite import ( "fmt" "strings" ) const ( // DefaultSeparator is the default join character to use when joining multiple // measurement parts in a template. DefaultSeparator = "." ) // Config represents the configuration for Graphite endpoints. type Config struct { Separator string Templates []string } // Validate validates the config's templates and tags. func (c *Config) Validate() error { return c.validateTemplates() } func (c *Config) validateTemplates() error { // map to keep track of filters we see filters := make(map[string]struct{}, len(c.Templates)) for i, template := range c.Templates { parts := strings.Fields(template) // Ensure template string is non-empty if len(parts) == 0 { return fmt.Errorf("missing template at position: %d", i) } if len(parts) == 1 && parts[0] == "" { return fmt.Errorf("missing template at position: %d", i) } if len(parts) > 3 { return fmt.Errorf("invalid template format: %q", template) } filter := "" tags := "" if len(parts) >= 2 { // We could have