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

Added ability to detect optionality for each Parameter #68

Merged
merged 8 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change log

## Unreleased
- General improvements:
- Added ability to detect "Required" or "Optional for each parameter. [#55](https://github.com/Azure/PSDocs.Azure/issues/55)
- Detects if parameter is either "Optional" or "Required" based on the availability of `DefaultValue` or `AllowedValues`

## v0.3.0-B2103011 (pre-release)

Expand Down
9 changes: 7 additions & 2 deletions src/PSDocs.Azure/docs/Azure.Template.Doc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ function global:GetTemplateParameter {
Description = ''
DefaultValue = $Null
AllowedValues = $Null
Required = "Required"
Copy link
Contributor

Choose a reason for hiding this comment

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

@vicperdana Potentially this can be localized as well since it will be part of the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BernieWhite just to clarify, would this be related to:
$LocalizedData.Required in line number 238.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vicperdana More suggesting that we Required now Yes / No can be localized.

So at some point, if someone wants to localize PSDocs.Azure then Yes/ No can be specified in another language.

I've added the suggestion as a commit.

}
if ([bool]$property.Value.PSObject.Properties['metadata'] -and [bool]$property.Value.metadata.PSObject.Properties['description']) {
$result.Description = $property.Value.metadata.description;
}
if ([bool]$property.Value.PSObject.Properties['defaultValue']) {
$result.DefaultValue = $property.Value.defaultValue;
$result.Required = "Optional"
vicperdana marked this conversation as resolved.
Show resolved Hide resolved
}
if ([bool]$property.Value.PSObject.Properties['allowedValues']) {
$result.AllowedValues = $property.Value.allowedValues;
$result.Required = "Optional"
vicperdana marked this conversation as resolved.
Show resolved Hide resolved
}
$result;
}
Expand Down Expand Up @@ -232,11 +235,13 @@ Document 'README' {

# Add table and detail for each parameter
Section $LocalizedData.Parameters {
$parameters | Table -Property @{ Name = $LocalizedData.ParameterName; Expression = { $_.Name }},
@{ Name = $LocalizedData.Description; Expression = { $_.Description }}
$parameters | Table -Property @{ Name = $LocalizedData.ParameterName; Expression = { $_.Name }},
@{ Name = $LocalizedData.Required; Expression = { $_.Required }},
@{ Name = $LocalizedData.Description; Expression = { $_.Description }}

foreach ($parameter in $parameters) {
Section $parameter.Name {
$parameter.Required;
$parameter.Description;

if (![String]::IsNullOrEmpty($parameter.DefaultValue)) {
Expand Down
1 change: 1 addition & 0 deletions src/PSDocs.Azure/en/PSDocs-strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
DefaultTitle = 'Azure template'
ParameterFile = 'Parameter file'
CommandLine = 'Command line'
Required = 'Required'
}
20 changes: 14 additions & 6 deletions templates/acr/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ Create or update a Container Registry.

## Parameters

Parameter name | Description
-------------- | -----------
registryName | Required. The name of the container registry.
location | Optional. The location to deploy the container registry.
registrySku | Optional. The container registry SKU.
tags | Optional. Tags to apply to the resource.
Parameter name | Required | Description
-------------- | -------- | -----------
registryName | Required | Required. The name of the container registry.
location | Optional | Optional. The location to deploy the container registry.
registrySku | Optional | Optional. The container registry SKU.
tags | Optional | Optional. Tags to apply to the resource.

### registryName

Required
vicperdana marked this conversation as resolved.
Show resolved Hide resolved

Required. The name of the container registry.

### location

Optional

Optional. The location to deploy the container registry.

- Default value: `[resourceGroup().location]`

### registrySku

Optional

Optional. The container registry SKU.

- Default value: `Basic`
Expand All @@ -33,6 +39,8 @@ Optional. The container registry SKU.

### tags

Optional

Optional. Tags to apply to the resource.

## Snippets
Expand Down
48 changes: 35 additions & 13 deletions templates/keyvault/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,98 @@ Create or update a Key Vault.

## Parameters

Parameter name | Description
-------------- | -----------
vaultName | Required. The name of the Key Vault.
location | Optional. The Azure region to deploy to.
accessPolicies | Optional. The access policies defined for this vault.
useDeployment | Optional. Determines if Azure can deploy certificates from this Key Vault.
useTemplate | Optional. Determines if templates can reference secrets from this Key Vault.
useDiskEncryption | Optional. Determines if this Key Vault can be used for Azure Disk Encryption.
useSoftDelete | Optional. Determine if soft delete is enabled on this Key Vault.
usePurgeProtection | Optional. Determine if purge protection is enabled on this Key Vault.
networkAcls | Optional. The network firewall defined for this vault.
workspaceId | Optional. The workspace to store audit logs.
tags | Optional. Tags to apply to the resource.
Parameter name | Required | Description
-------------- | -------- | -----------
vaultName | Required | Required. The name of the Key Vault.
location | Optional | Optional. The Azure region to deploy to.
accessPolicies | Optional | Optional. The access policies defined for this vault.
useDeployment | Optional | Optional. Determines if Azure can deploy certificates from this Key Vault.
useTemplate | Optional | Optional. Determines if templates can reference secrets from this Key Vault.
useDiskEncryption | Optional | Optional. Determines if this Key Vault can be used for Azure Disk Encryption.
useSoftDelete | Optional | Optional. Determine if soft delete is enabled on this Key Vault.
usePurgeProtection | Optional | Optional. Determine if purge protection is enabled on this Key Vault.
networkAcls | Optional | Optional. The network firewall defined for this vault.
workspaceId | Optional | Optional. The workspace to store audit logs.
tags | Optional | Optional. Tags to apply to the resource.

### vaultName

Required

Required. The name of the Key Vault.

### location

Optional

Optional. The Azure region to deploy to.

- Default value: `[resourceGroup().location]`

### accessPolicies

Optional

Optional. The access policies defined for this vault.

### useDeployment

Optional

Optional. Determines if Azure can deploy certificates from this Key Vault.

- Default value: `False`

### useTemplate

Optional

Optional. Determines if templates can reference secrets from this Key Vault.

- Default value: `False`

### useDiskEncryption

Optional

Optional. Determines if this Key Vault can be used for Azure Disk Encryption.

- Default value: `False`

### useSoftDelete

Optional

Optional. Determine if soft delete is enabled on this Key Vault.

- Default value: `True`

### usePurgeProtection

Optional

Optional. Determine if purge protection is enabled on this Key Vault.

- Default value: `True`

### networkAcls

Optional

Optional. The network firewall defined for this vault.

- Default value: `@{defaultAction=Allow; bypass=AzureServices; ipRules=System.Object[]; virtualNetworkRules=System.Object[]}`

### workspaceId

Optional

Optional. The workspace to store audit logs.

### tags

Optional

Optional. Tags to apply to the resource.

## Outputs
Expand Down
60 changes: 44 additions & 16 deletions templates/storage/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,41 @@ This template deploys a Storage Account including blob containers and files shar

## Parameters

Parameter name | Description
-------------- | -----------
storageAccountName | Required. The name of the Storage Account.
location | Optional. The Azure region to deploy to.
sku | Optional. Create the Storage Account as LRS or GRS.
suffixLength | Optional. Determine how many additional characters are added to the storage account name as a suffix.
containers | Optional. An array of storage containers to create on the storage account.
lifecycleRules | Optional. An array of lifecycle management policies for the storage account.
blobSoftDeleteDays | Optional. The number of days to retain deleted blobs. When set to 0, soft delete is disabled.
containerSoftDeleteDays | Optional. The number of days to retain deleted containers. When set to 0, soft delete is disabled.
shares | Optional. An array of file shares to create on the storage account.
useLargeFileShares | Optional. Determines if large file shares are enabled. This can not be disabled once enabled.
shareSoftDeleteDays | Optional. The number of days to retain deleted shares. When set to 0, soft delete is disabled.
allowBlobPublicAccess | Optional. Determines if any containers can be configured with the anonymous access types of blob or container.
keyVaultPrincipalId | Optional. Set to the objectId of Azure Key Vault to delegated permission for use with Key Managed Storage Accounts.
tags | Optional. Tags to apply to the resource.
Parameter name | Required | Description
-------------- | -------- | -----------
storageAccountName | Required | Required. The name of the Storage Account.
location | Optional | Optional. The Azure region to deploy to.
sku | Optional | Optional. Create the Storage Account as LRS or GRS.
suffixLength | Optional | Optional. Determine how many additional characters are added to the storage account name as a suffix.
containers | Optional | Optional. An array of storage containers to create on the storage account.
lifecycleRules | Optional | Optional. An array of lifecycle management policies for the storage account.
blobSoftDeleteDays | Optional | Optional. The number of days to retain deleted blobs. When set to 0, soft delete is disabled.
containerSoftDeleteDays | Optional | Optional. The number of days to retain deleted containers. When set to 0, soft delete is disabled.
shares | Optional | Optional. An array of file shares to create on the storage account.
useLargeFileShares | Optional | Optional. Determines if large file shares are enabled. This can not be disabled once enabled.
shareSoftDeleteDays | Optional | Optional. The number of days to retain deleted shares. When set to 0, soft delete is disabled.
allowBlobPublicAccess | Optional | Optional. Determines if any containers can be configured with the anonymous access types of blob or container.
keyVaultPrincipalId | Optional | Optional. Set to the objectId of Azure Key Vault to delegated permission for use with Key Managed Storage Accounts.
tags | Optional | Optional. Tags to apply to the resource.

### storageAccountName

Required

Required. The name of the Storage Account.

### location

Optional

Optional. The Azure region to deploy to.

- Default value: `[resourceGroup().location]`

### sku

Optional

Optional. Create the Storage Account as LRS or GRS.

- Default value: `Standard_LRS`
Expand All @@ -45,58 +51,80 @@ Optional. Create the Storage Account as LRS or GRS.

### suffixLength

Optional

Optional. Determine how many additional characters are added to the storage account name as a suffix.

- Default value: `0`

### containers

Optional

Optional. An array of storage containers to create on the storage account.

### lifecycleRules

Optional

Optional. An array of lifecycle management policies for the storage account.

### blobSoftDeleteDays

Optional

Optional. The number of days to retain deleted blobs. When set to 0, soft delete is disabled.

- Default value: `0`

### containerSoftDeleteDays

Optional

Optional. The number of days to retain deleted containers. When set to 0, soft delete is disabled.

- Default value: `0`

### shares

Optional

Optional. An array of file shares to create on the storage account.

### useLargeFileShares

Optional

Optional. Determines if large file shares are enabled. This can not be disabled once enabled.

- Default value: `False`

### shareSoftDeleteDays

Optional

Optional. The number of days to retain deleted shares. When set to 0, soft delete is disabled.

- Default value: `0`

### allowBlobPublicAccess

Optional

Optional. Determines if any containers can be configured with the anonymous access types of blob or container.

- Default value: `False`

### keyVaultPrincipalId

Optional

Optional. Set to the objectId of Azure Key Vault to delegated permission for use with Key Managed Storage Accounts.

### tags

Optional

Optional. Tags to apply to the resource.

## Outputs
Expand Down