mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Simplify parsing
This commit is contained in:
@@ -87,18 +87,8 @@ metadata:
|
||||
expectedFiles: func(d string) map[string]string {
|
||||
return map[string]string{
|
||||
"deployment.json": `
|
||||
{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
"a-bool-value": "false",
|
||||
"a-int-value": "0",
|
||||
"a-string-value": ""
|
||||
},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
{"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "foo", annotations: {
|
||||
a-string-value: '', a-int-value: '0', a-bool-value: 'false'}}}
|
||||
`,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestSinkCommandJSON(t *testing.T) {
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo",
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/format: 'json', config.kubernetes.io/index: '0',
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'f1.json'}}, "spec": {"replicas": 1}}
|
||||
`))
|
||||
r.Command.SetArgs([]string{d})
|
||||
@@ -309,7 +309,7 @@ func TestSinkCommandJSON_Stdout(t *testing.T) {
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo",
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/format: 'json', config.kubernetes.io/index: '0',
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'f1.json'}}, "spec": {"replicas": 1}}
|
||||
`))
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ func (r *SourceRunner) runE(c *cobra.Command, args []string) error {
|
||||
inputs = append(inputs, kio.LocalPackageReader{PackagePath: a, MatchFilesGlob: kio.MatchAll})
|
||||
}
|
||||
if len(inputs) == 0 {
|
||||
inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin(), AcceptJSON: true}}
|
||||
inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}}
|
||||
}
|
||||
|
||||
err := kio.Pipeline{Inputs: inputs, Outputs: outputs}.Execute()
|
||||
|
||||
@@ -195,13 +195,12 @@ func TestSourceCommandJSON(t *testing.T) {
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo",
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/format: 'json', config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'f1.json'}}, "spec": {"replicas": 1}}
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f1.json'}},
|
||||
"spec": {"replicas": 1}}
|
||||
- {"apiVersion": "v1", "kind": "Abstraction", "metadata": {"name": "foo", "annotations": {
|
||||
"config.kubernetes.io/function": "container:\n image: gcr.io/example/reconciler:v1\n",
|
||||
"config.kubernetes.io/local-config": "true", config.kubernetes.io/format: 'json',
|
||||
config.kubernetes.io/index: '0', config.kubernetes.io/path: 'f2.json'}}, "spec": {
|
||||
"replicas": 3}}
|
||||
"config.kubernetes.io/local-config": "true", config.kubernetes.io/index: '0',
|
||||
config.kubernetes.io/path: 'f2.json'}}, "spec": {"replicas": 3}}
|
||||
`, b.String()) {
|
||||
return
|
||||
}
|
||||
@@ -309,8 +308,8 @@ func TestSourceCommandJSON_Stdin(t *testing.T) {
|
||||
kind: ResourceList
|
||||
items:
|
||||
- {"kind": "Deployment", "metadata": {"labels": {"app": "nginx2"}, "name": "foo",
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/format: 'json', config.kubernetes.io/index: '0'}},
|
||||
"spec": {"replicas": 1}}
|
||||
"annotations": {"app": "nginx2", config.kubernetes.io/index: '0'}}, "spec": {
|
||||
"replicas": 1}}
|
||||
`, out.String()) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user