-
Notifications
You must be signed in to change notification settings - Fork 760
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
Add Optional KeyName Param to Items() Function #9503
Comments
Out of interest, why do you feel like the
|
Well, it's not terrible but NVP is a standard datatype so it felt like there ought to be a shorter, normal'ish looking method like passing in a param or casting the KVP to an NVP to get the right value. It took me longer than it should have to realize the only difference between the working and non-working object was just the key name. The appsettings property doesn't complain about being given an invalid object, it just fails. If the name is seeded from the start the intent is clear that we want the format returned by I get it though, it's nothing egregious. |
After reviewing Azure/ResourceModules using the
Since the primary use case for this feature request is no longer relevant going to close this out. |
As mentioned in #1427, I wish you could pass in a KeyName param to the
items()
function likeitems(myObj, "name")
. This change would make it easier for users to work with Bicep properties that only accept NameValuePairs and not KeyValuePairs. One such property is SiteConfig/Appsettings and although I can usemap((items(appsettings)), arg => {name: arg.key, value: arg.value})
to reconstruct the object list it feels inelegant.I guess another way of going about this would be making NameValuePair and KeyValuePair interchangeable data types but I imagine those changes would be more work than my proposal.
Also, I realize this is a pipe dream but the NameValuePair stuff makes SiteConfig/Appsettings difficult to work with because you can't do StructuredTransforms on a parameter file when the key names are all the same. Additionally, the
items()
function only works on the first depth of an object and there is no way to recurse a child object (far as I know) to produce a flattened object. So, a single level appsettings.json could work but users will probably make the mistake of thinking they can nest and we can't validate a JSON schema against it yet.If we had a
flatten()
function which could takeand convert it to
that would allow us to use
items()
to convert it to NameValuePair and pass it to SiteConfig/Appsettings with minimal (user) effort. I imagine that it would look like thisitems(flatten(loadJsonContent('appsettings.json'), "--"), "name")
in practice. Maybe that's where User Defined Functions will come in down the road? I guess I can't really think of where else aflatten()
function would come in handy so... yeah.Anyway, thanks for listening.
The text was updated successfully, but these errors were encountered: