Пример #1
0
func main() {
	dao.InitDatabase()
	initRouters()
	job.InitWorkerPool()
	go job.Dispatch()
	resumeJobs()
	beego.Run()
}
Пример #2
0
func init() {
	dao.InitDatabase()
	_, file, _, _ := runtime.Caller(1)
	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
	beego.BConfig.WebConfig.Session.SessionOn = true
	beego.TestBeegoInit(apppath)

	beego.Router("/api/search/", &SearchAPI{})
	beego.Router("/api/projects/", &ProjectAPI{}, "get:List;post:Post;head:Head")
	beego.Router("/api/projects/:id", &ProjectAPI{}, "delete:Delete;get:Get")
	beego.Router("/api/users/?:id", &UserAPI{})
	beego.Router("/api/users/:id([0-9]+)/password", &UserAPI{}, "put:ChangePassword")
	beego.Router("/api/users/:id/sysadmin", &UserAPI{}, "put:ToggleUserAdminRole")
	beego.Router("/api/projects/:id/publicity", &ProjectAPI{}, "put:ToggleProjectPublic")
	beego.Router("/api/projects/:id([0-9]+)/logs/filter", &ProjectAPI{}, "post:FilterAccessLog")
	beego.Router("/api/projects/:pid([0-9]+)/members/?:mid", &ProjectMemberAPI{}, "get:Get;post:Post;delete:Delete;put:Put")
	beego.Router("/api/statistics", &StatisticAPI{})
	beego.Router("/api/users/?:id", &UserAPI{})
	beego.Router("/api/logs", &LogAPI{})
	beego.Router("/api/repositories", &RepositoryAPI{})
	beego.Router("/api/repositories/tags", &RepositoryAPI{}, "get:GetTags")
	beego.Router("/api/repositories/manifests", &RepositoryAPI{}, "get:GetManifests")
	beego.Router("/api/repositories/top", &RepositoryAPI{}, "get:GetTopRepos")
	beego.Router("/api/targets/", &TargetAPI{}, "get:List")
	beego.Router("/api/targets/", &TargetAPI{}, "post:Post")
	beego.Router("/api/targets/:id([0-9]+)", &TargetAPI{})
	beego.Router("/api/targets/:id([0-9]+)/policies/", &TargetAPI{}, "get:ListPolicies")
	beego.Router("/api/targets/ping", &TargetAPI{}, "post:Ping")
	beego.Router("/api/policies/replication/:id([0-9]+)", &RepPolicyAPI{})
	beego.Router("/api/policies/replication", &RepPolicyAPI{}, "get:List")
	beego.Router("/api/policies/replication", &RepPolicyAPI{}, "post:Post;delete:Delete")
	beego.Router("/api/policies/replication/:id([0-9]+)/enablement", &RepPolicyAPI{}, "put:UpdateEnablement")

	_ = updateInitPassword(1, "Harbor12345")

	//syncRegistry
	if err := SyncRegistry(); err != nil {
		log.Fatalf("failed to sync repositories from registry: %v", err)
	}

	//Init user Info
	admin = &usrInfo{adminName, adminPwd}
	unknownUsr = &usrInfo{"unknown", "unknown"}
	testUser = &usrInfo{TestUserName, TestUserPwd}

}
Пример #3
0
func main() {

	beego.BConfig.WebConfig.Session.SessionOn = true
	//TODO
	redisURL := os.Getenv("_REDIS_URL")
	if len(redisURL) > 0 {
		beego.BConfig.WebConfig.Session.SessionProvider = "redis"
		beego.BConfig.WebConfig.Session.SessionProviderConfig = redisURL
	}
	//
	beego.AddTemplateExt("htm")

	dao.InitDatabase()

	if err := updateInitPassword(adminUserID, config.InitialAdminPassword()); err != nil {
		log.Error(err)
	}
	initRouters()
	if err := api.SyncRegistry(); err != nil {
		log.Error(err)
	}
	beego.Run()
}