From bdbfb28139db6eefb2c5c147323d78a2894041d2 Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Tue, 12 Jan 2021 16:13:40 -0800 Subject: [PATCH] Unwrap ResourceList with a functionConfig but no items --- kyaml/kio/byteio_reader.go | 2 +- kyaml/kio/byteio_reader_test.go | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/kyaml/kio/byteio_reader.go b/kyaml/kio/byteio_reader.go index f14f13bfa..7469698f4 100644 --- a/kyaml/kio/byteio_reader.go +++ b/kyaml/kio/byteio_reader.go @@ -178,7 +178,7 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) { if !r.DisableUnwrapping && len(values) == 1 && // Only unwrap if there is only 1 value (meta.Kind == ResourceListKind || meta.Kind == "List") && - node.Field("items") != nil { + (node.Field("items") != nil || node.Field("functionConfig") != nil) { r.WrappingKind = meta.Kind r.WrappingAPIVersion = meta.APIVersion diff --git a/kyaml/kio/byteio_reader_test.go b/kyaml/kio/byteio_reader_test.go index 043eff101..41c43182b 100644 --- a/kyaml/kio/byteio_reader_test.go +++ b/kyaml/kio/byteio_reader_test.go @@ -94,6 +94,29 @@ spec: elems: - a - b +- c`, + wrappingAPIVersion: ResourceListAPIVersion, + wrappingAPIKind: ResourceListKind, + }, + // + // + // + { + name: "wrapped_resource_list_function_config_without_items", + input: `apiVersion: config.kubernetes.io/v1alpha1 +kind: ResourceList +functionConfig: + foo: bar + elems: + - a + - b + - c +`, + expectedItems: []string{}, + expectedFunctionConfig: `foo: bar +elems: +- a +- b - c`, wrappingAPIVersion: ResourceListAPIVersion, wrappingAPIKind: ResourceListKind,