1 Star 0 Fork 31

luoxuanzao/open-source-summer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Init.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
liuxuezhuo 提交于 2022-09-30 21:48 . init
package main
import (
"flag"
"fmt"
"os"
"github.com/opensourceways/community-robot-lib/secret"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"openSummer/Client"
"openSummer/Dao"
"openSummer/Model"
"openSummer/service"
)
func ReadYamlConfig(path string) (*Model.TaskConfig, error) {
conf := &Model.TaskConfig{}
if f, err := os.Open(path); err != nil {
return nil, err
} else {
err := yaml.NewDecoder(f).Decode(conf)
if err != nil {
return nil, err
}
}
return conf, nil
}
func Init() {
o := gatherOptions(flag.NewFlagSet(os.Args[0], flag.ExitOnError), os.Args[1:]...)
if err := o.Validate(); err != nil {
logrus.WithError(err).Fatal("Invalid Options")
}
var err error
secretAgent := new(secret.Agent)
if err := secretAgent.Start([]string{o.github.TokenPath, o.gitee.TokenPath, o.gitlab.TokenPath}); err != nil {
logrus.WithError(err).Fatal("Error starting secret agent.")
}
Client.Gitee = Client.GetGiteeClient(string(secretAgent.GetTokenGenerator(o.gitee.TokenPath)()))
Client.Gitlab = Client.GetGitlabClient(string(secretAgent.GetTokenGenerator(o.gitlab.TokenPath)()))
service.SyncTask, err = ReadYamlConfig(o.service.ConfigFile)
if err != nil {
_ = fmt.Errorf(err.Error())
}
service.UserMap = make(map[string]Model.User)
users := Dao.GetUser()
for _, user := range users {
service.UserMap[user.Identifier] = user
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hxcplxz/open-source-summer.git
git@gitee.com:hxcplxz/open-source-summer.git
hxcplxz
open-source-summer
open-source-summer
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385