Skip to content

Commit

Permalink
Don't use a string as the OpenAPI default value for Helm values with …
Browse files Browse the repository at this point in the history
…an empty object default

This fixes the translation of empty object Helm default values into
OpenAPI. Empty objects were getting the string `"{}"` as their default,
which is not a valid value. We now correctly use `{}`.

Signed-off-by: Giuseppe Capizzi <[email protected]>
  • Loading branch information
gcapizzi committed Jan 22, 2024
1 parent 0972b2f commit a0b9617
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (h HelmValuesSchemaGen) calculateProperties(key *yaml3.Node, value *yaml3.N
if len(properties) > 0 {
apiKeys = append(apiKeys, &MapItem{Key: propertiesKey, Value: &Map{Items: properties}})
} else {
apiKeys = append(apiKeys, &MapItem{Key: defaultKey, Value: "{}"})
apiKeys = append(apiKeys, &MapItem{Key: defaultKey, Value: &Map{}})
}
case yaml3.SequenceNode:
apiKeys = append(apiKeys, &MapItem{Key: typeKey, Value: arrayVal})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ arrExample:
floatExample: 2.3
# Integer example
intExample: 3
# Object example
objExample: {}
`,
want: `properties:
arrExample:
Expand Down Expand Up @@ -111,6 +113,10 @@ intExample: 3
default: test-container
description: Container name
type: string
objExample:
default: {}
description: Object example
type: object
type: object
`},
{
Expand Down
8 changes: 4 additions & 4 deletions cli/test/e2e/package_authoring_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ spec:
operator:
properties:
affinity:
default: '{}'
default: {}
type: object
createOperatorServiceAccount:
default: true
Expand All @@ -281,7 +281,7 @@ spec:
objects like Deployment, ServiceAccount, Role etc.
type: string
nodeSelector:
default: '{}'
default: {}
type: object
operator_image_name:
default: mongodb-enterprise-operator
Expand Down Expand Up @@ -817,7 +817,7 @@ spec:
default: ""
type: string
podAnnotations:
default: '{}'
default: {}
type: object
replicaCount:
default: 1
Expand All @@ -834,7 +834,7 @@ spec:
serviceAccount:
properties:
annotations:
default: '{}'
default: {}
description: Annotations to add to the service account
type: object
create:
Expand Down

0 comments on commit a0b9617

Please sign in to comment.