Closed elboulangero closed 7 months ago
I propose to disable line wrapping, without switching to yaml.v3, with this patch: https://github.com/etix/mirrorbits/pull/154
Alternatively, let's just bump the gopkg.in/yaml dependency to v3: https://github.com/etix/mirrorbits/pull/163
Problem
The yaml library, and more precisely
yaml.Marshal
, wraps long lines after 80 characters by default. It is not configurable. It's an awkward default, and it's been fixed in the yaml.v3 library (where the default is no line wrapping). But in yaml.v2, for backward compat, they couldn't change it, so line wrapping is on.In mirrorbits, it manifests in the
show
andedit
commands. For example:Above, we can see that
SponsorName
spawns on two lines. Same behavior withmirrorbits edit
.It is a problem for scripts. For example, a script that parses the output of
mirrorbits show
, and based on a simple grep, will fail to get the second line.Part of our Ansible playbook, we also edit the mirrors programmatically, and the line-wrapping makes it difficult.
Solutions
Solution is to disable line wrapping, which can be done in two ways:
yaml.v3
(as it doesn't wrap by default)yaml.FutureLineWrap()
to disable line wrapping (cf. https://github.com/go-yaml/yaml/commit/7649d4548cb53a614db133b2a8ac1f31859dda8c for details)