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 for i, propExDef := range propDef.Examples { val, err := bputil.NewStringKeyed().ConvertInterface(propExDef.ValueRaw) if err != nil { return propDef, bosherr.WrapErrorf(err, "Example[%d]", i) } propDef.Examples[i].Value = val } return propDef, nil }
func (v SyntaxValidator) validateJob(job *Job) error { if job.Name == "" { return bosherr.Error("Missing job name") } if job.Template != nil { return bosherr.Error("'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.WrapErrorf(err, "Network association %s (%d)", na.NetworkName, i) } } return nil }
func (v SyntaxValidator) Validate() error { if v.deployment.Name == "" { return bosherr.Error("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.WrapErrorf(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.WrapErrorf(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.WrapErrorf(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 }