modularize default checker implementation
Signed-off-by: Nathan13888 <29968201+Nathan13888@users.noreply.github.com>
This commit is contained in:
parent
08112df5df
commit
5b06ad7e98
|
@ -1,6 +1,7 @@
|
|||
package checkers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -27,7 +28,65 @@ var DefaultCheckerResult CheckerResult = CheckerResult{
|
|||
|
||||
// All "projects" which have been implemented.
|
||||
var SupportedProjects map[string]*Project = map[string]*Project{
|
||||
// "almalinux":&AlmaLinuxProject,
|
||||
// "alpine":&AlpineProject,
|
||||
// "apache":&ApacheProject,
|
||||
// "arch":&ArchProject,
|
||||
// "artix":&ArtixProject,
|
||||
// "centos":&CentosProject,
|
||||
// "ceph":&CephProject,
|
||||
// "cpan":&CpanProject,
|
||||
// "cran":&CranProject,
|
||||
// "ctan":&CtanProject,
|
||||
// "cygwin":&CygwinProject,
|
||||
"debian": &DebianProject,
|
||||
// "debiancd":&DebianCdProject,
|
||||
// "debianmultimedia":&DebianMultimediaProject,
|
||||
// "debianports":&DebianPortsProject,
|
||||
// "debiansecurity":&DebianSecurityProject,
|
||||
// "eclipse":&EclipseProject,
|
||||
// "fedora":&FedoraProject,
|
||||
// "freebsd":&FreebsdProject,
|
||||
// "gentoodistfiles":&GentooDistFilesProject,
|
||||
// "gentooportage":&GentooPortageProject,
|
||||
// "gnome":&GnomeProject,
|
||||
// "gnu":&GnuProject,
|
||||
// "gutenberg":&GutenbergProject,
|
||||
// "ipfire":&IpfireProject,
|
||||
// "kde":&KdeProject,
|
||||
// "kdeapplicationdata":&KdeApplicationDataProject,
|
||||
// "kernel":&KernelProject,
|
||||
// "linuxmint":&LinuxMintProject,
|
||||
// "linuxmint_packages":&LinuxMintPackagesProject,
|
||||
// "macports":&MacPortsProject,
|
||||
// "manjaro":&MajaroProject,
|
||||
// "mxlinux":&MxLinuxProject,
|
||||
// "mxlinux_iso":&MxLinuxIsoProject,
|
||||
// "mysql":&MysqlProject,
|
||||
// "netbsd":&NetBsdProject,
|
||||
// "nongnu":&NongnuProject,
|
||||
// "openbsd":&OpenbsdProject,
|
||||
// "opensuse":&OpensuseProject,
|
||||
// "parabola":&ParabolaProject,
|
||||
// "pkgsrc":&PkgsrcProject,
|
||||
// "puppy_linux":&PuppyLinuxProject,
|
||||
// "qtproject":&QtProject,
|
||||
// "racket":&RacketProject,
|
||||
// "raspberrypi":&RaspberrypiProject,
|
||||
// "raspbian":&RaspbianProject,
|
||||
// "sage":&SageProject,
|
||||
// "saltstack":&SaltStackProject,
|
||||
// "slackware":&SlackwareProject,
|
||||
// "tdf":&TdfProject,
|
||||
// "trisquel":&TrisquelProject,
|
||||
"ubuntu": &UbuntuProject,
|
||||
// "ubuntu_ports":&UbuntuPortsProject,
|
||||
// "ubuntu_ports_releases":&UbuntuPortsReleasesProject,
|
||||
// "ubuntu_releases":&UbuntuReleasesProject,
|
||||
// "vlc":&VlcProject,
|
||||
// "x_org":&XorgProject,
|
||||
// "xiph":&XiphProject,
|
||||
// "xubuntu_releases":&XubuntuReleasesProject,
|
||||
}
|
||||
|
||||
func LoadDefaultProjects() {
|
||||
|
@ -35,16 +94,95 @@ func LoadDefaultProjects() {
|
|||
|
||||
log.Info().Msg("Loading Default Projects.")
|
||||
|
||||
// LoadProject("almalinux")
|
||||
// LoadProject("alpine")
|
||||
// LoadProject("apache")
|
||||
// LoadProject("arch")
|
||||
// LoadProject("artix")
|
||||
// LoadProject("centos")
|
||||
// LoadProject("ceph")
|
||||
// LoadProject("cpan")
|
||||
// LoadProject("cran")
|
||||
// LoadProject("ctan")
|
||||
// LoadProject("cygwin")
|
||||
LoadProject("debian")
|
||||
// LoadProject("debiancd")
|
||||
// LoadProject("debianmultimedia")
|
||||
// LoadProject("debianports")
|
||||
// LoadProject("debiansecurity")
|
||||
// LoadProject("eclipse")
|
||||
// LoadProject("fedora")
|
||||
// LoadProject("freebsd")
|
||||
// LoadProject("gentoodistfiles")
|
||||
// LoadProject("gentooportage")
|
||||
// LoadProject("gnome")
|
||||
// LoadProject("gnu")
|
||||
// LoadProject("gutenberg")
|
||||
// LoadProject("ipfire")
|
||||
// LoadProject("kde")
|
||||
// LoadProject("kdeapplicationdata")
|
||||
// LoadProject("kernel")
|
||||
// LoadProject("linuxmint")
|
||||
// LoadProject("linuxmint_packages")
|
||||
// LoadProject("macports")
|
||||
// LoadProject("manjaro")
|
||||
// LoadProject("mxlinux")
|
||||
// LoadProject("mxlinux_iso")
|
||||
// LoadProject("mysql")
|
||||
// LoadProject("netbsd")
|
||||
// LoadProject("nongnu")
|
||||
// LoadProject("openbsd")
|
||||
// LoadProject("opensuse")
|
||||
// LoadProject("parabola")
|
||||
// LoadProject("pkgsrc")
|
||||
// LoadProject("puppy_linux")
|
||||
// LoadProject("qtproject")
|
||||
// LoadProject("racket")
|
||||
// LoadProject("raspberrypi")
|
||||
// LoadProject("raspbian")
|
||||
// LoadProject("sage")
|
||||
// LoadProject("saltstack")
|
||||
// LoadProject("slackware")
|
||||
// LoadProject("tdf")
|
||||
// LoadProject("trisquel")
|
||||
LoadProject("ubuntu")
|
||||
// LoadProject("ubuntu_ports")
|
||||
// LoadProject("ubuntu_ports_releases")
|
||||
// LoadProject("ubuntu_releases")
|
||||
// LoadProject("vlc")
|
||||
// LoadProject("x_org")
|
||||
// LoadProject("xiph")
|
||||
// LoadProject("xubuntu_releases")
|
||||
|
||||
}
|
||||
|
||||
func GetDefaultChecker(name string) *ProjectChecker {
|
||||
return &ProjectChecker{
|
||||
func GetDefaultChecker(name string, def bool, f func(*Project) (bool, error)) *ProjectChecker {
|
||||
checker := ProjectChecker{
|
||||
Name: fmt.Sprintf("default_checker_%s", name),
|
||||
CheckProject: func() (bool, error) {
|
||||
fmt.Println("Default Checker: ", name)
|
||||
return true, nil
|
||||
return false, errors.New("Project not supported.")
|
||||
},
|
||||
Default: def,
|
||||
}
|
||||
|
||||
proj, err := GetProject(name)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to get project")
|
||||
return &checker
|
||||
}
|
||||
|
||||
if f == nil {
|
||||
e := errors.New("Checker function is nil.")
|
||||
log.Error().Err(e).Msg("Missing custom checker function.")
|
||||
checker.CheckProject = func() (bool, error) {
|
||||
return false, e
|
||||
}
|
||||
return &checker
|
||||
}
|
||||
|
||||
checker.CheckProject = func() (bool, error) {
|
||||
return f(proj)
|
||||
}
|
||||
|
||||
return &checker
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue