Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Created September 9, 2012 14:56
Show Gist options
  • Save nickanderson/3684847 to your computer and use it in GitHub Desktop.
Save nickanderson/3684847 to your computer and use it in GitHub Desktop.
cf-agent -KIf ./override_array_defaults.cf
R: Why does local_array[blue] not get set from the param?
R:
R: Param: main.array[red]=dog
R: Param: main.array[blue]=fish
R:
R: Array: local_array[one]=fish
R: Array: local_array[two]=fish
R: Array: local_array[red]=dog
body common control {
inputs => { "../sketches/CFEngine/stdlib/cfengine_stdlib.cf" };
bundlesequence => { "main" };
}
bundle agent main
{
vars:
"array[red]"
string => "dog",
policy => "free";
"array[blue]"
string => "fish",
policy => "free";
methods:
"story time" usebundle => test("main.array");
}
bundle agent test(prefix)
{
vars:
"local_array[one]"
string => "fish",
policy => "free";
"local_array[two]"
string => "fish",
policy => "free";
"local_array[red]"
string => "fish",
policy => "free";
"param_index" slist => getindices("$(prefix)");
# Override default values with those from parameter
"local_array[$(param_index)]"
handle => "test_vars_copy_paramaters_to_local_array",
string => "$($(prefix)[$(param_index)])",
policy => "free";
"array_keys" slist => getindices("local_array");
reports:
cfengine::
"Why does local_array[blue] not get set from the param?";
" ";
"Param: $(prefix)[$(param_index)]=$($(prefix)[$(param_index)])";
" ";
"Array: local_array[$(array_keys)]=$(local_array[$(array_keys)])";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment