Comments (1)
In general, Augeas lenses create files which are syntactically correct for a given syntax (such as Json), they do not necessarily make them "pretty".
Part of the problem is that for many languages such as JSON, spaces are not significant. So when a new entry is created, the amount of space that can or should be inserted becomes arbitrary.
In this case, it may be possible to update the lens to produce a more readable output, though I expect the indentation would remain messy.
I find it odd that appending another entry after "groups" inserts the new entry directly between previous one and the }
> augtool --noload --noautoload
augtool> set /augeas/load/Json/lens Json.lns
augtool> set /augeas/load/Json/incl /tmp/policy.json
augtool> load-file /tmp/policy.json
augtool> set /files/tmp/policy.json/dict/entry[last()+1] 'extra1'
augtool> set /files/tmp/policy.json/dict/entry[.='extra1']/string 'hello'
augtool> set /files/tmp/policy.json/dict/entry[last()+1] 'extra2'
augtool> set /files/tmp/policy.json/dict/entry[.='extra2']/string 'world'
augtool> preview /files/tmp/policy.json/
{
"context_is_admin": "role:admin or role:load-balancer_admin",
"admin_or_owner": "is_admin:True or project_id:%(project_id)s",
"load-balancer:read": "rule:admin_or_owner",
"load-balancer:read-global": "is_admin:True",
"load-balancer:write": "rule:admin_or_owner",
"load-balancer:read-quota": "rule:admin_or_owner",
"load-balancer:read-quota-global": "is_admin:True",
"load-balancer:write-quota": "is_admin:True"
,
"extra1":"hello","extra2":"world"}augtool>
There is definitely room for improvement here
from augeas.
Related Issues (20)
- Puppetfile lens doesn't allow inline comments
- how to encrypt password using htpasswd.lens HOT 1
- Poorly specified licensing for some lenses HOT 2
- Implicit function delcaration error with Apple Clang HOT 4
- User configuration HOT 1
- after updating from 1.12.0 to 1.14.1 sysctl.lns broken for OpenBSD HOT 1
- GitHub org information suggests nonexistent #augeas on freenode
- Samba lens is missing on Stock Lenses page, https://augeas.net/stock_lenses.html
- Redis lens parse error with the default Redis configuration for v6 and v7
- Augeas cannot parse krb5.conf if trailing brace on the same line
- augeas can't set an empty string (passwd/name and shadow/password) HOT 1
- Unable to add Match to /etc/sshd_conf HOT 2
- ruby-augeas gem produces (harmless?) warning under Ruby 3.2 HOT 1
- cannot parse /etc/fstab with trailing "," in the fs_mntops field HOT 11
- httpd lens Apache parsing error with unclosed tags HOT 4
- The NGINX lens reports "types" as a syntax error incorrectly HOT 1
- ignoring case for sshd_config HOT 1
- Augeas can't parse systemd unit file entry `ExecStartPre=+-command` HOT 4
- New chrony.conf option leapseclist unsupported by chrony lens
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from augeas.