Родитель
4055eec381
Коммит
57229d6b78
|
@ -7,6 +7,8 @@ What's changed since pre-release v0.1.0-B2101004:
|
|||
- Engineering:
|
||||
- Bump PSRule dependency to v1.0.1. [#49](https://github.com/microsoft/PSRule.Rules.CAF/issues/49)
|
||||
- Bump PSRule.Rules.Azure dependency to v0.19.0. [#49](https://github.com/microsoft/PSRule.Rules.CAF/issues/49)
|
||||
- Bug fixes:
|
||||
- Fixed storage account name rule with Azure Cloud Shell. [#47](https://github.com/microsoft/PSRule.Rules.CAF/issues/47)
|
||||
|
||||
## v0.1.0-B2101004 (pre-release)
|
||||
|
||||
|
|
|
@ -102,3 +102,20 @@ function global:CAF_IsManagedLB {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Determines if the object is a managed storage account created by Azure
|
||||
function global:CAF_IsManagedStorage {
|
||||
[CmdletBinding()]
|
||||
[OutputType([System.Boolean])]
|
||||
param ()
|
||||
process {
|
||||
if ($PSRule.TargetType -ne 'Microsoft.Storage/storageAccounts') {
|
||||
return $False;
|
||||
}
|
||||
# Check for managed storage accounts
|
||||
if ($Assert.HasFieldValue($TargetObject, 'Tags.ms-resource-usage', 'azure-cloud-shell').Result) {
|
||||
return $True;
|
||||
}
|
||||
return $False;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ Rule 'CAF.Name.VM' -Type 'Microsoft.Compute/virtualMachines' {
|
|||
}
|
||||
|
||||
# Synopsis: Use standard storage accounts names.
|
||||
Rule 'CAF.Name.Storage' -Type 'Microsoft.Storage/storageAccounts' {
|
||||
Rule 'CAF.Name.Storage' -Type 'Microsoft.Storage/storageAccounts' -If { !(CAF_IsManagedStorage) } {
|
||||
$Assert.StartsWith($PSRule, 'TargetName', $Configuration.CAF_StoragePrefix, $True);
|
||||
$Assert.IsLower($PSRule, 'TargetName');
|
||||
}
|
||||
|
|
|
@ -331,6 +331,7 @@ Describe 'CAF.Name' -Tag 'name' {
|
|||
$invalidNames = @(
|
||||
'sTest001'
|
||||
'testst001'
|
||||
'cs001'
|
||||
)
|
||||
$testObject = [PSCustomObject]@{
|
||||
Name = ''
|
||||
|
@ -356,6 +357,19 @@ Describe 'CAF.Name' -Tag 'name' {
|
|||
$ruleResult.Outcome | Should -Be 'Fail';
|
||||
}
|
||||
}
|
||||
|
||||
It 'Cloud Shell' {
|
||||
$testObject = [PSCustomObject]@{
|
||||
Name = 'cs001'
|
||||
ResourceType = 'Microsoft.Storage/storageAccounts'
|
||||
Tags = @{
|
||||
'ms-resource-usage' = 'azure-cloud-shell'
|
||||
}
|
||||
}
|
||||
$ruleResult = $testObject | Invoke-PSRule @invokeParams -Name 'CAF.Name.Storage' -Outcome All;
|
||||
$ruleResult | Should -Not -BeNullOrEmpty;
|
||||
$ruleResult.Outcome | Should -Be 'None';
|
||||
}
|
||||
}
|
||||
|
||||
Context 'CAF.Name.PublicIP' {
|
||||
|
|
Загрузка…
Ссылка в новой задаче