gimlet icon indicating copy to clipboard operation
gimlet copied to clipboard

`gimlet seal` doesn't keep the field order

Open laszlocph opened this issue 4 years ago • 3 comments

When I run gimlet seal on a yaml file, it seals the fields on the given path.

But since it marshals and un-marshals the yaml into a map, it doesn't preserve field order.

The changeset therefor is too large, fields are shuffled.

The task is to keep the field order when running gimlet seal

laszlocph avatar Apr 20 '21 09:04 laszlocph

Potential solution: https://stackoverflow.com/a/42109240/8244089

laszlocph avatar Apr 20 '21 09:04 laszlocph

@laszlocph what about this alternative solution https://gist.github.com/tullo/f4f9e59ca123d976cf9c5f4fdfed7328 ? No yaml wrestling needed in this case and keeps the order in place.

tullo avatar Apr 25 '21 13:04 tullo

@laszlocph what about this alternative solution https://gist.github.com/tullo/f4f9e59ca123d976cf9c5f4fdfed7328 ? No yaml wrestling needed in this case and keeps the order in place.

Basically that would be string manipulation / matching.

  • Spec wise right now people can provide a JSONPath to select the node that needs encrypting, that wouldn't be satisfied easily with this.
  • In general this approach feels more fragile - for later enhancements for example would be more difficult

Comparing these drawbacks with the potential simplicity of using a yaml map type.. I would try the yaml.MapSlice first. Now I think of this, Kubernetes codebase does something similar. They have their own mapSlice too(?)

laszlocph avatar Apr 26 '21 07:04 laszlocph

https://github.com/gimlet-io/gimlet/pull/469

laszlocph avatar Mar 28 '23 12:03 laszlocph