mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
E2e test for run with json
This commit is contained in:
@@ -130,17 +130,12 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) {
|
||||
if r.AcceptJSON && json.Valid([]byte(inputStr)) {
|
||||
// convert json to yaml string to generate resource list object
|
||||
// with appropriate format annotation
|
||||
yamlValue, err := yaml.ConvertJSONToYAMLString(input.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.SetAnnotations == nil {
|
||||
r.SetAnnotations = map[string]string{}
|
||||
}
|
||||
if !r.OmitReaderAnnotations {
|
||||
r.SetAnnotations[kioutil.FormatAnnotation] = JSON
|
||||
}
|
||||
inputStr = yamlValue
|
||||
}
|
||||
|
||||
values := strings.Split(inputStr, "\n---\n")
|
||||
|
||||
@@ -173,10 +173,11 @@ func TestLocalPackageReader_Read_JSON(t *testing.T) {
|
||||
}
|
||||
// TODO: Fix https://github.com/go-yaml/yaml/issues/44 so these are printed correctly
|
||||
expected := []string{
|
||||
`{"a": "b", metadata: {annotations: {config.kubernetes.io/index: '0', config.kubernetes.io/path: 'a_test.json'}}}
|
||||
`{"a": "b", metadata: {annotations: {config.kubernetes.io/format: 'json', config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'a_test.json'}}}
|
||||
`,
|
||||
`{"e": "f", "g": {"h": ["i", "j"]}, metadata: {annotations: {config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'b_test.json'}}}
|
||||
`{"e": "f", "g": {"h": ["i", "j"]}, metadata: {annotations: {config.kubernetes.io/format: 'json',
|
||||
config.kubernetes.io/index: '0', config.kubernetes.io/path: 'b_test.json'}}}
|
||||
`,
|
||||
}
|
||||
for i := range nodes {
|
||||
|
||||
Reference in New Issue
Block a user