report with template output will only have access to ReportTemplateSpec. This function reverts parsedMetadata.String()
(key string)
| 295 | // report with template output will only have access to ReportTemplateSpec. |
| 296 | // This function reverts parsedMetadata.String() |
| 297 | func (t *ReportTemplateSpec) loadFromKey(key string) error { |
| 298 | pattern := regexp.MustCompile(`(?P<namespace>[a-z0-9-]+), (?P<name>[a-z0-9.-]+), (?P<kind>\w+) \((?P<api>[^)]+)\)`) |
| 299 | matches := pattern.FindStringSubmatch(key) |
| 300 | if len(matches) > 1 { |
| 301 | t.Namespace = matches[1] |
| 302 | t.Name = matches[2] |
| 303 | t.Kind = matches[3] |
| 304 | t.API = matches[4] |
| 305 | return nil |
| 306 | } |
| 307 | return errors.New("key string didn't match regexp") |
| 308 | } |
| 309 | |
| 310 | // load and print report for template output |
| 311 | func templateReportPrinter(t *template.Template) func(r *Report, to io.Writer) { |
no outgoing calls