Make kyaml indentation style configurable #4029
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
Kyaml is currently using a version of the go-yaml library that uses the old indentation style for sequence nodes, allowing us to get fixes from the upstream library without accepting the new indentation. The new indentation style is hardcoded as part of the NewEncoder method in kyaml.
This presents problems for other tools which are using kyaml as a low-level yaml processing library. For example, kpt had made the decision to go with the new indentation style for beta launch and are now unable to upgrade to kyaml v0.11.0, which is blocking them from moving forward. We should make the indentation style configurable in kyaml for the same reason that we needed the indentation style to be configurable in go-yaml: to prevent breaking whitespace changes from library consumers. This will help them have minimum future disruption to users and it is in the best interest of everyone to have one library that can be used by multiple tools and is maintained by both teams rather than requiring them to make separate forks.
The configurable indentation style should allow library consumers to decide whether to use the compact sequence indentation style where "- " is considered part of the indentation, or the wide sequence indentation style where "- " is not considered part of the indentation.
Potential options:
kyaml/yaml/alias.go
).kyaml.NewEncoder
andkyaml.Marshal
can take parameters to set the indentation style.NewEncoder
to return an interface that has all the methods of an Encoder, so that kpt can override it to directly use the upstream yaml.v3 Encoder.Of all these, I prefer option 1, because it is the simplest.
The text was updated successfully, but these errors were encountered: