Hi Nick,

I'm having trouble understanding the intentions of your policy. However,
I'll share the important things I've discovered while working with
arrays.

1. One does not pass an array.  On passes a reference to that array.
Example

'config' usebundle => foo( 'main.array' );
}

bundle agent ( ref ) {
# I always use 'ref' to remind me what I'm doing.

vars:

    'i' slist => getindices( '$(ref)' );

reports:

    cfengine::
       "$(i) = $($(ref)[$(i)])"
}

2. The trouble with multidimensional arrays in Cfengine is that the
looping is mostly out of our control.  For example I have never been
able index and loop through something like your example.  Cfengine does
not seem to nest the loops.  Rather, loops seem to go in parallel.
Examples that prove me wrong will be meet with enthusiasm.

3. Given point two, multidimensional arrays can only work if one refers
to some keys manually rather than with nested looping.

Back to your example.  

>"service[configfile][acl]"        string => "/etc/service/acl";
>"service[configfile][passwd]"     string => "/etc/service/passwd";
>"service[acl][component1][user1]" string => "rw";
>"service[acl][componentb][user2]" string => "r";
>
>"service_config" usebundle => service_main("context.service");
>
>bundle service_main(params){
>vars:
># c=component
># u=user
>acl_conf[$(c)][$(u)] string => $(service[acl[$(c)][$(u)])

params is a reference.  Try this "$($(params)[acl][$(c)][$(u)])"

It's a pity that the parser does not allow whitespace in the variables
for better readability.

Off topic,

Please excuse this self promotion for a moment.  I've just finished a
contact and am looking for a new one.  I'd be grateful for any leads.

Sincerely,
-- 
Neil Watson
Linux/UNIX Consultant
http://watson-wilson.ca
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to