mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
Merge pull request #2657 from phanimarupaka/FixCommentsInFunctions
Fix copy comments for Folded style scalar nodes
This commit is contained in:
@@ -30,7 +30,16 @@ func (c *copier) VisitMap(s walk.Sources, _ *openapi.ResourceSchema) (*yaml.RNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *copier) VisitScalar(s walk.Sources, _ *openapi.ResourceSchema) (*yaml.RNode, error) {
|
func (c *copier) VisitScalar(s walk.Sources, _ *openapi.ResourceSchema) (*yaml.RNode, error) {
|
||||||
copy(s.Dest(), s.Origin())
|
to := s.Origin()
|
||||||
|
// TODO: File a bug with upstream yaml to handle comments for FoldedStyle scalar nodes
|
||||||
|
// Hack: convert FoldedStyle scalar node to DoubleQuotedStyle as the line comments are
|
||||||
|
// being serialized without space
|
||||||
|
// https://github.com/GoogleContainerTools/kpt/issues/766
|
||||||
|
if to != nil && to.Document().Style == yaml.FoldedStyle {
|
||||||
|
to.Document().Style = yaml.DoubleQuotedStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
copy(s.Dest(), to)
|
||||||
return s.Dest(), nil
|
return s.Dest(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,29 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
items:
|
||||||
- a # comment
|
- a # comment
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "copy_comments_folded_style",
|
||||||
|
from: `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
data:
|
||||||
|
somekey: "012345678901234567890123456789012345678901234567890123456789012345678901234" # x
|
||||||
|
`,
|
||||||
|
to: `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
data:
|
||||||
|
somekey: >-
|
||||||
|
012345678901234567890123456789012345678901234567890123456789012345678901234
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
data:
|
||||||
|
somekey: "012345678901234567890123456789012345678901234567890123456789012345678901234" # x
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user