diff --git a/pkg/helm/controller.go b/pkg/helm/controller.go index e396d8be97..b8e29ba01d 100644 --- a/pkg/helm/controller.go +++ b/pkg/helm/controller.go @@ -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" ) diff --git a/pkg/server/router.go b/pkg/server/router.go index 83e54d654d..0626cae997 100644 --- a/pkg/server/router.go +++ b/pkg/server/router.go @@ -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))) +}