-
Notifications
You must be signed in to change notification settings - Fork 86
/
RuleToc.Doc.ps1
118 lines (96 loc) · 4.19 KB
/
RuleToc.Doc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Document 'index' {
Title 'Reference'
Metadata @{
generated = $True
title = 'Reference'
}
Import-Module ./out/modules/PSRule.Rules.Azure
$rules = Get-PSRule -Module PSRule.Rules.Azure -Baseline Azure.All -WarningAction SilentlyContinue;
'The following rules and features are included in PSRule for Azure.'
@"
!!! Info
The rule _release_ indicates if the Azure feature is _generally available (GA)_ or available under _preview_.
Features provided under previews may have additional limits, availability restrictions, or [terms][1].
By default, PSRule for Azure will not provide recommendations that relate to preview features.
To include rules for preview features see [working with baselines][2].
[1]: https://azure.microsoft.com/support/legal/preview-supplemental-terms/
[2]: ../../working-with-baselines.md
"@
Section 'Rules' {
'The following rules are included in PSRule for Azure.'
$rules | Sort-Object -Property Ref | Table -Property @{ Name = 'Reference'; Expression = {
$_.Ref.Name
}}, @{ Name = 'Name'; Expression = {
"[$($_.Name)]($($_.Name).md)"
}}, Synopsis, @{ Name = 'Release'; Expression = {
if ($_.Tag.release -eq 'GA') {
'GA'
}
elseif ($_.Tag.release -eq 'Preview'){
'Preview'
}
else {
$_.Tag.release.ToString()
}
}}
}
'*[GA]: Generally Available — Rules related to a generally available Azure features.'
}
Document 'module' {
Title 'Rules by pillar'
Metadata @{
generated = $True
}
Import-Module ./out/modules/PSRule.Rules.Azure
$rules = Get-PSRule -Module PSRule.Rules.Azure -Baseline Azure.All -WarningAction SilentlyContinue |
Add-Member -MemberType ScriptProperty -Name Category -Value { $this.Info.Annotations.category } -PassThru |
Add-Member -MemberType ScriptProperty -Name Pillar -Value { $this.Info.Annotations.pillar } -PassThru |
Sort-Object -Property Pillar, Category;
'PSRule for Azure includes the following rules across five pillars of the Microsoft Azure Well-Architected Framework.'
$pillars = $rules | Group-Object -Property Pillar | Sort-Object -Property Name;
foreach ($pillar in $pillars) {
Section $pillar.Name {
$categories = $pillar.Group | Group-Object -Property Category | Sort-Object -Property Name;
foreach ($category in $categories) {
Section $category.Name {
$category.Group |
Sort-Object -Property Name |
Table -Property @{ Name = 'Name'; Expression = {
"[$($_.Name)]($($_.Name).md)"
}}, Synopsis, @{ Name = 'Severity'; Expression = {
$_.Info.Annotations.severity
}}, @{ Name = 'Level'; Expression = {
$_.Level.ToString()
}}
}
}
}
}
}
Document 'resource' {
Title 'Rules by resource type'
Metadata @{
generated = $True
}
Import-Module ./out/modules/PSRule.Rules.Azure
$rules = Get-PSRule -Module PSRule.Rules.Azure -Baseline Azure.All -WarningAction SilentlyContinue |
Add-Member -MemberType ScriptProperty -Name Resource -Value { $this.Info.Annotations.resource } -PassThru |
Sort-Object -Property Resource;
'PSRule for Azure includes the following rules organized by resource type.'
$resources = $rules | Group-Object -Property Resource;
foreach ($resource in $resources) {
Section "$($resource.Name)" {
$resource.Group |
Sort-Object -Property Name |
Table -Property @{ Name = 'Name'; Expression = {
"[$($_.Name)]($($_.Name).md)"
}}, Synopsis, @{ Name = 'Severity'; Expression = {
$_.Info.Annotations.severity
}}, @{ Name = 'Level'; Expression = {
$_.Level.ToString()
}}
}
}
}