feat: 修改配置文件,删除无用代码

This commit is contained in:
zhengkunwang223 2023-02-13 14:28:04 +08:00 committed by zhengkunwang223
parent 493fb57dff
commit cb281b2513
4 changed files with 15 additions and 5 deletions

View File

@ -8,8 +8,8 @@ type System struct {
DataDir string `mapstructure:"data_dir"`
Cache string `mapstructure:"cache"`
Backup string `mapstructure:"backup"`
AppOss string `mapstructure:"app_oss"`
AppRepoOwner string `mapstructure:"app_repo_owner"`
AppRepoName string `mapstructure:"app_repo_name"`
EncryptKey string `mapstructure:"encrypt_key"`
BaseDir string `mapstructure:"base_dir"`
}

View File

@ -18,6 +18,7 @@ import (
func Init() {
baseDir := "/opt"
mode := "local"
fileOp := files.NewFileOp()
v := viper.NewWithOptions()
v.SetConfigType("yaml")
@ -28,6 +29,7 @@ func Init() {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}
} else {
mode = "release"
stdout, err := cmd.Exec("grep '^BASE_DIR=' /usr/bin/1pctl | cut -d'=' -f2")
if err != nil {
panic(err)
@ -50,6 +52,9 @@ func Init() {
if err := v.Unmarshal(&serverConfig); err != nil {
panic(err)
}
if mode == "local" && serverConfig.System.BaseDir != "" {
baseDir = serverConfig.System.BaseDir
}
global.CONF = serverConfig
global.CONF.BaseDir = baseDir
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"gitee.com/openeuler/go-gitee/gitee"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/google/go-github/github"
"net/http"
"time"
@ -28,10 +29,14 @@ func CheckAndGetInfo(owner, repoName string) (*RepoInfo, error) {
res, err := getLatestRepoInfo(repoType, owner, repoName)
if err == nil {
return res, nil
} else {
global.LOG.Errorf("get %s last release version failed %s", repoType, err.Error())
}
} else {
global.LOG.Errorf("get %s remote repo [%s] failed", repoType, url)
}
}
return nil, errors.New("remote repo get failed")
return nil, errors.New("all remote repo get failed")
}
func checkValid(addr string) bool {

View File

@ -1,8 +1,8 @@
system:
db_file: 1Panel.db
app_oss: "https://1panel.oss-cn-hangzhou.aliyuncs.com"
app_repo_owner: "1Panel-dev"
app_repo_name: 'appstore'
app_repo_owner: 1Panel-dev
app_repo_name: appstore
base_dir: /opt
log:
level: debug