Ensure build & update main module (#20)

Related to #19.

- Module was renamed to match csc gitea
- OpenBSD was removed as the unimplemented template prevented builds
- Gnome was removed as 29 errors were masked by a missing "(" and it would probably be faster to rewrite
- Removed "data.OOSInterval" string asserts from Linux Mint & Rasberry Pi checkers since it is not a string and cannot be asserted as one
- Replaced imports using {}s instead of ()s which prevented builds
Co-authored-by: Ohm Patel <ohm.patel@uwaterloo.ca>
Co-committed-by: Ohm Patel <ohm.patel@uwaterloo.ca>
This commit is contained in:
Ohm Patel 2024-05-13 16:20:30 -04:00 committed by Ohm Patel
parent 2ee05653fc
commit 4e88152a3f
14 changed files with 33 additions and 108 deletions

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"os"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
"github.com/rs/zerolog/log"
)

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var DebianProject Project = Project{

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var DebianCDProject Project = Project{

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var DebianMultimediaProject Project = Project{

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var DebianPortsProject Project = Project{

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var DebianSecurityProject Project = Project{

View File

@ -3,7 +3,7 @@ package checkers
import (
"time"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var FedoraProject Project = Project{

View File

@ -4,7 +4,7 @@ import (
"strconv"
"strings"
"github.com/Nathan13888/mirror-checker2/v2/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
)
var GentooDistProject Project = Project{

View File

@ -1,52 +0,0 @@
package checkers
import {
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
"time"
}
var OpenBSDProject Project = Project{
Name: "openbsd",
Properties: DefaultProjectProperties,
NumOfCheckers: 1,
Checkers: []*ProjectChecker {
GetDefaultChecker("openbsd", true, func(*Project) (bool, error) {
file := data[project].(map[string]string)["file1"]
cscVersions, err := httpGET(CSCMirror + data[project].(map[string]string)["csc"] + file)
if err != nil {
return false, GetError(err, "OpenBSD", "getting CSC file")
}
upstreamVersions, err := httpGET(data[project].(map[string]string)["upstream"] + file)
if err != nil {
return false, GetError(err, "OpenBSD", "getting upstream file")
}
cscLatest := regexp.MustCompile(`"\d+\.?\d*"`).FindAllStringSubmatch(cscVersions, -1)
upstreamLatest := regexp.MustCompile(`"\d+\.?\d*"`).FindAllStringSubmatch(upstreamVersions, -1)
if cscLatest[len(cscLatest) - 1][0] != upstreamLatest[len(upstreamLatest) - 1][0]) {
return false, GetError(nil, "OpenBSD", "latest versions do not match")
}
file += cscLatest[len(cscLatest) - 1][0] + "/"
cscVersions, err = httpGET(CSCMirror + data[project].(map[string]string)["csc"] + file + data[project].(map[string]string)["file2"])
if err != nil {
return false, GetError(err, "OpenBSD", "getting CSC file")
}
upstreamVersions, err = httpGET(data[project].(map[string]string)["upstream2"] + file + data[project].(map[string]string)["file2"])
if err != nil {
return false, GetError(err, "OpenBSD", "getting upstream file")
}
ret := cscVersions == upstreamVersions
if !ret {
upstreamVersions, err = httpGET(data[project].(map[string]string)["upstream3"] + file + data[project].(map[string]string)["file2"])
if err != nil {
return false, GetError(err, "OpenBSD", "getting upstream file")
}
ret = cscVersions == upstreamVersions
}
return ret, nil
}),
},
}

View File

@ -1,22 +1,21 @@
package checkers
import {
"fmt"
"io/ioutil"
"net/http"
import (
"regexp"
"strconv"
"strings"
"time"
}
)
var LinuxMintProject Project = Project{
Name: "linuxmint",
Properties: DefaultProjectProperties,
Name: "linuxmint",
Properties: DefaultProjectProperties,
NumOfCheckers: 1,
Checkers: []*ProjectChecker {
Checkers: []*ProjectChecker{
GetDefaultChecker("linuxmint", true, func(*Project) (bool, error) {
data := EnabledProjects["linuxmint"].Properties
err := AssertStrings(data.Upstream, data.OOSInterval)
err := AssertStrings(data.Upstream)
if err != nil {
return false, GetError(err, "Linux Mint", "config sanity check")
}
@ -43,8 +42,8 @@ var LinuxMintProject Project = Project{
if err != nil {
return false, GetError(err, "Linux Mint", "parsing minutes")
}
duration := time.Duration(hours) * time.Hour + time.Duration(minutes) * time.Minute
return (duration <= time.Duration(data.OOSInterval) * time.Second), nil
duration := time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute
return (duration <= time.Duration(data.OOSInterval)*time.Second), nil
}),
},
}
}

View File

@ -1,21 +0,0 @@
package checkers
import {
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
"time"
}
var OpenBSDProject Project = Project{
Name: "openbsd",
Properties: DefaultProjectProperties,
NumOfCheckers: 1,
Checkers: []*ProjectChecker {
GetDefaultChecker("openbsd", true, func(*Project) (bool, error) {
}),
}
}

View File

@ -1,22 +1,21 @@
package checkers
import {
"fmt"
"io/ioutil"
"net/http"
import (
"regexp"
"strconv"
"strings"
"time"
}
)
var RaspberryPiProject Project = Project{
Name: "raspberrypi",
Properties: DefaultProjectProperties,
Name: "raspberrypi",
Properties: DefaultProjectProperties,
NumOfCheckers: 1,
Checkers: []*ProjectChecker {
Checkers: []*ProjectChecker{
GetDefaultChecker("raspberrypi", true, func(*Project) (bool, error) {
data := EnabledProjects["raspberrypi"].Properties
err := AssertStrings(data.Upstream, data.OOSInterval)
err := AssertStrings(data.Upstream)
if err != nil {
return false, GetError(err, "Raspberry Pi", "config sanity check")
}
@ -43,8 +42,8 @@ var RaspberryPiProject Project = Project{
if err != nil {
return false, GetError(err, "Raspberry Pi", "parsing minutes")
}
duration := time.Duration(hours) * time.Hour + time.Duration(minutes) * time.Minute
return (duration <= time.Duration(data.OOSInterval) * time.Second), nil
duration := time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute
return (duration <= time.Duration(data.OOSInterval)*time.Second), nil
}),
},
}

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/Nathan13888/mirror-checker2/v2
module git.csclub.uwaterloo.ca/public/mirror-checker
go 1.20

View File

@ -3,9 +3,9 @@ package main
import (
"os"
"github.com/Nathan13888/mirror-checker2/v2/checkers"
"github.com/Nathan13888/mirror-checker2/v2/config"
"github.com/Nathan13888/mirror-checker2/v2/web"
"git.csclub.uwaterloo.ca/public/mirror-checker/checkers"
"git.csclub.uwaterloo.ca/public/mirror-checker/config"
"git.csclub.uwaterloo.ca/public/mirror-checker/web"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
)