mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +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/user"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
@ -424,14 +425,19 @@ func DiffResources(before, clusterUp, clusterDown, after []byte, location string
|
||||
}
|
||||
lines = lines[2:]
|
||||
|
||||
var added []string
|
||||
var added, report []string
|
||||
resourceTypeRE := regexp.MustCompile(`^@@.+\s(\[\s\S+\s\])$`)
|
||||
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 {
|
||||
added = append(added, l)
|
||||
report = append(report, l)
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user