Skip to content

Commit 7b7d396

Browse files
Merge pull request #1465 from gcapizzi/fix-empty-array-items
Make sure array Helm values always get an `items` field in OpenAPI schema
2 parents 2ebe1ba + 2c641ad commit 7b7d396

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ func (h HelmValuesSchemaGen) calculateProperties(key *yaml3.Node, value *yaml3.N
203203
return nil, err
204204
}
205205
apiKeys = append(apiKeys, &MapItem{Key: itemsKey, Value: calculatedProperties})
206+
} else {
207+
apiKeys = append(apiKeys, &MapItem{Key: itemsKey, Value: &Map{}})
206208
}
207209
case yaml3.ScalarNode:
208210
defaultVal, err := h.getDefaultValue(value.Tag, value.Value)

cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ arrKeyWithIntValues:
3939
arrKeyWithFloatValues:
4040
- 1.1
4141
- 1.2
42+
arrKeyEmpty: []
4243
`,
4344
want: `properties:
45+
arrKeyEmpty:
46+
default: []
47+
items: {}
48+
type: array
4449
arrKeyWithFloatValues:
4550
default: []
4651
description: default value is 1.1. 1.2 is ignored

cli/test/e2e/package_authoring_e2e_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ spec:
252252
properties:
253253
clusters:
254254
default: []
255+
items: {}
255256
type: array
256257
kubeConfigSecretName:
257258
default: mongodb-enterprise-operator-multi-cluster-kubeconfig
@@ -289,6 +290,7 @@ spec:
289290
type: string
290291
tolerations:
291292
default: []
293+
items: {}
292294
type: array
293295
vaultSecretBackend:
294296
properties:
@@ -812,6 +814,7 @@ spec:
812814
type: object
813815
imagePullSecrets:
814816
default: []
817+
items: {}
815818
type: array
816819
nameOverride:
817820
default: ""

0 commit comments

Comments
 (0)