hi,
I tried various functions but its just frustrating...
users.csv
ClassExpression,uid,name,group,ssh_key
weirdos,mscott,Michael Scott,pathetic,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg
weirdos,jkras,John Krasinski,pathetic,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg
twats,tflen,Toby Flenderson,tedious,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg
zombie,fired,Get OUT!,buzzoff,ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg
test promise:
bundle agent parent_bundle
{
classes:
"weirdos";
"twats";
"zombie";
vars:
"data_file" string => "users.csv";
"d" data => classfiltercsv($(data_file), "true", 0);
"parameter_name" slist => getindices("d");
"parameter_name_sorted" slist => sort(parameter_name, lex);
"cvalues" slist => getvalues("d");
"cvalues_sorted" slist => sort(cvalues, lex);
"raw" data => @(d);
methods:
"call_remove" usebundle => child_bundle("$(this.bundle).d"),
handle => "dba_user_guard",
classes => results("bundle", "itsv_DABA_USER_NOT_JUSTIFIED");
reports:
"All users in parent function: data: $(with)" with => string_mustache("{{%-top-}}", d);
"Bonkers index is number instead of key name: Key: $(parameter_name) -> Value: $(cvalues)";
"Totally useless for practical usage: $(d[0])";
}
bundle agent child_bundle (info) {
vars:
"user_crap1" slist => getindices("$(info)");
"bla" data => mergedata("info");
"user_crap2" slist => getindices("$(bla)");
"user_crap3" slist => getvalues("info[uid]");
"bla_$(user_crap1)" string => format("%S", "info[$(user_crap1)]");
reports:
"child function, only numbers instead if key names : data: $(with)" with => string_mustache("{{%-top-}}", user_crap1);
"child funtion, mergedate produces empty output: $(with)" with => string_mustache("{{%-top-}}", user_crap2);
"child function, getvalues also not working : data: $(with)" with => string_mustache("{{%-top-}}", user_crap3);
"Some mehtod from the docs, also nothing: $(user_crap1): $(bla_$(user_crap1))";
}
bundle agent __main__
{
methods:
"parent_bundle";
}
data format:
{
"group": "pathetic",
"name": "Michael Scott",
"ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
"uid": "mscott"
},
{
"group": "pathetic",
"name": "John Krasinski",
"ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
"uid": "jkras"
},
{
"group": "tedious",
"name": "Toby Flenderson",
"ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
"uid": "tflen"
},
{
"group": "buzzoff",
"name": "Get OUT!",
"ssh_key": "ssh-someSupERsecretKey287483438dsdjhdsdsdjahhsgdsg",
"uid": "fired"
}
how to i access uid, name,...from this structure?