|
|
|
@ -29,6 +29,11 @@ import (
|
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
ExcludeNameFilter = "!name"
|
|
|
|
|
IncludeNameFilter = "name"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ReleaseTesting is the action for testing a release.
|
|
|
|
|
//
|
|
|
|
|
// It provides the implementation of 'helm test'.
|
|
|
|
@ -66,9 +71,9 @@ func (r *ReleaseTesting) Run(name string) (*release.Release, error) {
|
|
|
|
|
|
|
|
|
|
skippedHooks := []*release.Hook{}
|
|
|
|
|
executingHooks := []*release.Hook{}
|
|
|
|
|
if len(r.Filters["!name"]) != 0 {
|
|
|
|
|
if len(r.Filters[ExcludeNameFilter]) != 0 {
|
|
|
|
|
for _, h := range rel.Hooks {
|
|
|
|
|
if contains(r.Filters["!name"], h.Name) {
|
|
|
|
|
if contains(r.Filters[ExcludeNameFilter], h.Name) {
|
|
|
|
|
skippedHooks = append(skippedHooks, h)
|
|
|
|
|
} else {
|
|
|
|
|
executingHooks = append(executingHooks, h)
|
|
|
|
@ -76,10 +81,10 @@ func (r *ReleaseTesting) Run(name string) (*release.Release, error) {
|
|
|
|
|
}
|
|
|
|
|
rel.Hooks = executingHooks
|
|
|
|
|
}
|
|
|
|
|
if len(r.Filters["name"]) != 0 {
|
|
|
|
|
if len(r.Filters[IncludeNameFilter]) != 0 {
|
|
|
|
|
executingHooks = nil
|
|
|
|
|
for _, h := range rel.Hooks {
|
|
|
|
|
if contains(r.Filters["name"], h.Name) {
|
|
|
|
|
if contains(r.Filters[IncludeNameFilter], h.Name) {
|
|
|
|
|
executingHooks = append(executingHooks, h)
|
|
|
|
|
} else {
|
|
|
|
|
skippedHooks = append(skippedHooks, h)
|
|
|
|
@ -110,6 +115,12 @@ func (r *ReleaseTesting) GetPodLogs(out io.Writer, rel *release.Release) error {
|
|
|
|
|
for _, h := range rel.Hooks {
|
|
|
|
|
for _, e := range h.Events {
|
|
|
|
|
if e == release.HookTest {
|
|
|
|
|
if contains(r.Filters[ExcludeNameFilter], h.Name) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if len(r.Filters[IncludeNameFilter]) > 0 && !contains(r.Filters[IncludeNameFilter], h.Name) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
req := client.CoreV1().Pods(r.Namespace).GetLogs(h.Name, &v1.PodLogOptions{})
|
|
|
|
|
logReader, err := req.Stream(context.Background())
|
|
|
|
|
if err != nil {
|
|
|
|
|