nurse/check/endpoint.go

28 lines
610 B
Go
Raw Normal View History

2022-05-13 13:38:19 +00:00
package check
import (
"github.com/baez90/nurse/config"
"github.com/baez90/nurse/grammar"
)
func CheckForScript(script []grammar.Check, lkp ModuleLookup, srvLookup config.ServerLookup) (SystemChecker, error) {
compiledChecks := make([]SystemChecker, 0, len(script))
for i := range script {
rawChk := script[i]
mod, err := lkp.Lookup(rawChk.Initiator.Module)
if err != nil {
return nil, err
}
compiledCheck, err := mod.Lookup(rawChk, srvLookup)
if err != nil {
return nil, err
}
compiledChecks = append(compiledChecks, compiledCheck)
}
return Collection(compiledChecks), nil
}