Skip to content

Commit a85b88d

Browse files
Added ability to detect optionality for each Parameter (#68)
Added ability to detect "Required" or "Optional for each parameter. Closes #55 - Detects if parameter is either "Optional" or "Required" based on the availability of DefaultValue or AllowedValues - Added a "Required" column - Added "Required" and "Optional" badge for each parameter Co-authored-by: Bernie White <bewhite@microsoft.com>
1 parent b1785bd commit a85b88d

File tree

6 files changed

+116
-37
lines changed

6 files changed

+116
-37
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change log
22

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

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

src/PSDocs.Azure/docs/Azure.Template.Doc.ps1

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ function global:GetTemplateParameter {
2020
Description = ''
2121
DefaultValue = $Null
2222
AllowedValues = $Null
23+
Required = $Null
2324
}
2425
if ([bool]$property.Value.PSObject.Properties['metadata'] -and [bool]$property.Value.metadata.PSObject.Properties['description']) {
2526
$result.Description = $property.Value.metadata.description;
2627
}
2728
if ([bool]$property.Value.PSObject.Properties['defaultValue']) {
2829
$result.DefaultValue = $property.Value.defaultValue;
30+
$result.Required = "Optional"
2931
}
3032
if ([bool]$property.Value.PSObject.Properties['allowedValues']) {
3133
$result.AllowedValues = $property.Value.allowedValues;
@@ -232,11 +234,24 @@ Document 'README' {
232234

233235
# Add table and detail for each parameter
234236
Section $LocalizedData.Parameters {
235-
$parameters | Table -Property @{ Name = $LocalizedData.ParameterName; Expression = { $_.Name }},
236-
@{ Name = $LocalizedData.Description; Expression = { $_.Description }}
237+
$parameters | Table -Property @{ Name = $LocalizedData.ParameterName; Expression = { $_.Name }},
238+
@{ Name = $LocalizedData.Required; Expression = {
239+
if($_.Required) {
240+
$LocalizedData.RequiredNo
241+
}
242+
else {
243+
$LocalizedData.RequiredYes
244+
}
245+
}
246+
},
247+
@{ Name = $LocalizedData.Description; Expression = { $_.Description }}
237248

238249
foreach ($parameter in $parameters) {
239250
Section $parameter.Name {
251+
if($parameter.Required){
252+
"![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)"
253+
}
254+
else{ "![Parameter Setting](https://img.shields.io/badge/parameter-required-orange?style=flat-square)" }
240255
$parameter.Description;
241256

242257
if (![String]::IsNullOrEmpty($parameter.DefaultValue)) {

src/PSDocs.Azure/en/PSDocs-strings.psd1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
DefaultTitle = 'Azure template'
1515
ParameterFile = 'Parameter file'
1616
CommandLine = 'Command line'
17+
Required = 'Required'
18+
RequiredYes = 'Yes'
19+
RequiredNo = 'No'
1720
}

templates/acr/v1/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,31 @@ Create or update a Container Registry.
66

77
## Parameters
88

9-
Parameter name | Description
10-
-------------- | -----------
11-
registryName | Required. The name of the container registry.
12-
location | Optional. The location to deploy the container registry.
13-
registrySku | Optional. The container registry SKU.
14-
tags | Optional. Tags to apply to the resource.
9+
Parameter name | Required | Description
10+
-------------- | -------- | -----------
11+
registryName | Yes | Required. The name of the container registry.
12+
location | No | Optional. The location to deploy the container registry.
13+
registrySku | No | Optional. The container registry SKU.
14+
tags | No | Optional. Tags to apply to the resource.
1515

1616
### registryName
1717

18+
![Parameter Setting](https://img.shields.io/badge/parameter-required-orange?style=flat-square)
19+
1820
Required. The name of the container registry.
1921

2022
### location
2123

24+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
25+
2226
Optional. The location to deploy the container registry.
2327

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

2630
### registrySku
2731

32+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
33+
2834
Optional. The container registry SKU.
2935

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

3440
### tags
3541

42+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
43+
3644
Optional. Tags to apply to the resource.
3745

3846
## Snippets

templates/keyvault/v1/README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,98 @@ Create or update a Key Vault.
66

77
## Parameters
88

9-
Parameter name | Description
10-
-------------- | -----------
11-
vaultName | Required. The name of the Key Vault.
12-
location | Optional. The Azure region to deploy to.
13-
accessPolicies | Optional. The access policies defined for this vault.
14-
useDeployment | Optional. Determines if Azure can deploy certificates from this Key Vault.
15-
useTemplate | Optional. Determines if templates can reference secrets from this Key Vault.
16-
useDiskEncryption | Optional. Determines if this Key Vault can be used for Azure Disk Encryption.
17-
useSoftDelete | Optional. Determine if soft delete is enabled on this Key Vault.
18-
usePurgeProtection | Optional. Determine if purge protection is enabled on this Key Vault.
19-
networkAcls | Optional. The network firewall defined for this vault.
20-
workspaceId | Optional. The workspace to store audit logs.
21-
tags | Optional. Tags to apply to the resource.
9+
Parameter name | Required | Description
10+
-------------- | -------- | -----------
11+
vaultName | Yes | Required. The name of the Key Vault.
12+
location | No | Optional. The Azure region to deploy to.
13+
accessPolicies | No | Optional. The access policies defined for this vault.
14+
useDeployment | No | Optional. Determines if Azure can deploy certificates from this Key Vault.
15+
useTemplate | No | Optional. Determines if templates can reference secrets from this Key Vault.
16+
useDiskEncryption | No | Optional. Determines if this Key Vault can be used for Azure Disk Encryption.
17+
useSoftDelete | No | Optional. Determine if soft delete is enabled on this Key Vault.
18+
usePurgeProtection | No | Optional. Determine if purge protection is enabled on this Key Vault.
19+
networkAcls | No | Optional. The network firewall defined for this vault.
20+
workspaceId | No | Optional. The workspace to store audit logs.
21+
tags | No | Optional. Tags to apply to the resource.
2222

2323
### vaultName
2424

25+
![Parameter Setting](https://img.shields.io/badge/parameter-required-orange?style=flat-square)
26+
2527
Required. The name of the Key Vault.
2628

2729
### location
2830

31+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
32+
2933
Optional. The Azure region to deploy to.
3034

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

3337
### accessPolicies
3438

39+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
40+
3541
Optional. The access policies defined for this vault.
3642

3743
### useDeployment
3844

45+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
46+
3947
Optional. Determines if Azure can deploy certificates from this Key Vault.
4048

4149
- Default value: `False`
4250

4351
### useTemplate
4452

53+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
54+
4555
Optional. Determines if templates can reference secrets from this Key Vault.
4656

4757
- Default value: `False`
4858

4959
### useDiskEncryption
5060

61+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
62+
5163
Optional. Determines if this Key Vault can be used for Azure Disk Encryption.
5264

5365
- Default value: `False`
5466

5567
### useSoftDelete
5668

69+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
70+
5771
Optional. Determine if soft delete is enabled on this Key Vault.
5872

5973
- Default value: `True`
6074

6175
### usePurgeProtection
6276

77+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
78+
6379
Optional. Determine if purge protection is enabled on this Key Vault.
6480

6581
- Default value: `True`
6682

6783
### networkAcls
6884

85+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
86+
6987
Optional. The network firewall defined for this vault.
7088

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

7391
### workspaceId
7492

93+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
94+
7595
Optional. The workspace to store audit logs.
7696

7797
### tags
7898

99+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
100+
79101
Optional. Tags to apply to the resource.
80102

81103
## Outputs

templates/storage/v1/README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,41 @@ This template deploys a Storage Account including blob containers and files shar
88

99
## Parameters
1010

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

2828
### storageAccountName
2929

30+
![Parameter Setting](https://img.shields.io/badge/parameter-required-orange?style=flat-square)
31+
3032
Required. The name of the Storage Account.
3133

3234
### location
3335

36+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
37+
3438
Optional. The Azure region to deploy to.
3539

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

3842
### sku
3943

44+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
45+
4046
Optional. Create the Storage Account as LRS or GRS.
4147

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

4652
### suffixLength
4753

54+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
55+
4856
Optional. Determine how many additional characters are added to the storage account name as a suffix.
4957

5058
- Default value: `0`
5159

5260
### containers
5361

62+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
63+
5464
Optional. An array of storage containers to create on the storage account.
5565

5666
### lifecycleRules
5767

68+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
69+
5870
Optional. An array of lifecycle management policies for the storage account.
5971

6072
### blobSoftDeleteDays
6173

74+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
75+
6276
Optional. The number of days to retain deleted blobs. When set to 0, soft delete is disabled.
6377

6478
- Default value: `0`
6579

6680
### containerSoftDeleteDays
6781

82+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
83+
6884
Optional. The number of days to retain deleted containers. When set to 0, soft delete is disabled.
6985

7086
- Default value: `0`
7187

7288
### shares
7389

90+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
91+
7492
Optional. An array of file shares to create on the storage account.
7593

7694
### useLargeFileShares
7795

96+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
97+
7898
Optional. Determines if large file shares are enabled. This can not be disabled once enabled.
7999

80100
- Default value: `False`
81101

82102
### shareSoftDeleteDays
83103

104+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
105+
84106
Optional. The number of days to retain deleted shares. When set to 0, soft delete is disabled.
85107

86108
- Default value: `0`
87109

88110
### allowBlobPublicAccess
89111

112+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
113+
90114
Optional. Determines if any containers can be configured with the anonymous access types of blob or container.
91115

92116
- Default value: `False`
93117

94118
### keyVaultPrincipalId
95119

120+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
121+
96122
Optional. Set to the objectId of Azure Key Vault to delegated permission for use with Key Managed Storage Accounts.
97123

98124
### tags
99125

126+
![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)
127+
100128
Optional. Tags to apply to the resource.
101129

102130
## Outputs

0 commit comments

Comments
 (0)