mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
compact sequence indent
This commit is contained in:
committed by
Katrina Verey
parent
979f03e76c
commit
4b66043735
@@ -10,6 +10,15 @@ import (
|
||||
"sigs.k8s.io/kustomize/kyaml/internal/forked/github.com/go-yaml/yaml"
|
||||
)
|
||||
|
||||
const CompactSequenceStyle = "compact"
|
||||
const WideSequenceStyle = "wide"
|
||||
|
||||
const DefaultIndent = 2
|
||||
const DefaultSequenceStyle = CompactSequenceStyle
|
||||
|
||||
var sequenceIndentationStyle = DefaultSequenceStyle
|
||||
var indent = DefaultIndent
|
||||
|
||||
// Expose the yaml.v3 functions so this package can be used as a replacement
|
||||
|
||||
type Decoder = yaml.Decoder
|
||||
@@ -21,7 +30,7 @@ type Node = yaml.Node
|
||||
type Style = yaml.Style
|
||||
type TypeError = yaml.TypeError
|
||||
type Unmarshaler = yaml.Unmarshaler
|
||||
var Marshal = func (in interface{}) ([]byte, error) {
|
||||
var Marshal = func(in interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := NewEncoder(&buf).Encode(in)
|
||||
if err != nil {
|
||||
@@ -33,7 +42,10 @@ var Unmarshal = yaml.Unmarshal
|
||||
var NewDecoder = yaml.NewDecoder
|
||||
var NewEncoder = func(w io.Writer) *yaml.Encoder {
|
||||
e := yaml.NewEncoder(w)
|
||||
e.SetIndent(2)
|
||||
e.SetIndent(indent)
|
||||
if sequenceIndentationStyle == CompactSequenceStyle {
|
||||
e.CompactSeqIndent()
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user