Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #23581: Missing NA report on Windows for methods only compatible with Unix #5100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion policies/rudderc/src/backends/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::Path;

use anyhow::{bail, Result};
use askama::Template;
use rudder_commons::Escaping;
use rudder_commons::{methods::method::Agent, Escaping};

use super::Backend;
use crate::ir::{
Expand Down Expand Up @@ -132,6 +132,7 @@ struct WindowsMethod {
condition: Option<String>,
args: Vec<(String, String, Escaping)>,
name: String,
is_supported: bool,
}

fn method_call(m: Method, condition: Condition) -> Result<WindowsMethod> {
Expand Down Expand Up @@ -164,6 +165,8 @@ fn method_call(m: Method, condition: Condition) -> Result<WindowsMethod> {
// We want a stable output
args.sort();

let is_supported = m.info.unwrap().agent_support.contains(&Agent::Dsc);

Ok(WindowsMethod {
id: m.id.to_string(),
class_prefix: m.info.as_ref().unwrap().class_prefix.clone(),
Expand All @@ -178,6 +181,7 @@ fn method_call(m: Method, condition: Condition) -> Result<WindowsMethod> {
},
args,
name: filters::dsc_case(&m.info.as_ref().unwrap().bundle_name).unwrap(),
is_supported,
})
}

Expand Down
4 changes: 4 additions & 0 deletions policies/rudderc/templates/technique.ps1.askama
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function {{ id|dsc_case }} {
DisableReporting = ${{ m.disable_reporting }}
TechniqueName = $techniqueName
}
{%- if m.is_supported %}
{% match m.condition %}
{%- when Some with (cond) %}
$class = {{ cond|canonify_condition }}
Expand All @@ -62,6 +63,9 @@ function {{ id|dsc_case }} {
$methodContext = Compute-Method-Call @reportParams -MethodCall $call
$localContext.merge($methodContext)
{% endmatch %}
{%- else %}
Rudder-Report-NA @reportParams
{%- endif %}
{% endfor %}

EndTechniqueCall -Name $techniqueName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
DisableReporting = $false
TechniqueName = $techniqueName
}

$methodParams = @{
Condition = "it_generates_properly"
ReportMessage = "This should be ReportMessage"

}
$call = Report-If-Condition @methodParams -PolicyMode $policyMode
$methodContext = Compute-Method-Call @reportParams -MethodCall $call
$localContext.merge($methodContext)

Rudder-Report-NA @reportParams


EndTechniqueCall -Name $techniqueName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#
# @class_prefix package_present
# @class_parameter name
# @agent_support = ["cfengine-community", "dsc"]
# This line should be ignored

bundle agent package_present(name, version, architecture, provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bundle_args:
- provider
agent_support:
- cfengine-community
- dsc
parameter:
- name: name
description: "Name of the package, or path to a local package"
Expand Down