forked from klovercloud-dev/security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (40 loc) · 1.13 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
package main
import (
"github.com/klovercloud-ci-cd/security/api"
"github.com/klovercloud-ci-cd/security/config"
"github.com/klovercloud-ci-cd/security/core/v1"
"github.com/klovercloud-ci-cd/security/dependency"
_ "github.com/klovercloud-ci-cd/security/docs"
"github.com/klovercloud-ci-cd/security/enums"
)
// @title Klovercloud-ci-security API
// @description Klovercloud-security API
func main() {
e := config.New()
go initResources()
initPermissions()
initRoles()
api.Routes(e)
e.Logger.Fatal(e.Start(":" + config.ServerPort))
}
func initResources() {
resourceService := dependency.GetV1ResourceService()
for _, each := range config.Resources {
resourceService.Store(v1.Resource{Name: each})
}
}
func initPermissions() {
permissionService := dependency.GetV1PermissionService()
for _, each := range config.Permissions {
permissionService.Store(v1.Permission{Name: each})
}
}
func initRoles() {
permissions := dependency.GetV1PermissionService().Get()
role := v1.RoleDto{
Name: string(enums.ADMIN),
Permissions: permissions,
}
dependency.GetV1RoleService().Store(role)
}
//swag init --parseDependency --parseInternal