Ejemplo n.º 1
0
// assertValid performs extra assertions on an AppManifest to ensure that
// fields are set appropriately, etc. It is used exclusively when marshalling
// and unmarshalling an AppManifest. Most field-specific validation is
// performed through the individual types being marshalled; assertValid()
// should only deal with higher-level validation.
func (am *AppManifest) assertValid() error {
	if am.ACKind != "AppManifest" {
		return types.ACKindError(`missing or bad ACKind (must be "AppManifest")`)
	}
	if am.ACVersion.Empty() {
		return errors.New(`acVersion must be set`)
	}
	if am.Name.Empty() {
		return errors.New(`name must be set`)
	}
	if am.Version.Empty() {
		return errors.New(`version must be set`)
	}
	if am.OS.String() != "linux" {
		return errors.New(`missing or bad OS (must be "linux")`)
	}
	if am.Arch.String() != "amd64" {
		return errors.New(`missing or bad Arch (must be "amd64")`)
	}
	if len(am.Exec) < 1 {
		return errors.New(`Exec cannot be empty`)
	}
	// TODO(jonboulle): assert hashes is not empty?
	return nil
}
Ejemplo n.º 2
0
func (fsm *FilesetManifest) assertValid() error {
	if fsm.ACKind != "FilesetManifest" {
		return types.ACKindError(`missing or bad ACKind (must be "FilesetManifest")`)
	}
	if fsm.OS != "linux" {
		return errors.New(`missing or bad OS (must be "linux")`)
	}
	if fsm.Arch != "amd64" {
		return errors.New(`missing or bad Arch (must be "amd64")`)
	}
	return nil
}
Ejemplo n.º 3
0
// assertValid performs extra assertions on an ContainerRuntimeManifest to
// ensure that fields are set appropriately, etc. It is used exclusively when
// marshalling and unmarshalling an ContainerRuntimeManifest. Most
// field-specific validation is performed through the individual types being
// marshalled; assertValid() should only deal with higher-level validation.
func (cm *ContainerRuntimeManifest) assertValid() error {
	if cm.ACKind != "ContainerRuntimeManifest" {
		return types.ACKindError(`missing or bad ACKind (must be "ContainerRuntimeManifest")`)
	}
	return nil
}