v3: Don't count sequence indicator as part of indentation. #746
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes 2 spaces from sequence indentations to account for space consumed by the sequence item indicator, and adds tests around the use of the
SetIndent
api.This maintains sequence indentation consistency with gopkg.in/yaml.v2 (see the example at https://pkg.go.dev/gopkg.in/yaml.v2#readme-api-documentation) and conforms to the comment:
in the specification at https://yaml.org/spec/1.2/spec.html#id2772075
Kubernetes is currently pinned to gopkg.in/yaml.v2, and kustomize (now a part of kubectl) is pinned to v3. We'd like the marshalling of sequences by kustomize and kubectl (e.g.
kubectl create deployment foo -o yaml --dry-run --image bar
) to match. This means reverting the parts of ae27a74 and a5ece68 that dealt with sequence indentation.There's more background in kubernetes-sigs/kustomize#3946. There's time pressure as we'd like kubectl and kustomize to be consistent before the next code kubernetes code freeze in early July, and this PR or a fork seem like the only options.