- Use qualified target names #36
- Use pre-release PSRule version to fix POSIX issue.
This commit is contained in:
Bernie White 2020-02-10 23:40:57 +10:00 коммит произвёл GitHub
Родитель 75a0009d53
Коммит a19407c0e9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 29 добавлений и 22 удалений

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

@ -2,6 +2,9 @@
## Unreleased
- **Breaking change**: Use qualified target names. [#36](https://github.com/Microsoft/PSRule.Rules.Kubernetes/issues/36)
- If using suppression, update suppressed target name with qualified name.
## v0.1.0
- Initial release.

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

@ -7,4 +7,4 @@
. ./.azure-pipelines/pipeline-deps.ps1
Invoke-Build Test -AssertStyle Client
Write-Host "If no build errors occured. The module has been saved to out/modules/PSRule.Rules.Kubernetes"
Write-Host "If no build errors occurred. The module has been saved to out/modules/PSRule.Rules.Kubernetes"

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

@ -22,11 +22,13 @@ param (
[String]$AssertStyle = 'AzurePipelines'
)
Write-Host -Object "[Pipeline] -- PowerShell: v$($PSVersionTable.PSVersion.ToString())" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- PWD: $PWD" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- ArtifactPath: $ArtifactPath" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- BuildNumber: $($Env:BUILD_BUILDNUMBER)" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- SourceBranch: $($Env:BUILD_SOURCEBRANCH)" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- SourceBranchName: $($Env:BUILD_SOURCEBRANCHNAME)" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- Culture: $((Get-Culture).Name), $((Get-Culture).Parent)" -ForegroundColor Green;
if ($Env:SYSTEM_DEBUG -eq 'true') {
$VerbosePreference = 'Continue';
@ -143,7 +145,7 @@ task VersionModule ModuleDependencies, {
$manifest = Test-ModuleManifest -Path $manifestPath;
$requiredModules = $manifest.RequiredModules | ForEach-Object -Process {
if ($_.Name -eq 'PSRule' -and $Configuration -eq 'Release') {
@{ ModuleName = 'PSRule'; ModuleVersion = '0.13.0' }
@{ ModuleName = 'PSRule'; ModuleVersion = '0.14.0' }
}
else {
@{ ModuleName = $_.Name; ModuleVersion = $_.Version }
@ -193,8 +195,8 @@ task PSScriptAnalyzer NuGet, {
# Synopsis: Install PSRule
task PSRule NuGet, {
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion 0.13.0 -ErrorAction Ignore)) {
Install-Module -Name PSRule -MinimumVersion 0.13.0 -Scope CurrentUser -Force;
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion '0.15.0-B2002012' -AllowPrerelease -ErrorAction Ignore)) {
Install-Module -Name PSRule -MinimumVersion '0.15.0-B2002012' -AllowPrerelease -Scope CurrentUser -Force;
}
Import-Module -Name PSRule -Verbose:$False;
}

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

@ -12,6 +12,7 @@ spec:
- kind
field:
namespace: [ 'metadata.namespace' ]
useQualifiedName: true
rule:
tag:
group: core
@ -29,6 +30,7 @@ spec:
- kind
field:
namespace: [ 'metadata.namespace' ]
useQualifiedName: true
rule:
tag:
group: [ 'core', 'AKS' ]

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

@ -38,13 +38,13 @@ Describe 'Kubernetes.AKS' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'service-B';
$ruleResult.TargetName | Should -Be 'service/service-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 2;
$ruleResult.TargetName | Should -BeIn 'service-A', 'service-C';
$ruleResult.TargetName | Should -BeIn 'service/service-A', 'service/service-C';
}
}
}

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

@ -38,13 +38,13 @@ Describe 'Kubernetes.API.Removal' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
}
}

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

@ -38,13 +38,13 @@ Describe 'Kubernetes.Metadata' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 2;
$ruleResult.TargetName | Should -BeIn 'deployment-B', 'service-B';
$ruleResult.TargetName | Should -BeIn 'deployment/deployment-B', 'service/service-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 2;
$ruleResult.TargetName | Should -BeIn 'deployment-A', 'service-A';
$ruleResult.TargetName | Should -BeIn 'deployment/deployment-A', 'service/service-A';
}
}
}

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

@ -38,13 +38,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
It 'Kubernetes.Pod.Latest' {
@ -54,13 +54,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
It 'Kubernetes.Pod.Secrets' {
@ -70,13 +70,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
}
@ -88,13 +88,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
}
@ -106,13 +106,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
It 'Kubernetes.Pod.Replicas' {
@ -122,13 +122,13 @@ Describe 'Kubernetes.Pod' {
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-B';
$ruleResult.TargetName | Should -Be 'deployment/deployment-B';
# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'deployment-A';
$ruleResult.TargetName | Should -Be 'deployment/deployment-A';
}
}
}