(group charttpl.Group, parent compileScope, groupPath []int)
| 59 | } |
| 60 | |
| 61 | func (c *compiler) compileGroup(group charttpl.Group, parent compileScope, groupPath []int) error { |
| 62 | scope := compileScope{ |
| 63 | metrics: cloneStringSet(parent.metrics), |
| 64 | familyParts: append(append([]string(nil), parent.familyParts...), strings.TrimSpace(group.Family)), |
| 65 | contextParts: append(append([]string(nil), parent.contextParts...), normalizeOptional(group.ContextNamespace)...), |
| 66 | } |
| 67 | |
| 68 | for _, metric := range group.Metrics { |
| 69 | name := strings.TrimSpace(metric) |
| 70 | scope.metrics[name] = struct{}{} |
| 71 | c.metricsSet[name] = struct{}{} |
| 72 | } |
| 73 | |
| 74 | for i := range group.Charts { |
| 75 | templateID := buildTemplateID(groupPath, i) |
| 76 | compiled, err := c.compileChart(group.Charts[i], scope, templateID) |
| 77 | if err != nil { |
| 78 | return fmt.Errorf("chartengine: compile group[%s] chart[%d]: %w", pathIndexes(groupPath), i, err) |
| 79 | } |
| 80 | c.charts = append(c.charts, compiled) |
| 81 | } |
| 82 | |
| 83 | for i := range group.Groups { |
| 84 | nextPath := append(append([]int(nil), groupPath...), i) |
| 85 | if err := c.compileGroup(group.Groups[i], scope, nextPath); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | } |
| 89 | return nil |
| 90 | } |
| 91 | |
| 92 | func (c *compiler) compileChart(chart charttpl.Chart, scope compileScope, templateID string) (program.Chart, error) { |
| 93 | dimensions := make([]program.Dimension, 0, len(chart.Dimensions)) |
no test coverage detected