Hi Joe.


> Am I overlooking something really simple, or am what I'm attempting not 
> possible?

I'd say the former. ;-)



> let testbranch =
>                [ key /testbranch/i . Sep.space . attribute . Util.eol ]

Here you have stated that you want to have a testbranch with exactly one 
subnode (matched by attribute), finished by the end of the 
line. So you need to change at least two things: allow several attributes for 
your testbranch and consider that you have several lines 
in your configuration file.



Ciao,

Xavier.



From: [email protected] [mailto:[email protected]] 
On Behalf Of Joe Nuts
Sent: Monday, March 07, 2016 3:30 PM
To: [email protected]
Subject: [augeas-devel] How to create a new tree node with more than one 
subnode (key)?




I'm having trouble building a lens that creates branches with multiple keys 
inside. My configuration file has unique lines which 
dictate which tree and branch a value is to be associated with, but the lens 
configuration I've build insists on building a sequence 
where one is not desired.

I've seen where a single line in a configuration file can be built to create 
multiple keys in a branch.
test_logrotate.aug shows single line "create 0664 root utmp" converted to
{.../create/mode = 0664
 .../create/owner = root
 .../create/group = utmp
}

Is this same result possible if the configuration file contains the values 
across multiple lines ( sometimes seperated by other 
configuration values )?

I've built the following lens and test as an example to show my (currently 
unachieved ) desired results.

-- simpletestconf.aug --
module Simpletestconf =
        autoload xfm

        let attribute = [ key /key[1-3]/i . Sep.space . store /value[1-3]/i ]

        let testbranch =
                [ key /testbranch/i . Sep.space . attribute . Util.eol ]

        let lns = ( Util.comment | testbranch ) *

        let filter = incl "/etc/simpletest.conf"

        let xfm = transform lns filter

-- dist/tests/test_simpletestconf.aug --
module Test_simpletestconf =

let example = "testbranch key1 value1
testbranch key2 value2
testbranch key3 value3
"

test SimpletestConf.lns get example =
{ "testbranch"
        { "key1" = "value1" }
        { "key2" = "value2" }
        { "key3" = "value3" }
}


Running augparse tests/test_simpletestconf.aug gives :
Test failure:tests/test_simpletestconf.aug:9.0-14.1:
 Expected:
{
  { "testbranch"
    { "key1" = "value1" }
    { "key2" = "value2" }
    { "key3" = "value3" }
  }
}

 Actual:
{
  { "testbranch"
    { "key1" = "value1" }
  }
  { "testbranch"
    { "key2" = "value2" }
  }
  { "testbranch"
    { "key3" = "value3" }
  }
}

Syntax error in lens definition
Failed to load tests/test_simpletestconf.aug




Sincerely
-Joe

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to