Skip to content

Commit

Permalink
Fixes #20963: Add suport for report id reporting with Windows agent
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Mar 31, 2022
1 parent 6c2bc95 commit 0cf2265
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ class DSCTechniqueWriter(

def naReport(method : GenericMethod, expectedReportingValue : String) =
s"""_rudder_common_report_na ${componentName} -componentKey ${expectedReportingValue} -message "Not applicable" ${genericParams}"""
for {


(for {

// First translate parameters to Dsc values
params <- ((call.parameters.toList).traverse {
Expand Down Expand Up @@ -863,7 +865,7 @@ class DSCTechniqueWriter(
} else {
s" ${naReport(method,classParameter)}" :: Nil
}
}
}).map(s""" $$reportId=$$reportIdBase+"${call.id}"""" :: _)
}

case block : MethodBlock =>
Expand Down Expand Up @@ -897,7 +899,7 @@ class DSCTechniqueWriter(
| [string]$$techniqueName,${parameters}
| [switch]$$auditOnly
| )
|
| $$reportIdBase = $$reportId.Substring(0,$$reportId.Length-1)
| $$local_classes = New-ClassContext
| $$resources_dir = $$PSScriptRoot + "\\resources"
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
[string]$Version,
[switch]$auditOnly
)

$reportIdBase = $reportId.Substring(0,$reportId.Length-1)
$local_classes = New-ClassContext
$resources_dir = $PSScriptRoot + "\resources"

$reportId=$reportIdBase+"id"

$local_classes = Merge-ClassContext $local_classes $(Package-Install-Version -PackageName "$($node.properties[apache_package_name])" -PackageVersion "2.2.11" -componentName "Test component$&é)à\'`"" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
[string]$Version,
[switch]$auditOnly
)

$reportIdBase = $reportId.Substring(0,$reportId.Length-1)
$local_classes = New-ClassContext
$resources_dir = $PSScriptRoot + "\resources"

$reportId=$reportIdBase+"id"

$local_classes = Merge-ClassContext $local_classes $(Package-Install-Version -PackageName "$($node.properties[apache_package_name])" -PackageVersion "2.2.11" -componentName "Test component$&é)à\'`"" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,38 @@
[string]$TechniqueParameter,
[switch]$auditOnly
)

$reportIdBase = $reportId.Substring(0,$reportId.Length-1)
$local_classes = New-ClassContext
$resources_dir = $PSScriptRoot + "\resources"

$reportId=$reportIdBase+"id1"

$local_classes = Merge-ClassContext $local_classes $(Package-Install-Version -PackageName "$($node.properties[apache_package_name])" -PackageVersion "2.2.11" -componentName "Customized component" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")

$reportId=$reportIdBase+"id2"

$class = "windows"
if (Evaluate-Class $class $local_classes $system_classes) {
$local_classes = Merge-ClassContext $local_classes $(Command-Execution -Command "Write-Host `"testing special characters ` è &é 'à é `"" -componentName "Command execution" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")
} else {
_rudder_common_report_na -componentName "Command execution" -componentKey "Write-Host `"testing special characters ` è &é 'à é `"" -message "Not applicable" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly
}

$reportId=$reportIdBase+"id3"

$class = "package_install_version_" + $(Canonify-Class $($node.properties[apache_package_name])) + "_repaired"
if (Evaluate-Class $class $local_classes $system_classes) {
$local_classes = Merge-ClassContext $local_classes $(Service-Start -ServiceName "$($node.properties[apache_package_name])" -componentName "Customized component" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")
} else {
_rudder_common_report_na -componentName "Customized component" -componentKey "$($node.properties[apache_package_name])" -message "Not applicable" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly
}

$reportId=$reportIdBase+"id4"

_rudder_common_report_na -componentName "Package install" -componentKey "openssh-server" -message "Not applicable" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly

$reportId=$reportIdBase+"id5"

$class = "cfengine-community"
if (Evaluate-Class $class $local_classes $system_classes) {
$local_classes = Merge-ClassContext $local_classes $(Command-Execution -Command "/bin/echo `"testing special characters ` è &é 'à é `"\" -componentName "Command execution" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")
Expand Down

0 comments on commit 0cf2265

Please sign in to comment.