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

Add variables support #511

Merged
merged 3 commits into from
Aug 8, 2024
Merged

Add variables support #511

merged 3 commits into from
Aug 8, 2024

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Aug 3, 2024

PR Summary

Add ability to have variables section in config and variables() function implementation. Note that due to how serde works by default, duplicates don't error and last one wins (created #510)

Also added some additional debug tracing to parser to understand why array indexing didn't work. Turns out I missed implementing it #509

PR Context

Part of #57

myParameter:
type: string
# the use of `concat()` here is just an example of using an expression for a defaultValue
defaultValue: "[concat('world','!')]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a difference between parameters and variables:
parameters have 2 subfields: type and defaultValue,
but looks like variables have just implied defaultValue and type is implicitly derived.
Should this be consistent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took this directly from ARM. variables are intended to just be used to keep values that get reused multiple times within the config and typically constructed from params based on examples I saw.

$out.results[0].result.actualState.output | Should -Be 'bar'
}

It 'Missing variable returns error' {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The essence of a variable in any language is that it's value can be changed; I don't see such example or tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, but that's not how it's used in an ARM template

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 8, 2024
Merged via the queue into PowerShell:main with commit 47479f7 Aug 8, 2024
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the variables branch August 8, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants