mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
Include resource type headers in diff report
This commit is contained in:
parent
2c61d2f80c
commit
0be9b81319
10
hack/e2e.go
10
hack/e2e.go
@ -29,6 +29,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
@ -424,14 +425,19 @@ func DiffResources(before, clusterUp, clusterDown, after []byte, location string
|
|||||||
}
|
}
|
||||||
lines = lines[2:]
|
lines = lines[2:]
|
||||||
|
|
||||||
var added []string
|
var added, report []string
|
||||||
|
resourceTypeRE := regexp.MustCompile(`^@@.+\s(\[\s\S+\s\])$`)
|
||||||
for _, l := range lines {
|
for _, l := range lines {
|
||||||
|
if matches := resourceTypeRE.FindStringSubmatch(l); matches != nil {
|
||||||
|
report = append(report, matches[1])
|
||||||
|
}
|
||||||
if strings.HasPrefix(l, "+") && len(strings.TrimPrefix(l, "+")) > 0 {
|
if strings.HasPrefix(l, "+") && len(strings.TrimPrefix(l, "+")) > 0 {
|
||||||
added = append(added, l)
|
added = append(added, l)
|
||||||
|
report = append(report, l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(added) > 0 {
|
if len(added) > 0 {
|
||||||
return fmt.Errorf("Error: %d leaked resources\n%v", len(added), strings.Join(added, "\n"))
|
return fmt.Errorf("Error: %d leaked resources\n%v", len(added), strings.Join(report, "\n"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user