mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
if the kind matches '*List$', treat it as a list
This commit is contained in:
@@ -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() == "" {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user