Skip to content

Commit

Permalink
rollback parseYaml native jsonnet function
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Nov 27, 2018
1 parent 4500ac0 commit bbc1607
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 3,418 deletions.
20 changes: 1 addition & 19 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 34 additions & 34 deletions drone/jsonnet/nativefuncs.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
package jsonnet

import (
"bytes"
"encoding/json"
"io"
// "bytes"
// "encoding/json"
// "io"

jsonnet "github.com/google/go-jsonnet"
jsonnetAst "github.com/google/go-jsonnet/ast"
"k8s.io/apimachinery/pkg/util/yaml"
// jsonnetAst "github.com/google/go-jsonnet/ast"
// "k8s.io/apimachinery/pkg/util/yaml"
)

// RegisterNativeFuncs adds kubecfg's native jsonnet functions to provided VM
func RegisterNativeFuncs(vm *jsonnet.VM) {
vm.NativeFunction(&jsonnet.NativeFunction{
Name: "parseJson",
Params: []jsonnetAst.Identifier{"json"},
Func: func(args []interface{}) (res interface{}, err error) {
data := []byte(args[0].(string))
err = json.Unmarshal(data, &res)
return
},
})
// vm.NativeFunction(&jsonnet.NativeFunction{
// Name: "parseJson",
// Params: []jsonnetAst.Identifier{"json"},
// Func: func(args []interface{}) (res interface{}, err error) {
// data := []byte(args[0].(string))
// err = json.Unmarshal(data, &res)
// return
// },
// })

vm.NativeFunction(&jsonnet.NativeFunction{
Name: "parseYaml",
Params: []jsonnetAst.Identifier{"yaml"},
Func: func(args []interface{}) (res interface{}, err error) {
ret := []interface{}{}
data := []byte(args[0].(string))
d := yaml.NewYAMLToJSONDecoder(bytes.NewReader(data))
for {
var doc interface{}
if err := d.Decode(&doc); err != nil {
if err == io.EOF {
break
}
return nil, err
}
ret = append(ret, doc)
}
return ret, nil
},
})
// vm.NativeFunction(&jsonnet.NativeFunction{
// Name: "parseYaml",
// Params: []jsonnetAst.Identifier{"yaml"},
// Func: func(args []interface{}) (res interface{}, err error) {
// ret := []interface{}{}
// data := []byte(args[0].(string))
// d := yaml.NewYAMLToJSONDecoder(bytes.NewReader(data))
// for {
// var doc interface{}
// if err := d.Decode(&doc); err != nil {
// if err == io.EOF {
// break
// }
// return nil, err
// }
// ret = append(ret, doc)
// }
// return ret, nil
// },
// })
}
202 changes: 0 additions & 202 deletions vendor/k8s.io/apimachinery/LICENSE

This file was deleted.

Loading

0 comments on commit bbc1607

Please sign in to comment.