Esempio n. 1
0
func (v SyntaxValidator) validateJob(job *Job) error {
	if job.Name == "" {
		return bosherr.New("Missing job name")
	}

	if job.Template != nil {
		return bosherr.New("'template' is deprecated in favor of 'templates'")
	}

	err := v.validateUpdate(&job.Update)
	if err != nil {
		return bosherr.WrapError(err, "Update")
	}

	props, err := bputil.NewStringKeyed().ConvertMap(job.PropertiesRaw)
	if err != nil {
		return bosherr.WrapError(err, "Properties")
	}

	job.Properties = props

	for i, na := range job.NetworkAssociations {
		err := v.validateNetworkAssociation(&job.NetworkAssociations[i])
		if err != nil {
			return bosherr.WrapError(err, "Network association %s (%d)", na.NetworkName, i)
		}
	}

	return nil
}
Esempio n. 2
0
func (v SyntaxValidator) validatePropDef(propDef PropertyDefinition) (PropertyDefinition, error) {
	def, err := bputil.NewStringKeyed().ConvertInterface(propDef.DefaultRaw)
	if err != nil {
		return propDef, bosherr.WrapError(err, "Default")
	}

	propDef.Default = def

	ex, err := bputil.NewStringKeyed().ConvertInterface(propDef.ExampleRaw)
	if err != nil {
		return propDef, bosherr.WrapError(err, "Example")
	}

	propDef.Example = ex

	return propDef, nil
}
Esempio n. 3
0
func (v SyntaxValidator) Validate() error {
	if v.deployment.Name == "" {
		return bosherr.New("Missing deployment name")
	}

	err := v.validateUpdate(&v.deployment.Update)
	if err != nil {
		return bosherr.WrapError(err, "Deployment update")
	}

	for i, net := range v.deployment.Networks {
		err := v.validateNetwork(&v.deployment.Networks[i])
		if err != nil {
			return bosherr.WrapError(err, "Network %s (%d)", net.Name, i)
		}
	}

	for i, release := range v.deployment.Releases {
		err := v.validateRelease(&v.deployment.Releases[i])
		if err != nil {
			return bosherr.WrapError(err, "Release %s (%d)", release.Name, i)
		}
	}

	err = v.validateCompilation(&v.deployment.Compilation)
	if err != nil {
		return bosherr.WrapError(err, "Compilation")
	}

	for i, job := range v.deployment.Jobs {
		err := v.validateJob(&v.deployment.Jobs[i])
		if err != nil {
			return bosherr.WrapError(err, "Job %s (%d)", job.Name, i)
		}
	}

	props, err := bputil.NewStringKeyed().ConvertMap(v.deployment.PropertiesRaw)
	if err != nil {
		return bosherr.WrapError(err, "Deployment properties")
	}

	v.deployment.Properties = props

	return nil
}