Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/masterfiles/git-failsafe.cf
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bundle agent git_update
perms => u_m("755"),
depth_search => u_recurse_basedir("inf"),
action => u_immediate,
ifvarclass => "hpux";
if => "hpux";

"/usr/local/bin"
comment => "Ensure cfengine binaries were copied to /usr/local/bin",
Expand Down
11 changes: 6 additions & 5 deletions examples/augment.cf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ bundle common def
{
vars:
# Only define this variable if it is not yet defined.
"example_augment_string_override"
unless => isvariable("example_augment_string_override");
"example_augment_string"
string => "fallback value when not defined in def.json",
unless => isvariable("example_augment_string");

# Define this variable regardless if it has been set in def.json
"example_augment_list_override"
Expand All @@ -18,16 +19,16 @@ bundle agent main
reports:
"Def var: '$(def_vars)'";

"def.example_augment_string_override = '$(def.example_augment_string_override)'";
"def.example_augment_string = '$(def.example_augment_string)'";
"def.example_augment_list_override = '$(def.example_augment_list_override)'";
"def.example_augment_structured_override[key1] = '$(def.example_augment_structured_override[key1])'";
}
#+begin_src example_output
#@ ```
#@ R: Def var: 'default:def.example_augment_structured_override'
#@ R: Def var: 'default:def.example_augment_string_override'
#@ R: Def var: 'default:def.example_augment_string'
#@ R: Def var: 'default:def.example_augment_list_override'
#@ R: def.example_augment_string_override = 'defined in def.json'
#@ R: def.example_augment_string = 'defined in def.json'
#@ R: def.example_augment_list_override = 'defined'
#@ R: def.example_augment_list_override = 'in'
#@ R: def.example_augment_list_override = 'bundle'
Expand Down
12 changes: 6 additions & 6 deletions examples/classfilterdata_array_of_objects.cf
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ bundle agent __main__
vars:
"original"
data => '[
{ "file": "/tmp/foo", "ifvarclass": "role_1" },
{ "file": "/tmp/bar", "ifvarclass": "role_2" },
{ "file": "/tmp/baz", "ifvarclass": "(role_1|role_2)" }
{ "file": "/tmp/foo", "if": "role_1" },
{ "file": "/tmp/bar", "if": "role_2" },
{ "file": "/tmp/baz", "if": "(role_1|role_2)" }
]';

"filtered"
data => classfilterdata("original", "array_of_objects", "ifvarclass");
data => classfilterdata("original", "array_of_objects", "if");

reports:
"Filtered data: $(with)"
Expand All @@ -26,11 +26,11 @@ bundle agent __main__
#@ R: Filtered data: [
#@ {
#@ "file": "/tmp/bar",
#@ "ifvarclass": "role_2"
#@ "if": "role_2"
#@ },
#@ {
#@ "file": "/tmp/baz",
#@ "ifvarclass": "(role_1|role_2)"
#@ "if": "(role_1|role_2)"
#@ }
#@ ]
#@ ```
Expand Down
12 changes: 6 additions & 6 deletions examples/classfilterdata_object_of_objects.cf
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ bundle agent __main__
vars:
"original"
data => '{
"/tmp/foo": { "ifvarclass": "role_1" },
"/tmp/bar": { "ifvarclass": "role_2" },
"/tmp/baz": { "ifvarclass": "(role_1|role_2)" }
"/tmp/foo": { "if": "role_1" },
"/tmp/bar": { "if": "role_2" },
"/tmp/baz": { "if": "(role_1|role_2)" }
}';

"filtered"
data => classfilterdata("original", "object_of_objects", "ifvarclass");
data => classfilterdata("original", "object_of_objects", "if");

reports:
"Filtered data: $(with)"
Expand All @@ -25,10 +25,10 @@ bundle agent __main__
#@ ```
#@ R: Filtered data: {
#@ "/tmp/bar": {
#@ "ifvarclass": "role_2"
#@ "if": "role_2"
#@ },
#@ "/tmp/baz": {
#@ "ifvarclass": "(role_1|role_2)"
#@ "if": "(role_1|role_2)"
#@ }
#@ }
#@ ```
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/00_basics/04_bundles/wrong-bundle-type.cf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bundle agent init
bundle agent test
{
vars:
"subout" string => execresult("${sys.cf_agent} -Kf ${this.promise_filename}.sub", "noshell");
"subout" string => execresult("${sys.cf_agent} -Kf $(this.promise_dirname)/wrong-bundle-type.sub.x.cf", "noshell");
}

bundle agent check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ bundle agent init
"mode": "755",
"owner": "root",
"group": "root",
"ifvarclass": "role_1"
"if": "role_1"
},
{
"file": "/tmp/bar",
"mode": "600",
"owner": "root",
"group": "root",
"ifvarclass": "role_2"
"if": "role_2"
},
{
"file": "/tmp/baz",
"mode": "644",
"owner": "root",
"group": "root",
"ifvarclass": "(role_1|role_2)"
"if": "(role_1|role_2)"
}
]';
}
Expand All @@ -44,7 +44,7 @@ bundle agent test

vars:
"filtered"
data => classfilterdata(readjson("$(G.testfile).json"), "auto", "ifvarclass");
data => classfilterdata(readjson("$(G.testfile).json"), "auto", "if");
}

bundle agent check
Expand All @@ -57,14 +57,14 @@ bundle agent check
"mode": "600",
"owner": "root",
"group": "root",
"ifvarclass": "role_2"
"if": "role_2"
},
{
"file": "/tmp/baz",
"mode": "644",
"owner": "root",
"group": "root",
"ifvarclass": "(role_1|role_2)"
"if": "(role_1|role_2)"
}
]');
"actual"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bundle agent test
{
meta:
"description" -> { "CFE-3319" }
string => "Test that if/ifvarclass can check class expressions from within a data container";
string => "Test that if can check class expressions from within a data container";

vars:

Expand Down
40 changes: 20 additions & 20 deletions tests/acceptance/dcs.sub.cf
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ bundle common G
vars:
# General commands.
"$(cmds)" string => "$(paths[$(paths_indices)])$(const.dirsep)$(cmds)$(exeext)",
ifvarclass => canonify("$(paths_indices)_$(cmds)$(exeext)");
if => canonify("$(paths_indices)_$(cmds)$(exeext)");

# Special cases.
"$(sbin_cmds)" string => "$(paths[$(paths_indices)])$(const.dirsep)$(sbin_cmds)$(exeext)",
ifvarclass => canonify("$(paths_indices)_$(sbin_cmds)$(exeext)");
if => canonify("$(paths_indices)_$(sbin_cmds)$(exeext)");
# gmake has higher priority, so should come last.
"make" string => "$(paths[$(paths_indices)])$(const.dirsep)make$(exeext)",
ifvarclass => canonify("$(paths_indices)_make$(exeext)");
if => canonify("$(paths_indices)_make$(exeext)");
"make" string => "$(paths[$(paths_indices)])$(const.dirsep)gmake$(exeext)",
ifvarclass => canonify("$(paths_indices)_gmake$(exeext)");
if => canonify("$(paths_indices)_gmake$(exeext)");

# on solaris, gsed works more like GNU sed, such as having `-i` option
solaris::
Expand Down Expand Up @@ -247,7 +247,7 @@ bundle agent test_run(filename)

AUTO::
"any" usebundle => "$(default.tests)",
ifvarclass => canonify("have_test_run_$(default.tests)");
if => canonify("have_test_run_$(default.tests)");

reports:
!AUTO::
Expand Down Expand Up @@ -460,15 +460,15 @@ bundle agent dcs_report_generic_classes(x)

reports:
DEBUG::
"class '$(x)_$(choices)' was defined" ifvarclass => '$(x)_$(choices)';
"class '$(x)_$(choices)' was NOT defined" ifvarclass => '!$(x)_$(choices)';
"class '$(x)_$(choices)' was defined" if => '$(x)_$(choices)';
"class '$(x)_$(choices)' was NOT defined" if => '!$(x)_$(choices)';
}

bundle agent dcs_generic_classes_to_string(x)
{
vars:
"choices" slist => { "repaired", "failed", "denied", "timeout", "kept" };
"s[$(choices)]" string => "$(x)_$(choices)", ifvarclass => '$(x)_$(choices)';
"s[$(choices)]" string => "$(x)_$(choices)", if => '$(x)_$(choices)';
"found_unsorted" slist => getvalues(s);
"found" slist => sort(found_unsorted, "lex");
"found_str" string => format("%S", found);
Expand Down Expand Up @@ -792,13 +792,13 @@ reports:
bundle agent dcs_passif(classname, test)
{
reports:
"$(test) Pass" ifvarclass => $(classname);
"$(test) FAIL" ifvarclass => not($(classname));
"$(test) Pass" if => $(classname);
"$(test) FAIL" if => not($(classname));

EXTRA::
"$(this.bundle): passing based on class '$(classname)'" ifvarclass => $(classname);
"$(this.bundle): passing based on class '$(classname)'" if => $(classname);
DEBUG::
"$(this.bundle): failing based on class '$(classname)'" ifvarclass => not($(classname));
"$(this.bundle): failing based on class '$(classname)'" if => not($(classname));
}

bundle agent dcs_pass(test)
Expand Down Expand Up @@ -872,17 +872,17 @@ bundle agent dcs_passif_expected(expected, not_expected, test)
reports:
DEBUG::
"$(this.bundle): bad: $(ex) was NOT defined"
ifvarclass => "!$(ex)";
if => "!$(ex)";

"$(this.bundle): bad: $(notex) WAS defined"
ifvarclass => "$(notex)";
if => "$(notex)";

EXTRA::
"$(this.bundle): good: $(ex) WAS defined"
ifvarclass => "$(ex)";
if => "$(ex)";

"$(this.bundle): good: $(notex) was NOT defined"
ifvarclass => "!$(notex)";
if => "!$(notex)";
}

#######################################################
Expand All @@ -906,17 +906,17 @@ bundle agent dcs_passif_output(wanted, unwanted, command, test)
reports:
DEBUG::
"$(this.bundle): bad: '$(wanted)' was NOT found in the output of '$(command)'"
ifvarclass => "!__passif_output_wanted";
if => "!__passif_output_wanted";

"$(this.bundle): bad: '$(unwanted)' WAS found in the output of '$(command)'"
ifvarclass => "__passif_output_unwanted";
if => "__passif_output_unwanted";

EXTRA::
"$(this.bundle): good: '$(wanted)' WAS found in the output of '$(command)'"
ifvarclass => "__passif_output_wanted";
if => "__passif_output_wanted";

"$(this.bundle): good: '$(unwanted)' was NOT found in the output of '$(command)'"
ifvarclass => "!__passif_output_unwanted";
if => "!__passif_output_unwanted";

DEBUG::
"$(this.bundle): the output of command '$(command)' was: '$(subout)'";
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data/body_executor_control_empty.cf
Original file line number Diff line number Diff line change
@@ -1 +1 @@

# No configuration for cf-execd here
7 changes: 0 additions & 7 deletions tests/unit/data/constraint_lval_invalid.cf

This file was deleted.

2 changes: 1 addition & 1 deletion tests/unit/policy_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void test_body_control_no_arguments(void)

static void test_vars_multiple_types(void)
{
Seq *errs = LoadAndCheck("vars_multiple_types.cf");
Seq *errs = LoadAndCheck("vars_multiple_types.x.cf");
assert_int_equal(1, errs->length);

SeqDestroy(errs);
Expand Down
Loading