Squarespace / pgbedrock

Manage a Postgres cluster's roles, role memberships, schema ownership, and privileges
https://pgbedrock.readthedocs.io/en/latest/
Other
313 stars 35 forks source link

Sort generated spec output #23

Closed zcmarine closed 6 years ago

zcmarine commented 6 years ago

pgbedrock generate currently outputs a spec with the keys in sorted order. This is because PyYAML by default sorts the output of a mapping (e.g. dict). However, the order of all items in a list is left preserved. This makes sense, but ideally we would sort this output, for two reasons: 1) It is easier for an end user to inspect their spec: they can look at things alphabetically. 2) It is easier to compare specs, whether that's when we run pgbedrock generate on a new version of the codebase and want to compare it to the existing spec, or when a user for whatever reason generates a new spec and wants to compare it to their existing one. By not having this in sorted order, the specs look superficially different.

This commit adds a function that sorts all lists within a generated spec before outputting that spec.