Re: How to join multiple parts of one data container

Michal Švamberg <[email protected]> Thu, 27 Jul 2023 01:10:08 -0700 (PDT)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Hi,
the simplified source code is in the email attachment. When I run it:
# cf-agent -Kf ./test.cf -C --show-evaluated-vars=default:main\\.level
   error: Error parsing JSON expression '[hwraid] ]': Unable to parse json 
data as array, did not start with '['
   error: Error parsing JSON expression '[hwraid] ]': Unable to parse json 
data as array, did not start with '['
   error: Error parsing JSON expression '[icinga], repos[ubuntu_16][hwraid] 
]': Unable to parse json data as array, did not start with '['
   error: Error parsing JSON expression '[icinga], repos[ubuntu_16][hwraid] 
]': Unable to parse json data as array, did not start with '['
...
Variable name                            Variable value                     
                          Meta tags                                Comment 
                                
default:main.level1_serialized           
[{"debian":{"Suites":["bookworm","bookworm-backports","bookworm-proposed-updates","bookworm-updates"],"URIs":"http://deb.debian.org/debian"},"debian-security":{"Suites":["bookworm-security"],"URIs":"http://deb.debian.org/debian-security"},"icinga":{"Suites":["icinga-bookworm"],"URIs":"https://packages.icinga.com/debian"}},{"hwraid":{"Suites":["stretch"],"Types":["deb"],"URIs":"https://hwraid.le-vert.net/debian"},"ubuntu":{"Suites":["xenial","xenial-backports","xenial-proposed","xenial-updates","xenial-security"],"URIs":"http://cz.archive.ubuntu.com/ubuntu"},"ubuntu-security":{"Suites":["xenial-security"],"URIs":"http://cz.archive.ubuntu.com/ubuntu"}}] 
source=promise                                                             
      
default:main.level1_single               
[{"hwraid":{"Suites":["stretch"],"Types":["deb"],"URIs":"https://hwraid.le-vert.net/debian"},"ubuntu":{"Suites":["xenial","xenial-backports","xenial-proposed","xenial-updates","xenial-security"],"URIs":"http://cz.archive.ubuntu.com/ubuntu"},"ubuntu-security":{"Suites":["xenial-security"],"URIs":"http://cz.archive.ubuntu.com/ubuntu"}}] 
source=promise   

I get level1* variables only. Is there any way to do this for the second 
level as well?

Thanks
Michal Svamberg

Dne středa 26. července 2023 v 16:11:43 UTC+2 uživatel 
[email protected] napsal:

> Can you post some standalone policy that reproduces the issue?
>
> On Wednesday, July 26, 2023 at 7:42:56 AM UTC-5 [email protected] wrote:
>
>> Hi all,
>> I have big data container (more than 4K) with all debian repository, as 
>> this:
>> <pre>
>> {
>>   "debian_10": {
>>     "debian": {
>>       "Components": "main contrib non-free",
>>       "Suites": [
>>         "buster",
>>         "buster-backports"
>>       ],
>>       "URIs": "http://deb.debian.org/debian"
>>     },
>>     "debian-security": {
>>       "Components": "main contrib non-free",
>>       "Suites": [
>> ...
>> </pre>
>>
>> I want shorting this data to server, this is running perfect:
>> "myrepos" data => '[ repos[debian_12] ,  repos[debian_11] ]';
>>
>> But when i need more specific repository
>> "myrepos" data => '[ repos[debian_10][debian] , 
>>  repos[debian_10][debian-security] ]'
>> I get this error:
>> error: Error parsing JSON expression '[debian] , 
>>  repos[debian_10][debian-security] ]': Unable to parse json data as array, 
>> did not start with '['
>>
>> How can I access the second levels of the data container and serialize 
>> them?
>>
>> Thanks.
>> Michal Svamberg
>>
>>

-- 
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/f1d10daf-84ea-420b-9161-6c69124c0357n%40googlegroups.com.
test.cf (application/octet-stream, 1.2 KB) - not displayed