mirror of
https://github.com/simon987/ws_bucket.git
synced 2025-12-13 14:49:06 +00:00
jenkins setup
This commit is contained in:
17
api/api.go
17
api/api.go
@@ -12,7 +12,7 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var WorkDir, _ = filepath.Abs("./data/")
|
||||
var WorkDir = getWorkDir()
|
||||
|
||||
type Info struct {
|
||||
Name string `json:"name"`
|
||||
@@ -67,6 +67,10 @@ func LogRequestMiddleware(h fasthttp.RequestHandler) fasthttp.RequestHandler {
|
||||
|
||||
func New(db *gorm.DB) *WebApi {
|
||||
|
||||
if _, err := os.Stat(WorkDir); err != nil && os.IsNotExist(err) {
|
||||
_ = os.Mkdir(WorkDir, 0700)
|
||||
}
|
||||
|
||||
api := &WebApi{}
|
||||
|
||||
logrus.SetLevel(getLogLevel())
|
||||
@@ -134,3 +138,14 @@ func getLogLevel() logrus.Level {
|
||||
return level
|
||||
}
|
||||
}
|
||||
|
||||
func getWorkDir() string {
|
||||
workDir := os.Getenv("WS_BUCKET_WORKDIR")
|
||||
if workDir == "" {
|
||||
path, _ := filepath.Abs("./data")
|
||||
return path
|
||||
} else {
|
||||
path, _ := filepath.Abs(workDir)
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user