(path string, doc *pb.Document)
| 47 | } |
| 48 | |
| 49 | func KubeObjectFromDocument(path string, doc *pb.Document) (KubeObject, error) { |
| 50 | kind, err := kindFromPath(path) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | |
| 55 | base := BaseObject(kind) |
| 56 | if base == nil { |
| 57 | return nil, fmt.Errorf("unable to find Kind for '%s'", kind) |
| 58 | } |
| 59 | |
| 60 | err = data.Unmarshal(doc, &base) |
| 61 | if err != nil { |
| 62 | return nil, err |
| 63 | } |
| 64 | return base, nil |
| 65 | } |
| 66 | |
| 67 | func kindFromPath(path string) (string, error) { |
| 68 | parts := strings.Split(path, "/") |
no test coverage detected