diff --git a/cmd/joj3/env/env.go b/cmd/joj3/env/env.go index c3e33aa..29c905c 100644 --- a/cmd/joj3/env/env.go +++ b/cmd/joj3/env/env.go @@ -6,6 +6,12 @@ import ( "time" ) +const ( + ConfName = "JOJ3_CONF_NAME" + Groups = "JOJ3_GROUPS" + RunID = "JOJ3_RUN_ID" +) + type Attribute struct { ConfName string Groups string @@ -42,7 +48,7 @@ func init() { } func Set() { - os.Setenv("JOJ3_CONF_NAME", Attr.ConfName) - os.Setenv("JOJ3_GROUPS", Attr.Groups) - os.Setenv("JOJ3_RUN_ID", Attr.RunID) + os.Setenv(ConfName, Attr.ConfName) + os.Setenv(Groups, Attr.Groups) + os.Setenv(RunID, Attr.RunID) } diff --git a/cmd/repo-health-checker/main.go b/cmd/repo-health-checker/main.go index 8315cfb..494a5a2 100644 --- a/cmd/repo-health-checker/main.go +++ b/cmd/repo-health-checker/main.go @@ -6,7 +6,9 @@ import ( "fmt" "log/slog" "os" + "strings" + "github.com/joint-online-judge/JOJ3/cmd/joj3/env" "github.com/joint-online-judge/JOJ3/internal/conf" "github.com/joint-online-judge/JOJ3/pkg/healthcheck" ) @@ -61,22 +63,12 @@ func init() { func prepareTeapotCheck() ( confObj *conf.Conf, groups []string, err error, ) { - commitMsg, err := conf.GetCommitMsg() - if err != nil { - slog.Error("get commit msg", "error", err) - return - } - conventionalCommit, err := conf.ParseConventionalCommit(commitMsg) - if err != nil { - slog.Error("parse commit msg", "error", err) - return - } confObj, err = conf.ParseConfFile(confPath) if err != nil { slog.Error("parse conf", "error", err) return } - groups = conf.MatchGroups(confObj, conventionalCommit) + groups = strings.Split(os.Getenv(env.Groups), ",") return }