-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (42 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"log"
"registryui/client"
"registryui/view"
"github.com/labstack/echo/v4"
)
var (
basepath = "/registry"
debug = true
registry = "192.168.1.254:5000"
access = "https://registry:5000"
listen = "0.0.0.0:8080"
)
func init() {
flag.StringVar(&basepath, "basepath", basepath, "Base path of Docker Registry UI")
flag.BoolVar(&debug, "debug", debug, "Debug mode. Affects only templates")
flag.StringVar(®istry, "registry", registry, "Registry URL with schema and port for view")
flag.StringVar(&access, "access", access, "Registry access address")
flag.StringVar(&listen, "listen", listen, "Listen address")
}
func main() {
flag.Parse()
// 初始化数据层,用户获取registry数据
r, err := client.NewRegistry(access)
if err != nil {
log.Fatal(err)
}
model := view.NewModel(basepath, r)
// 初始化模板引擎
e := echo.New()
e.Renderer = view.SetupRender(debug, registry, basepath)
e.Static(basepath+"/static", "resources/static")
e.File("/favicon.ico", "resources/static/favicon.ico")
e.GET("", model.Redrict)
e.GET(basepath, model.Repositories)
e.GET(basepath+"/:repo", model.Tags)
e.GET(basepath+"/:repo/:tag", model.Manifest)
// 启动服务
log.Fatal(e.Start(listen))
}