Exemplo n.º 1
0
func (pm *PodManifest) UnmarshalJSON(data []byte) error {
	p := podManifest(*pm)
	err := json.Unmarshal(data, &p)
	if err != nil {
		return err
	}
	if p.ACKind != string(schema.PodManifestKind) {
		return types.InvalidACKindError(schema.PodManifestKind)
	}
	*pm = PodManifest(p)
	return nil
}
Exemplo n.º 2
0
func (im *ImageManifest) UnmarshalJSON(data []byte) error {
	i := imageManifest(*im)
	err := json.Unmarshal(data, &i)
	if err != nil {
		return err
	}
	if i.ACKind != string(schema.ImageManifestKind) {
		return types.InvalidACKindError(schema.ImageManifestKind)
	}
	*im = ImageManifest(i)
	return nil
}
Exemplo n.º 3
0
	npm := PodManifest(p)
	if err := npm.assertValid(); err != nil {
		return err
	}
	*pm = npm
	return nil
}

func (pm PodManifest) MarshalJSON() ([]byte, error) {
	if err := pm.assertValid(); err != nil {
		return nil, err
	}
	return json.Marshal(podManifest(pm))
}

var pmKindError = types.InvalidACKindError(PodManifestKind)

// assertValid performs extra assertions on an PodManifest to
// ensure that fields are set appropriately, etc. It is used exclusively when
// marshalling and unmarshalling an PodManifest. Most
// field-specific validation is performed through the individual types being
// marshalled; assertValid() should only deal with higher-level validation.
func (pm *PodManifest) assertValid() error {
	if pm.ACKind != PodManifestKind {
		return pmKindError
	}
	return nil
}

type AppList []RuntimeApp
Exemplo n.º 4
0
	nim := ImageManifest(a)
	if err := nim.assertValid(); err != nil {
		return err
	}
	*im = nim
	return nil
}

func (im ImageManifest) MarshalJSON() ([]byte, error) {
	if err := im.assertValid(); err != nil {
		return nil, err
	}
	return json.Marshal(imageManifest(im))
}

var imKindError = types.InvalidACKindError(ImageManifestKind)

// assertValid performs extra assertions on an ImageManifest to ensure that
// fields are set appropriately, etc. It is used exclusively when marshalling
// and unmarshalling an ImageManifest. Most field-specific validation is
// performed through the individual types being marshalled; assertValid()
// should only deal with higher-level validation.
func (im *ImageManifest) assertValid() error {
	if im.ACKind != ImageManifestKind {
		return imKindError
	}
	if im.ACVersion.Empty() {
		return errors.New(`acVersion must be set`)
	}
	if im.Name.Empty() {
		return errors.New(`name must be set`)