-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode.go
More file actions
34 lines (29 loc) · 691 Bytes
/
Copy pathdecode.go
File metadata and controls
34 lines (29 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package k8s
import (
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/runtime"
//"encoding/json"
"io/ioutil"
)
func DecodeFile(path string) (runtime.Object, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
return latest.Codec.Decode(data)
}
func Decode(data []byte) (runtime.Object, error) {
return latest.Codec.Decode(data)
}
// Read a Kubernetes file and decode it into an object.
// FIXME: This is an ugly first pass that does not use the k8s API. It only
// handles JSON.
/*
func DecodeFile(path string, o interface{}) error {
data, err := ioutil.ReadFile(path)
if err != nil {
return err
}
return json.Unmarshal(data, o)
}
*/