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
ellismg
left a comment
There was a problem hiding this comment.
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
|
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
When the
@sealed()decorator is applied on user defined types, it causes anadditionalProperties: falseproperty 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 ifadditionalPropertieswas set, it would be to set to an object that described information about the additional properties.I've updated the marshalling code to support
falseas 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 newArmTemplateParameterAdditionalPropertiesValuetype is used to provide the logcal descrimited union offalseor a object like value.Fixes #4659