Fixed use of lower case Tags resource property #43 (#44)

This commit is contained in:
Bernie White 2021-01-02 00:00:03 +10:00 коммит произвёл GitHub
Родитель 770bba535e
Коммит e73071fb87
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -2,6 +2,11 @@
## Unreleased
What's changed since pre-release v0.1.0-B2012004:
- Bug fixes:
- Fixed use of lower case `Tags` resource property. [#43](https://github.com/microsoft/PSRule.Rules.CAF/issues/43)
## v0.1.0-B2012004 (pre-release)
What's changed since pre-release v0.1.0-B2009009:

Просмотреть файл

@ -11,7 +11,7 @@ Rule 'CAF.Tag.Resource' -If { (CAF_SupportsTags) -and !(CAF_IsResourceGroup) -an
if ($required.Length -eq 0) {
return $Assert.Pass();
}
$Assert.HasField($TargetObject, 'Tags');
$Assert.HasField($TargetObject, 'tags');
if ($Null -ne $TargetObject.Tags) {
$Assert.HasFields($TargetObject.Tags, $required, $Configuration.CAF_MatchTagNameCase);
}
@ -23,14 +23,17 @@ Rule 'CAF.Tag.ResourceGroup' -Type 'Microsoft.Resources/resourceGroups' -If { ($
if ($required.Length -eq 0) {
return $Assert.Pass();
}
$Assert.HasField($TargetObject, 'Tags');
$Assert.HasField($TargetObject, 'tags');
if ($Null -ne $TargetObject.Tags) {
$Assert.HasFields($TargetObject.Tags, $required, $Configuration.CAF_MatchTagNameCase);
}
}
# Synopsis: Tag resources and resource groups with a valid environment.
Rule 'CAF.Tag.Environment' -If { (CAF_SupportsTags) -and (Exists "Tags.$($Configuration.CAF_EnvironmentTag)") } {
$Assert.HasField($TargetObject, "Tags.$($Configuration.CAF_EnvironmentTag)", $Configuration.CAF_MatchTagNameCase);
$Assert.In($TargetObject, "Tags.$($Configuration.CAF_EnvironmentTag)", $Configuration.CAF_Environments, $Configuration.CAF_MatchTagValueCase)
Rule 'CAF.Tag.Environment' -If { (CAF_SupportsTags) -and (Exists "tags.$($Configuration.CAF_EnvironmentTag)") } {
$Assert.HasField($TargetObject, 'tags');
if ($Null -ne $TargetObject.Tags) {
$Assert.HasField($TargetObject.Tags, $Configuration.CAF_EnvironmentTag, $Configuration.CAF_MatchTagNameCase);
$Assert.In($TargetObject.Tags, $Configuration.CAF_EnvironmentTag, $Configuration.CAF_Environments, $Configuration.CAF_MatchTagValueCase);
}
}

Просмотреть файл

@ -56,7 +56,7 @@ Describe 'CAF.Tag' -Tag 'tag' {
@{
Name = 'vnet-A'
Type = 'Microsoft.Network/virtualNetworks'
Tags = @{
tags = @{
Env = 'Prod'
}
},