Commit 96031935 authored by John Jarvis's avatar John Jarvis

Merge branch 'jarv/add-service-labels' into 'master'

Add service labels and make the report a bit easier to copy and paste.

See merge request gl-infra/oncall-robot-assistant!21
parents 84eac800 228066eb
Pipeline #29378498 passed with stage
in 2 minutes and 53 seconds
......@@ -183,6 +183,16 @@ func filterSeverityLabels(labels []string) (filteredLabels []string) {
return
}
func filterServiceLabels(labels []string) (filteredLabels []string) {
// severityTest := func(s string) bool { return strings.HasPrefix(s, "S") && len(s) <= 2 }
for _, l := range labels {
if strings.HasPrefix(l, "Service:") {
filteredLabels = append(filteredLabels, l)
}
}
return
}
func filterIssuesByLabel(label string, issues []*gitlab.Issue) (filteredIssues []*gitlab.Issue) {
for _, p := range issues {
if stringInSlice(label, p.Labels) {
......
......@@ -55,8 +55,9 @@ func (r *Report) CreateReportIssue(title string) string {
// weeklyOpsGraphs := r.uploadGraphs(graphs)
weeklyOpsGraphs := []WeeklyOpsGraph{}
desc := r.generateTemplate(weeklyOpsGraphs)
issue := r.Helpers.GitLab.CreateIssue(title, desc, r.Config.Projects.ReportProject.ID)
return issue.WebURL
// issue := r.Helpers.GitLab.CreateIssue(title, desc, r.Config.Projects.ReportProject.ID)
// return issue.WebURL
return desc
}
// Generate an issue using a template
......@@ -167,6 +168,7 @@ func genIssueInfo(p *gitlab.Issue) *Issue {
issue.URL = p.WebURL
issue.Assignee = p.Assignee.Username
issue.SeverityLabels = filterSeverityLabels(p.Labels)
issue.ServiceLabels = filterServiceLabels(p.Labels)
return &issue
}
......
......@@ -31,6 +31,7 @@ type Issue struct {
CreatedAt string
Assignee string
SeverityLabels []string
ServiceLabels []string
}
// Incident for PD incident
......
......@@ -62,21 +62,15 @@
#### Change Issues
| Created | Assignee | Summary |
| ------ | -------- | ------- |
{{- range .ChangeIssues }}
| [{{.CreatedAt}}]({{.URL}}) | {{.Assignee }} | {{.Summary}} |
* {{.CreatedAt}} - [{{.Summary}}]({{.URL}}) - {{.Assignee }}
{{- end }}
#### Incident Issues
| Created | Assignee | Summary | Severity |
| ------ | -------- | ------- | ------- |
{{- range .IncidentIssues }}
| [{{.CreatedAt}}]({{.URL}}) | {{.Assignee }} | {{.Summary}} | {{range .SeverityLabels}}~{{.}}{{ end }} |
* {{.CreatedAt}} - [{{.Summary}}]({{.URL}}) - {{.Assignee }} | {{range .SeverityLabels}}~{{.}}{{ end }} | {{range .ServiceLabels}}~{{.}}{{ end }}
{{- end }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment