Skip to content

Commit

Permalink
Make sure array Helm values always get an items field in OpenAPI schema
Browse files Browse the repository at this point in the history
The `items` field in OpenAPI schema is required, this makes sure that we
always add it, even if the default value is an empty array.

Fixes #1464.
  • Loading branch information
gcapizzi committed Jan 25, 2024
1 parent 2ebe1ba commit 0b5dccb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ func (h HelmValuesSchemaGen) calculateProperties(key *yaml3.Node, value *yaml3.N
return nil, err
}
apiKeys = append(apiKeys, &MapItem{Key: itemsKey, Value: calculatedProperties})
} else {
apiKeys = append(apiKeys, &MapItem{Key: itemsKey, Value: &Map{}})
}
case yaml3.ScalarNode:
defaultVal, err := h.getDefaultValue(value.Tag, value.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ arrKeyWithIntValues:
arrKeyWithFloatValues:
- 1.1
- 1.2
arrKeyEmpty: []
`,
want: `properties:
arrKeyEmpty:
default: []
items: {}
type: array
arrKeyWithFloatValues:
default: []
description: default value is 1.1. 1.2 is ignored
Expand Down
3 changes: 3 additions & 0 deletions cli/test/e2e/package_authoring_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ spec:
properties:
clusters:
default: []
items: {}
type: array
kubeConfigSecretName:
default: mongodb-enterprise-operator-multi-cluster-kubeconfig
Expand Down Expand Up @@ -289,6 +290,7 @@ spec:
type: string
tolerations:
default: []
items: {}
type: array
vaultSecretBackend:
properties:
Expand Down Expand Up @@ -812,6 +814,7 @@ spec:
type: object
imagePullSecrets:
default: []
items: {}
type: array
nameOverride:
default: ""
Expand Down

0 comments on commit 0b5dccb

Please sign in to comment.