Esempio n. 1
0
// ValidateResourcesExist checks that the list of resources is defined in the
// config and returns an error if a resources is not defined.
func ValidateResourcesExist(path pth.Path, c *Config, names []string) error {
	missing := []string{}
	for _, name := range names {
		resource := task.ParseName(name).Resource()
		if _, ok := c.Resources[resource]; !ok {
			missing = append(missing, resource)
		}
	}
	if len(missing) != 0 {
		return pth.Errorf(path, "missing dependencies: %s", strings.Join(missing, ", "))
	}
	return nil
}
Esempio n. 2
0
File: job.go Progetto: dnephin/dobi
// Validate checks that all fields have acceptable values
func (c *JobConfig) Validate(path pth.Path, config *Config) *pth.Error {
	validators := []validator{
		newValidator("use", func() error { return c.validateUse(config) }),
		newValidator("mounts", func() error { return c.validateMounts(config) }),
		newValidator("artifact", c.Artifact.Validate),
		newValidator("sources", c.Sources.Validate),
	}
	for _, validator := range validators {
		if err := validator.validate(); err != nil {
			return pth.Errorf(path.Add(validator.name), err.Error())
		}
	}
	return nil
}
Esempio n. 3
0
// Validate checks that all fields have acceptable values
func (c *ImageConfig) Validate(path pth.Path, config *Config) *pth.Error {
	if err := c.validateBuildOrPull(); err != nil {
		return pth.Errorf(path, err.Error())
	}
	return nil
}