mirror of https://github.com/k3s-io/k3s.git
Serve static assets
Provide a static assets route for use with helm or other air-gap needs.pull/241/head
parent
697c6e1580
commit
608f3a4e80
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
const (
|
||||
namespace = "kube-system"
|
||||
image = "rancher/klipper-helm:v0.1.3"
|
||||
image = "rancher/klipper-helm:v0.1.4"
|
||||
label = "helm.k3s.cattle.io/chart"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -15,6 +16,7 @@ const (
|
|||
binaryMediaType = "application/octet-stream"
|
||||
pbMediaType = "application/com.github.proto-openapi.spec.v2@v1.0+protobuf"
|
||||
openapiPrefix = "openapi."
|
||||
staticURL = "/static/"
|
||||
)
|
||||
|
||||
type CACertsGetter func() (string, error)
|
||||
|
@ -28,8 +30,10 @@ func router(serverConfig *config.Control, tunnel http.Handler, cacertsGetter CAC
|
|||
authed.Path("/v1-k3s/node.key").Handler(nodeKey(serverConfig))
|
||||
authed.Path("/v1-k3s/config").Handler(configHandler(serverConfig))
|
||||
|
||||
staticDir := filepath.Join(serverConfig.DataDir, "static")
|
||||
router := mux.NewRouter()
|
||||
router.NotFoundHandler = authed
|
||||
router.PathPrefix(staticURL).Handler(serveStatic(staticURL, staticDir))
|
||||
router.Path("/cacerts").Handler(cacerts(cacertsGetter))
|
||||
router.Path("/openapi/v2").Handler(serveOpenapi())
|
||||
router.Path("/ping").Handler(ping())
|
||||
|
@ -110,3 +114,7 @@ func ping() http.Handler {
|
|||
resp.Write(data)
|
||||
})
|
||||
}
|
||||
|
||||
func serveStatic(urlPrefix, staticDir string) http.Handler {
|
||||
return http.StripPrefix(urlPrefix, http.FileServer(http.Dir(staticDir)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue