pack html in program

This commit is contained in:
w-mj 2023-02-23 12:23:55 +08:00
parent da77bd0ca1
commit 67e1170787
No known key found for this signature in database
GPG Key ID: 3A2CB5BE2F835897
4 changed files with 9 additions and 28 deletions

View File

@ -1,4 +1,4 @@
IMAGE_TAG ?= docker.educg.net/k8s/manager:dev IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:v1.0.1
build: export CGO_ENABLED=0 build: export CGO_ENABLED=0
build: export GOOS=linux build: export GOOS=linux
@ -18,3 +18,6 @@ uninstall:
restart: docker restart: docker
kubectl delete -f install.yaml kubectl delete -f install.yaml
kubectl apply -f install.yaml kubectl apply -f install.yaml
push: docker
docker push $(IMAGE_TAG)

View File

@ -23,7 +23,7 @@ kubectl get secret dev-secret -o yaml
```bash ```bash
helm repo add traefik https://traefik.github.io/charts helm repo add traefik https://traefik.github.io/charts
helm repo update helm repo update
helm install traefik traefik/traefik helm install -f traefik-conf.yaml traefik traefik/traefik
helm uninstall traefik traefik/traefik helm uninstall traefik
helm install traefik traefik/traefik --set expose.dashboard=true helm install traefik traefik/traefik --set expose.dashboard=true
``` ```

15
main.go
View File

@ -17,21 +17,12 @@ func main() {
r := gin.Default() r := gin.Default()
//r.SetFuncMap(template.FuncMap{
// "inc": m.Inc,
//})
//
//tmp := template.Must(template.New("").
// Funcs(template.FuncMap{
// "inc": m.Inc,
// }).
// ParseFS(f, "template/*"))
//
//r.SetHTMLTemplate(tmp)
fp, _ := fs.Sub(f, "static") fp, _ := fs.Sub(f, "static")
r.StaticFS("/static", http.FS(fp)) r.StaticFS("/static", http.FS(fp))
r.GET("/index", m.JWTAuthMiddleware, m.AppPage) r.GET("/index", m.JWTAuthMiddleware, func(c *gin.Context) {
c.FileFromFS("/template/app_view.html", http.FS(f))
})
r.GET("/apps", m.JWTAuthMiddleware, m.GetAppsController) r.GET("/apps", m.JWTAuthMiddleware, m.GetAppsController)
r.POST("/app", m.JWTAuthMiddleware, m.CreateUpdateDeleteApp) r.POST("/app", m.JWTAuthMiddleware, m.CreateUpdateDeleteApp)
r.PUT("/app", m.JWTAuthMiddleware, m.CreateUpdateDeleteApp) r.PUT("/app", m.JWTAuthMiddleware, m.CreateUpdateDeleteApp)

View File

@ -49,20 +49,7 @@ func statusString(a *AppViewModel) string {
} }
func AppPage(c *gin.Context) { func AppPage(c *gin.Context) {
//username := c.MustGet("username").(string)
//appsvm := funk.Map(GetApps(username), func(a AppModel) AppViewModel { return AppViewModel{AppModel: &a} }).([]AppViewModel)
//for i := range appsvm {
// a := &appsvm[i]
// a.Status = statusString(a)
// a.ServiceDisplayName = a.ServiceName()
//}
//vm := &AppsViewModel{
// Username: username,
// Apps: appsvm,
//}
c.File("template/app_view.html") c.File("template/app_view.html")
// c.HTML(http.StatusOK, "app_view.html", vm)
} }
func AppMiddleware(c *gin.Context) { func AppMiddleware(c *gin.Context) {