Esempio n. 1
0
func (im *ImageManifest) UnmarshalJSON(data []byte) error {
	a := imageManifest(*im)
	err := json.Unmarshal(data, &a)
	if err != nil {
		if serr, ok := err.(*json.SyntaxError); ok {
			line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset)
			return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err)
		}
		return err
	}
	nim := ImageManifest(a)
	if err := nim.assertValid(); err != nil {
		return err
	}
	*im = nim
	return nil
}
Esempio n. 2
0
File: pod.go Progetto: matomesc/rkt
func (pm *PodManifest) UnmarshalJSON(data []byte) error {
	p := podManifest(*pm)
	err := json.Unmarshal(data, &p)
	if err != nil {
		if serr, ok := err.(*json.SyntaxError); ok {
			line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset)
			return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err)
		}
		return err
	}
	npm := PodManifest(p)
	if err := npm.assertValid(); err != nil {
		return err
	}
	*pm = npm
	return nil
}