-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bicep: Support @sealed()
decorator on user defined types
#4684
Conversation
When the `@sealed()` decorator is applied on user defined types, it causes an `additionalProperties: false` property to be added to the type defintition in the generated arm deployment. Our unmarshalling logic did not understand this pattern and so it would cause an error when trying to unmarshall this, since it expected if `additionalProperties` was set, it would be to set to an object that described information about the additional properties. I've updated the marshalling code to support `false` as a valid value for the additional properties node when parsing an ARM template. Since Go doesn't have great support for modeling descrimited unions, the new `ArmTemplateParameterAdditionalPropertiesValue` type is used to provide the logcal descrimited union of `false` or a object like value. Fixes Azure#4659
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have more context in this part of the code than I do, @vhvb1989, so you'll have a better sense of if I did the right thing here or not.
I'm not sure if there's a case where they can emit additionalProperties
as true
(I think this is allowed by JSON Schema, but I'm not sure if bicep ever emits this), but it wasn't clear exactly to me what we should do when AdditionalProperties
was true
. I think in practice we don't have to analyze this part of the document, just make sure as we transform it we keep the text the user provided. I could imagine changing ArmTemplateParameterAdditionalPropertiesValue
to also have a *bool
field, with the idea that either it or the *ArmTemplateParameterAdditionalPropertiesProperties
is always set (the bool is set to true or false if it was in the document, otherwise the value was an object and the props
field is set), and we also modify MarshalJSON
to emit true
when needed.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash:
pwsh:
WindowsPowerShell install
MSI install
Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When the
@sealed()
decorator is applied on user defined types, it causes anadditionalProperties: false
property to be added to the type defintition in the generated arm deployment. Our unmarshalling logic did not understand this pattern and so it would cause an error when trying to unmarshall this, since it expected ifadditionalProperties
was set, it would be to set to an object that described information about the additional properties.I've updated the marshalling code to support
false
as a valid value for the additional properties node when parsing an ARM template. Since Go doesn't have great support for modeling descrimited unions, the newArmTemplateParameterAdditionalPropertiesValue
type is used to provide the logcal descrimited union offalse
or a object like value.Fixes #4659