Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Nov 2015 14:40:15 -0500
From:      Allan Jude <allanjude@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: libUCL / UCL as FreeBSD config question
Message-ID:  <564F771F.4060408@freebsd.org>
In-Reply-To: <1448048197.2765.74.camel@michaeleichorn.com>
References:  <5B598F72-C5DD-48FD-866D-F90E117D646E@rdsor.ro> <564F6118.5030702@freebsd.org> <1448048197.2765.74.camel@michaeleichorn.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--mCnnVqGiXtb36sxo7S1sdISFmMWKrhVGT
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 2015-11-20 14:36, Michael B. Eichorn wrote:
> On Fri, 2015-11-20 at 13:06 -0500, Allan Jude wrote:
>> =20
>> Although some limitation in libucl mean that, if you have a config
>> that
>> has comments in it, the comments are lost, as they are not
>> represented
>> in the in-memory version of the object that then gets serialized for
>> output. If you treat the config files as a database, then this is
>> fine,
>> but if the user expects to still hand edit them with an editor, this
>> is
>> a fairly big POLA violation.
>>
>=20
> Even if someday we stop editing by hand, comments are far to useful
> IMHO to drop yet. Context is very important to what we do, and
> sometimes keys are just to cryptic.
>=20
> I think I see two ways to avoid the POLA violation (but I am still
> rather new at this so be gentle)
>=20
> 1) Add special keys for use in memory 'value' and 'comment' such that
> the file:
>=20
> FreeBSD: {
>   url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
>   mirror_type: "srv",
>   signature_type: "fingerprints",
>   # A comment about fingerprints
>   # More comments
>   fingerprints: "/usr/share/keys/pkg", # an inline comment
>   enabled: yes
> }
>=20
> becomes in memory:
>=20
> FreeBSD: {
>   url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
> =20
> mirror_type: "srv",
>   signature_type: "fingerprints",
>   fingerprints: {
> =20
>   value: "/usr/share/keys/pkg"
>     comment: {
>       above: "A comment
> about fingerprints\nMore comments"
>       inline: "an inline comment"
>   =20
> }
>   }
>   enabled: yes
> }
>=20
> uclcmd should just return value like:
>=20
> # uclcmd get -f /etc/pkg/FreeBSD.conf FreeBSD.fingerprints
>=20
> returns
> /usr/share/keys/pkg
>=20
> unless the comment (C?) flag is used:
> # uclcmd get -f -C /etc/pkg/FreeBSD.conf FreeBSD.fingerprints
>=20
> returns
> # A comment about fingerprints
> # More comments
> /usr/share/keys/pkg	# an inline comment
>=20
> Finally if uclcmd set is used, if the session is interactive, ask the u=
ser what to do about the existing comment. If not append a note of the ch=
ange to the comment so that the file becomes:
>=20
> FreeBSD: {
>   url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
>   mirror_type: "srv",
>   signature_type: "fingerprints",
>   # A comment about fingerprints
>   # More comments
>   ## Comments may be outdated, non-interactive edit 20151120T1400
>   ## /usr/share/keys/pkg -> /root/keys/pkg
>   fingerprints: "/root/keys/pkg", # an inline comment
>   enabled: yes
> }
>=20
> 2) Assume everything can be commented, everything gets an extra pointer=
 for a potential comment string. Output all comments as the 'above' style=
 (bonus: comments become predictible in style). Same uclcmd behavior as d=
escribed above.
>=20
> The above are just ideas (and I know next to nothing about the guts of =
libucl), but I think comments are important, if this or something else wo=
rks I am willing to help with the implementation.
>=20
> Regards,
> Ike
>=20

This was discussed at the developer summit at BSDCan, sadly the video is
not online yet.

The issue is that UCL allows comments anywhere, for example:

#above
FreeBSD: {
   /* before */ url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
   mirror_type: /* middle */ "srv",
   signature_type: "fingerprints", /* after */
   # under
   fingerprints: "/root/keys/pkg", # inline-after
   enabled: yes
}

Etc. So the solution that was discussed was changing libucl to use an
Abstract Syntax Tree, but that is a lot of work. So for now, I am not
sure what the best approach is.



--=20
Allan Jude


--mCnnVqGiXtb36sxo7S1sdISFmMWKrhVGT
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQIcBAEBAgAGBQJWT3ciAAoJEBmVNT4SmAt+sxcP/j0IxRYFmj1BJXU41h9dHOuo
TuXE9txKMfB9V3+azjwRI5cBb/vEByHAjWMH4zVHE8ihk1G07h8uuXtJd/GeLFof
64uPl6gf9Tvc6i09GoHBjQaXtk2FNnalf8VHvdXB1HXHhqljBoCm15oPLDZQH3mH
tWxixM1jiQLL5zMz/kT82dcIV63EBhFKehHnd7hNyJYMfo0ywWAPVVOhrJzndw6w
avpK0DSiwMv/4/47UAE2n9xYOhD/AM1JJrepJml7cvSo/6wTtaL0trrGm3sKy9HK
oHppvmo7BOGKWKf1XhQahFCmj+MAOkUwTyvGotZxaTWYpC4XlkxvZpp+MDYFVWAz
CWQtFC8kI77ttflT3hK09IBcl0eaNI8FPMQf3qFeBrhQTDwjJeo2RAwrsnoLqTAr
dCl1gM3DEaONdLCYHWsox1q4e4kZ+dgvGR+ivssFIbQt7gjlxfhPBZkOmcf9Hsa9
nVB7jUoaqzdU7/Y4lnLaifLoTxpP2Z3b7Rjjy0PmyvzPm4iTsJt7gg++ReqI19Cf
bMhjna3UzaJRqSZjXPsfCQS0vR14c+yMXhlpB1x+gV0s36llnrVJ0/gppnpbiWDE
ixYpxj8KIWIA2ZqBQuGz9moyiLP9s0J3wfASeEszTqHd5MB/ZXF+xKQKuqEHSldp
y8CbOhdNT+mCDw7AtRlX
=zQ24
-----END PGP SIGNATURE-----

--mCnnVqGiXtb36sxo7S1sdISFmMWKrhVGT--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?564F771F.4060408>