Re: stuck again...getvalues from datacontainer acting weird
Xander Cage <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
nick, i missinterpreted something here ...> https://docs.cfengine.com/docs/3.18/reference-promise-types-vars.html#some-useful-tips-for-using-data-containers sorry...it was late wbr chris On Tuesday, November 30, 2021 at 4:59:57 PM UTC+1 Nick Anderson wrote: > 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/47a3a6a3-72b6-43e4-83f1-e89e4de914bbn%40googlegroups.com.