feat(cmd): load groups from env
This commit is contained in:
parent
6ddd403f08
commit
e8c6e87b94
12
cmd/joj3/env/env.go
vendored
12
cmd/joj3/env/env.go
vendored
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user