Re: stuck again...getvalues from datacontainer acting weird

"'Nick Anderson' via help-cfengine" <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Xander Cage <[email protected]> writes:

> hey, again battling with basic things...

      nothing in default:parent_manage_aixtoolbox.DEBUG_pkg ...
      why is this not

I find it very helpful to distill problems down into a small easily run
and reproducible policy and build up.

So, I took some of date from your data container to make a small mock
....

,----
| bundle agent __main__
| {
|    vars:
|       "my_data" data => '[{"package":"bash-5.0.18-1"},{"package":"bzip2-1.0.8-2"}]';
|       "my_data_values" slist => getvalues( my_data );
| 
|    reports:
|       "CFEngine $(sys.cf_version)";
| }
`----

We can see that `getvalues()' on the data container returns the list of
/key/ *values*.

,----
| R: CFEngine 3.19.0a.da01eaa81
| Variable name                            Variable value                                               Meta tags                                Comment                                 
| default:main.my_data                     [{"package":"bash-5.0.18-1"},{"package":"bzip2-1.0.8-2"}]    source=promise                                                                   
| default:main.my_data_values               {"bash-5.0.18-1","bzip2-1.0.8-2"}                           source=promise                                                                   
`----


You were trying to get values from the `package' key of the
`DEBUG_my_data' data container, but there is no `package' key, there is
an array of dictionaries where each dictionary has a `package' key.

,----
| "DEBUG_pkg" slist => getvalues("DEBUG_my_data[package]");
`----

You could get values from an numerical index, for example:

,----
| bundle agent __main__
| {
|    vars:
|       "my_data" data => '[{"package":"bash-5.0.18-1"},{"package":"bzip2-1.0.8-2"}]';
|       "my_data_values" slist => getvalues( "my_data[1]" );
| 
|    reports:
|       "CFEngine $(sys.cf_version)";
| }
`----

,----
| R: CFEngine 3.19.0a.da01eaa81
| Variable name                            Variable value                                               Meta tags                                Comment                                 
| default:main.my_data                     [{"package":"bash-5.0.18-1"},{"package":"bzip2-1.0.8-2"}]    source=promise                                                                   
| default:main.my_data_values               {"bzip2-1.0.8-2"}                                           source=promise                                                                   
`----


Hope this helps ...

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87wnkp1vnp.fsf%40northern.tech.

-- 
Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87wnkp1vnp.fsf%40northern.tech.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.