Include json files for fn source

This commit is contained in:
Phani Teja Marupaka
2020-05-27 17:45:15 -07:00
parent fb6830c98a
commit 4cd3944860
6 changed files with 93 additions and 33 deletions

View File

@@ -71,7 +71,7 @@ func (r *SourceRunner) runE(c *cobra.Command, args []string) error {
var inputs []kio.Reader
for _, a := range args {
inputs = append(inputs, kio.LocalPackageReader{PackagePath: a})
inputs = append(inputs, kio.LocalPackageReader{PackagePath: a, IncludeJSON: true})
}
if len(inputs) == 0 {
inputs = []kio.Reader{&kio.ByteReader{Reader: c.InOrStdin()}}

View File

@@ -21,25 +21,37 @@ func TestSourceCommand(t *testing.T) {
}
defer os.RemoveAll(d)
err = ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
kind: Deployment
metadata:
labels:
app: nginx2
name: foo
annotations:
app: nginx2
spec:
replicas: 1
err = ioutil.WriteFile(filepath.Join(d, "f1.json"), []byte(`
{
"kind": "Deployment",
"metadata": {
"labels": {
"app": "nginx2"
},
"name": "foo",
"annotations": {
"app": "nginx2"
}
},
"spec": {
"replicas": 1
}
}
---
kind: Service
metadata:
name: foo
annotations:
app: nginx
spec:
selector:
app: nginx
{
"kind": "Service",
"metadata": {
"name": "foo",
"annotations": {
"app": "nginx"
}
},
"spec": {
"selector": {
"app": "nginx"
}
}
}
`), 0600)
if !assert.NoError(t, err) {
return
@@ -86,22 +98,22 @@ kind: ResourceList
items:
- kind: Deployment
metadata:
labels:
app: nginx2
name: foo
annotations:
app: nginx2
config.kubernetes.io/index: '0'
config.kubernetes.io/path: 'f1.yaml'
config.kubernetes.io/path: 'f1.json'
labels:
app: nginx2
name: foo
spec:
replicas: 1
- kind: Service
metadata:
name: foo
annotations:
app: nginx
config.kubernetes.io/index: '1'
config.kubernetes.io/path: 'f1.yaml'
config.kubernetes.io/path: 'f1.json'
name: foo
spec:
selector:
app: nginx