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

Custom types for Bicep #3723

Closed
johnnyreilly opened this issue Jul 22, 2021 · 4 comments
Closed

Custom types for Bicep #3723

johnnyreilly opened this issue Jul 22, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@johnnyreilly
Copy link
Contributor

johnnyreilly commented Jul 22, 2021

Apologies if this is a dupe - I've scanned the open issues and didn't spot it.

Is your feature request related to a problem? Please describe.

Consider the following:

@description('The config for the eventhubs')
param eventHubConfigs array = []

The type of the above will be an array of any. It's going to be exercised by something like this:

module senderEventHub '../../../infra/eventhub/main.bicep' = {
  name: 'senderEventHubDeploy'
  params: {
    location: location
    env: env
    tags: tags
    eventHubNamespaceName: senderEventHubNamespaceName
    eventHubConfigs: [
      // note the type here
      {
        name: 'echo_v4'
        messageRetentionInDays: eventHubMessageRetentionInDays
        partitionCount: eventHubPartitionCount
      }
    ]
    // ...
  }
}

Unless I'm missing something in the docs there doesn't seem to be a way to define a custom type which could be used to more directly describe the type of the array. This means people can supply invalid values.

Describe the solution you'd like

It would be amazing if there was a way to specify a custom type. eg:

type EventHubConfig {
    name: string
    messageRetentionInDays: number
    partitionCount: number
}

which could be used something like this:

@description('The config for the eventhubs')
param eventHubConfigs array<EventHubConfig> = []

What do you think?

@johnnyreilly johnnyreilly added the enhancement New feature or request label Jul 22, 2021
@ghost ghost added the Needs: Triage 🔍 label Jul 22, 2021
@shenglol
Copy link
Contributor

Related to #622.

@alex-frankel
Copy link
Collaborator

FWIW, I think this is two step process:

  1. Allow referencing existing resource property types (i.e. Microsft.Storage.StorageAccounts('2020-06-01').sku)
  2. Allow for full custom types - particularly when defining parameter types for modules as you've described

@hansmbakker
Copy link

I think this is a duplicate of #8673?

@jeskew
Copy link
Contributor

jeskew commented Sep 11, 2023

Closing as duplicate of #4158

@jeskew jeskew closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants