Esempio n. 1
0
func (s *ImageConfigSuite) TestValidateMissingDependencies() {
	s.image.Depends = []string{"one", "two"}
	conf := NewConfig()
	err := ValidateResourcesExist(pth.NewPath(""), conf, s.image.Dependencies())
	s.Error(err)
	s.Contains(err.Error(), "missing dependencies: one, two")
}
Esempio n. 2
0
func (s *JobConfigSuite) TestValidateMissingUse() {
	s.conf.Resources["example"] = &AliasConfig{}
	s.job.Use = "example"
	err := s.job.Validate(pth.NewPath(""), s.conf)
	s.Error(err)
	s.Contains(err.Error(), "example is not an image resource")
}
Esempio n. 3
0
func (s *ImageConfigSuite) TestValidateMissingOneOfRequired() {
	s.image.Dockerfile = ""
	s.image.Context = ""

	conf := NewConfig()
	err := s.image.Validate(pth.NewPath(""), conf)
	s.Error(err)
	s.Contains(err.Error(), "one of dockerfile, context, or pull is required")

}
Esempio n. 4
0
func (s *JobConfigSuite) TestValidateMissingMount() {
	s.conf.Resources["one"] = NewImageConfig()
	s.conf.Resources["two"] = NewImageConfig()
	s.conf.Resources["example"] = NewImageConfig()
	s.job.Use = "example"
	s.job.Mounts = []string{"one", "two"}

	err := s.job.Validate(pth.NewPath(""), s.conf)
	s.Error(err)
	s.Contains(err.Error(), "one is not a mount resource")
}
Esempio n. 5
0
// validate validates all the resources in the config
func validate(config *Config) error {
	for name, resource := range config.Resources {
		path := pth.NewPath(name)

		if err := configtf.ValidateFields(path, resource); err != nil {
			return err
		}
		if err := ValidateResourcesExist(path, config, resource.Dependencies()); err != nil {
			return err
		}
		if err := resource.Validate(path, config); err != nil {
			return err
		}
	}
	config.Meta.Validate(config)
	return nil
}