refactor: move internal/conf to cmd/joj3
This commit is contained in:
parent
a834e0ff17
commit
19bcc90ae9
|
@ -7,8 +7,8 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
|
||||||
"github.com/joint-online-judge/JOJ3/internal/conf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var runningTest bool
|
var runningTest bool
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
joj3Conf "github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
|
||||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/stage"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/stage"
|
||||||
internalConf "github.com/joint-online-judge/JOJ3/internal/conf"
|
|
||||||
internalStage "github.com/joint-online-judge/JOJ3/internal/stage"
|
internalStage "github.com/joint-online-judge/JOJ3/internal/stage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mainImpl() (err error) {
|
func mainImpl() (err error) {
|
||||||
conf := new(internalConf.Conf)
|
conf := new(joj3Conf.Conf)
|
||||||
|
|
||||||
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
||||||
slog.SetDefault(logger)
|
slog.SetDefault(logger)
|
||||||
|
@ -46,13 +46,13 @@ func mainImpl() (err error) {
|
||||||
fallbackConfFileName = confFileName
|
fallbackConfFileName = confFileName
|
||||||
}
|
}
|
||||||
slog.Info("start joj3", "version", Version)
|
slog.Info("start joj3", "version", Version)
|
||||||
commitMsg, err := internalConf.GetCommitMsg()
|
commitMsg, err := joj3Conf.GetCommitMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("get commit msg", "error", err)
|
slog.Error("get commit msg", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
env.Attr.CommitMsg = commitMsg
|
env.Attr.CommitMsg = commitMsg
|
||||||
confPath, confStat, conventionalCommit, err := internalConf.GetConfPath(
|
confPath, confStat, conventionalCommit, err := joj3Conf.GetConfPath(
|
||||||
confFileRoot, confFileName, fallbackConfFileName, commitMsg, tag,
|
confFileRoot, confFileName, fallbackConfFileName, commitMsg, tag,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -60,7 +60,7 @@ func mainImpl() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
slog.Info("try to load conf", "path", confPath)
|
slog.Info("try to load conf", "path", confPath)
|
||||||
conf, err = internalConf.ParseConfFile(confPath)
|
conf, err = joj3Conf.ParseConfFile(confPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("parse conf", "error", err)
|
slog.Error("parse conf", "error", err)
|
||||||
return err
|
return err
|
||||||
|
@ -74,20 +74,20 @@ func mainImpl() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// log conf file info
|
// log conf file info
|
||||||
confSHA256, err := internalConf.GetSHA256(confPath)
|
confSHA256, err := joj3Conf.GetSHA256(confPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("get sha256", "error", err)
|
slog.Error("get sha256", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
slog.Info("conf info", "sha256", confSHA256, "modTime", confStat.ModTime(),
|
slog.Info("conf info", "sha256", confSHA256, "modTime", confStat.ModTime(),
|
||||||
"size", confStat.Size())
|
"size", confStat.Size())
|
||||||
if err := internalConf.CheckExpire(conf); err != nil {
|
if err := joj3Conf.CheckExpire(conf); err != nil {
|
||||||
slog.Error("conf check expire", "error", err)
|
slog.Error("conf check expire", "error", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// run stages
|
// run stages
|
||||||
groups := internalConf.MatchGroups(conf, conventionalCommit)
|
groups := joj3Conf.MatchGroups(conf, conventionalCommit)
|
||||||
env.Attr.Groups = strings.Join(groups, ",")
|
env.Attr.Groups = strings.Join(groups, ",")
|
||||||
env.Set()
|
env.Set()
|
||||||
_, forceQuitStageName, err := stage.Run(
|
_, forceQuitStageName, err := stage.Run(
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joint-online-judge/JOJ3/internal/conf"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
executors "github.com/joint-online-judge/JOJ3/internal/executor"
|
executors "github.com/joint-online-judge/JOJ3/internal/executor"
|
||||||
_ "github.com/joint-online-judge/JOJ3/internal/parser"
|
_ "github.com/joint-online-judge/JOJ3/internal/parser"
|
||||||
"github.com/joint-online-judge/JOJ3/internal/stage"
|
"github.com/joint-online-judge/JOJ3/internal/stage"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user