skycfg
skycfg copied to clipboard
Make protobuf map --> starlark.Dict ordering deterministic
If I have a protobuf map in the host environment (say as a context variable), iterating through it is non-deterministic. That results in some pretty gnarly workarounds in the starlark code itself.
This PR performs some best-effort deterministic at the starlark conversion stage. It ensures that protobuf map items are inserts into the starlark dictionary in naturally sorted order (using starlark's own internal partial ordering).
Sorting is really awkward in starlark itself, so this type of convenience is extremely helpful