Skip to content

Commit c163468

Browse files
Merge pull request #11 from ryane/fix-kind-list
support for List resources
2 parents 5edb358 + 91a9040 commit c163468

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

cmd/convert.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,20 @@ func newResources(in []byte) ([]*resource.Resource, error) {
256256
var out map[string]interface{}
257257
err = decoder.Decode(&out)
258258
if err == nil {
259-
result = append(result, rf.FromMap(out))
259+
// ignore empty chunks
260+
if len(out) == 0 {
261+
continue
262+
}
263+
264+
if list, ok := isList(out); ok {
265+
for _, i := range list {
266+
if item, ok := i.(map[string]interface{}); ok {
267+
result = append(result, rf.FromMap(item))
268+
}
269+
}
270+
} else {
271+
result = append(result, rf.FromMap(out))
272+
}
260273
}
261274
}
262275
if err != io.EOF {
@@ -283,3 +296,13 @@ func prettyError(err error) error {
283296
func defaultKeyring() string {
284297
return os.ExpandEnv("$HOME/.gnupg/pubring.gpg")
285298
}
299+
300+
func isList(res map[string]interface{}) ([]interface{}, bool) {
301+
itemList, ok := res["items"]
302+
if !ok {
303+
return nil, false
304+
}
305+
306+
items, ok := itemList.([]interface{})
307+
return items, ok
308+
}

0 commit comments

Comments
 (0)