-
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
Support @allowed attribute on custom type array values #9395
Comments
You can use a union type: @allowed([
'Get'
'List'
'Set'
'Delete'
'Backup'
'Recover'
])
secrets: string[] would become: secrets: ('Get' | 'List' | 'Set' | 'Delete' | 'Backup' | 'Recover')[] |
That did the trick precisely, though my lines are a bit long now. In the name of readability, is there any possibility of having type AccessPolicyPermissionsSet = {
keys: ('Get' | 'List' | 'Update' | 'Create' | 'Import' | 'Delete' | 'Recover' | 'Backup' | 'Restore' | 'GetRotationPolicy' | 'SetRotationPolicy' | 'Rotate')[]
secrets: ('Get' | 'List' | 'Set' | 'Delete' | 'Recover' | 'Backup' | 'Restore')[]
certificates: ('Get' | 'List' | 'Update' | 'Create' | 'Import' | 'Delete' | 'Recover' | 'Backup' | 'Restore' | 'ManageContacts' | 'ManageIssuers' | 'GetIssuers' | 'ListIssuers' | 'SetIssuers' | 'DeleteIssuers')[]
}
type AccessPolicy = {
tenantId: string
principalId: string
permissions: AccessPolicyPermissionsSet
} |
Generally speaking, Bicep tries to follow a "There should be one-- and preferably only one --obvious way to do it" rule, so alternate syntax for something that can already be expressed is discouraged. I opened #9441 to allow multiline union types, which may help. |
@jeskew I understand the motivation there, but especially as the language evolves, I suspect you'll increasingly find users confused by " Again, while I'd encourage a "should be only one" approach, please don't make that a hard and fast rule for all syntax as some of these language design ships have already sailed. |
Reopening since there was another ask for this and I'd like to keep the discussion consolidated. |
If there's strong community support for this ask, I will back down, but I dislike the The issues I have with
Composability concerns only come into play when |
I knew I'd asked this before - I admit, I didn't think to remove the "closed" filter while searching for it earlier. My mistake! While I think I'd argue that the ship has sailed and that by having the Might I instead then suggest a rule (don't know if this is a good linting candidate or for some other sort of project analyzer) that when I attempt to specify an |
This is another request related to custom types. I suddenly have a new requirement to spin up a Key Vault instance using Access Policies. I'd like to be able to fully define the desired shape of the per-object policy via custom types, but the lack of support for
@allowed
stands in the way of that. What I'd like to do is the following:But.. because I cannot today use
@allowed
, I have to entirely opt out of custom types for this purpose leaving me with either specifying the individual arrays themselves for each permission type or opting out altogether and just doing:This is far from ideal
Thanks for the consideration!
The text was updated successfully, but these errors were encountered: