Skip to content
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

DevDiv meeting "notes" 9/30 #592

Closed
majastrz opened this issue Oct 2, 2020 · 3 comments
Closed

DevDiv meeting "notes" 9/30 #592

majastrz opened this issue Oct 2, 2020 · 3 comments

Comments

@majastrz
Copy link
Member

majastrz commented Oct 2, 2020

Summary

We spent most of the meeting discussing the problem of conditionally adding a property to a resource payload and making that consistent with other usage of conditionals in the language. (Covered JS spread operator as well as various variations of imperative and declarative conditional constructs).

Code Examples

The following are the syntax mockups we came up with during the meeting. I'm saving them here so we can reuse them during a team discussion:

if(resourceCondition) {
    resource foo 'res type' = {
        name: 'foo'
        properties: {
            p: 'v1'
            p2: x

            if(condition2) {
                weirdProperty: true
                relatedProperty: 222
            }

            otherWeirdProperty: condition ? 4 : undefined

            ...(condition ? { myProp: 4} : {})
        }
    }
}

/// break 
...
 dependsOn: [ foo ]
...

/// break

resource foo 'res type' = 
    if (condition) {
        name: 'foo'
        properties: {
            p: 'v1'
            p2: x

            if(condition2) {
                weirdProperty: true
                relatedProperty: 222
            }

            otherProperty: if (otherCondition) {

            }

            otherWeirdProperty: condition ? 4 : undefined

            ...(condition ? { myProp: 4} : {})
        }
    }
@WhitWaldo
Copy link

It'd be fantastic to see support for this, especially so I can create a single bicep file to conditionally include properties based on whether or not I'm deploying Windows or Linux machines.

Any idea of which version this might be slated for release in?

@alex-frankel
Copy link
Collaborator

We are starting the work on conditions now, so it should be available before the end of the year. Work is tracked with #186

@shenglol
Copy link
Contributor

shenglol commented Nov 19, 2020

I've verified with a custom resource provider and an ARM integration test that ARM won't strip out null values before sending requests to RPs, which means we cannot rely on using ternary operator with null to conditionally set a resource property. We'll have to choose a syntax for conditional properties.

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants