-
Notifications
You must be signed in to change notification settings - Fork 762
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
Proposal - Module metadata #3187
Comments
I wrote this observation in other issue but I will repeat it here - I'd like to have ability to pack multiple independent biceps into single package. Something like a dll having multiple classes to use, not just a single one. You might have a series of small modules and creating feed for every one of them might be way too much. |
Makes sense. If we adopt that, it will also have an effect on the scopes of various metadata. For example, we'd need a package description that is separate from module description. |
The common naming convention for entry point module is |
I think making package declaration inside bicep file is not a good idea. Various systems might require different properties. Some of them (ie. git, zip over https) might require none, unless we decide that a nupkg format is required for module packs. another case might be that if we pack many files into package, and then when we reference a package - if we do not provide specific file name the main.bicep will be used (some kind of entry point). open question - if main (or the file with package declaration) uses it’s local files as modules - can we call that files when pointing to a remote? Eg we have a remote package that sets up server farm and app service . Setting up Farm and web app are nested modules called from main. - can we call just a farm module or we need to call only the top one? |
I think we will most likely go with the URI-like format for the module type (#3186), which will have a scheme-like prefix (
Regardless if decide on supporting multi-module packages or not, we will need a way to differentiate between the "entry point" (aka main.bicep) module and others. I expect it to based on some metadata or naming convention created by the
Good question. I think it should be an intentional opt-in action to expose a module in a package. "Private" or "local" modules should remain hidden and inaccessible. If we expose them, the back-compat surface gets larger (#3251) and it makes it harder to change any of the internal implementation details in a package. |
When emitting an ARM template Bicep already sets a root level metadata property, current including the Bicep version as a generator. Also since Bicep is an abstraction, make sense there would be some correlation here. {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"name": "Storage Account",
"description": "Create or update a Storage Account."
},
"parameters": {
"storageAccountName": {
"type": "string",
"metadata": {
"description": "The name of the Storage Account."
}
},
"tags": {
"type": "object",
"metadata": {
"description": "Tags to apply to the resource.",
"example": {
"service": "<service_name>",
"env": "prod"
}
}
}
},
"resources": [
]
} Something inline with option 4 seems most logical to me. |
Multi-module does not seem necessary or useful to me. It creates the need to deal with this construct when it is just as simple to publish your other modules under a different name. There should IMO only be one entrypoint allowed to a bicep module with optionally specifying the name of the entrypoint. Since OCI was chosen as the distribution format for modules this also keeps bicep modules in line with other OCI artifacts such as container images and helm charts. I think creating the infrastructure to deal with multi-module bicep packages is way more costly than publishing multiple bicep modules especially since when you reference those packages in your bicep you will need to specify the full module name anyway. |
Metadata at the module level would help with auto-generating documentation, like what PSDocs.Azure does for ARM templates. That tool reads the metadata at the template level, but there's no way to generate the ARM metadata using a Bicep decorator. Bicep decorators that generate the ARM metadata like this would be helpful: {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"name": "Storage Account",
"description": "Create or update a Storage Account."
},
...
} Even if the ARM metadata is not emitted, it would be helpful if the Bicep parser would recognize some module level metadata decorators so that we could develop a doc generation tool that reads the Bicep template rather than the compiled ARM template. For now we can define our own metadata conventions as comments, like
|
This is resolved with the brm tool: https://www.nuget.org/packages/Azure.Bicep.RegistryModuleTool/ |
@alex-frankel Is there any plan to document the brm tool? |
It is lightly documented in the contribution guide, but we should do a better job of documenting. cc @mumian / @stephaniezyen as FYI. The only tricky part is using brm requires .net, which makes the tool more trouble than it is worth for most people. I'd want to promote it more if/when it is available is a standalone binary or shipped with the bicep CLI. |
Current
Currently, any Bicep file can be consumed as a local module without modification. The identity of the module is the path on the local file system and there is no version.
Proposal
Considerations
Module authors will need a way to set the metadata before publishing a module to the registry. We will need to choose a combination of the following options:
Option 1 - Convention
Metadata values could be inferred from Bicep module contents and file metadata.
Pros:
Cons:
main.bicep
makes it less than useful.Option 2 - CLI arguments
Metadata values can be passed via CLI arguments to the
bicep pack
command:Pros:
Cons:
bicep pack
command line will become overwhelming to use correctly.Option 3 - Top-level object declaration
Pros:
Cons:
Option 4 - Top-level declaration with decorators
Pros:
Cons:
Option 5 - File-level decorators
I just made up the syntax for file-level decorators. If we are interested in exploring this option, we can come up with more options to refine it:
Pros:
Cons:
Combination Option A
package
declaration.0.0
unless specified in thepackage
declaration. Can be overridden via the--version
CLI argument inbicep pack
.package
declaration.package
declaration.Considerations:
bicep pack
works on any module without requiring apackage
declaration.package
is intended to improve package metadata quality.package.json
Combination Option B
The
package
declaration is mandatory in this option.package
declaration.0.0
unless specified in thepackage
declaration. Can be overridden via the--version
CLI argument inbicep pack
.package
declaration.package
declaration.Considerations:
bicep pack
works on any module that has apackage
declaration. Packing a module without apackage
declaration is an error.package
declaration represents the intent to publish the module to a registry.package.json
Open Questions
The text was updated successfully, but these errors were encountered: