if the kind matches '*List$', treat it as a list

This commit is contained in:
Andrew Lavery
2019-02-12 12:28:08 -08:00
parent 02d753027a
commit fdba7df3c1
2 changed files with 7 additions and 2 deletions

View File

@@ -108,7 +108,7 @@ func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error
kind := u.GetKind() kind := u.GetKind()
if kind == "" { if kind == "" {
return fmt.Errorf("missing kind in object %v", u) return fmt.Errorf("missing kind in object %v", u)
} else if kind == "List" { } else if strings.HasSuffix(kind, "List") {
return nil return nil
} }
if u.GetName() == "" { if u.GetName() == "" {

View File

@@ -20,6 +20,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"log" "log"
"strings"
"sigs.k8s.io/kustomize/pkg/ifc" "sigs.k8s.io/kustomize/pkg/ifc"
internal "sigs.k8s.io/kustomize/pkg/internal/error" internal "sigs.k8s.io/kustomize/pkg/internal/error"
@@ -94,10 +95,14 @@ func (rf *Factory) SliceFromBytes(in []byte) ([]*Resource, error) {
for len(kunStructs) > 0 { for len(kunStructs) > 0 {
u := kunStructs[0] u := kunStructs[0]
kunStructs = kunStructs[1:] kunStructs = kunStructs[1:]
if u.GetKind() == "List" { if strings.HasSuffix(u.GetKind(), "List") {
items := u.Map()["items"] items := u.Map()["items"]
itemsSlice, ok := items.([]interface{}) itemsSlice, ok := items.([]interface{})
if !ok { if !ok {
if items == nil {
// an empty list
continue
}
return nil, fmt.Errorf("items in List is type %T, expected array", items) return nil, fmt.Errorf("items in List is type %T, expected array", items)
} }
for _, item := range itemsSlice { for _, item := range itemsSlice {