зеркало из https://github.com/mozilla/scribe.git
validate import chain references during validation
This commit is contained in:
Родитель
3a744fe5f1
Коммит
d9a8824f38
|
@ -17,3 +17,13 @@ func hasChainVariables(arg string) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func validateChains(cl []string, d *Document) error {
|
||||
for _, x := range cl {
|
||||
_, err := d.getObjectInterface(x)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ type matchLine struct {
|
|||
groups []string
|
||||
}
|
||||
|
||||
func (f *filecontent) validate() error {
|
||||
func (f *filecontent) validate(d *Document) error {
|
||||
if len(f.Path) == 0 {
|
||||
return fmt.Errorf("filecontent path must be set")
|
||||
}
|
||||
|
@ -57,6 +57,10 @@ func (f *filecontent) validate() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = validateChains(f.ImportChain, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ func (f *filename) fireChains(d *Document) []evaluationCriteria {
|
|||
func (f *filename) mergeCriteria(c []evaluationCriteria) {
|
||||
}
|
||||
|
||||
func (f *filename) validate() error {
|
||||
func (f *filename) validate(d *Document) error {
|
||||
if len(f.Path) == 0 {
|
||||
return fmt.Errorf("filename path must be set")
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type genericSource interface {
|
|||
getCriteria() []evaluationCriteria
|
||||
isChain() bool
|
||||
expandVariables([]variable)
|
||||
validate() error
|
||||
validate(d *Document) error
|
||||
mergeCriteria([]evaluationCriteria)
|
||||
fireChains(*Document) []evaluationCriteria
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func (o *object) validate(d *Document) error {
|
|||
if si == nil {
|
||||
return fmt.Errorf("%v: no valid source interface", o.Object)
|
||||
}
|
||||
err := si.validate()
|
||||
err := si.validate(d)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v: %v", o.Object, err)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func (p *pkg) isChain() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (p *pkg) validate() error {
|
||||
func (p *pkg) validate(d *Document) error {
|
||||
if len(p.Name) == 0 {
|
||||
return fmt.Errorf("package must specify name")
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func (r *raw) fireChains(d *Document) []evaluationCriteria {
|
|||
func (r *raw) mergeCriteria(c []evaluationCriteria) {
|
||||
}
|
||||
|
||||
func (r *raw) validate() error {
|
||||
func (r *raw) validate(d *Document) error {
|
||||
if len(r.Identifiers) == 0 {
|
||||
return fmt.Errorf("at least one identifier must be present")
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче