fix: console env directory (#189)

* fix: serve console env from os (not statik)

* ZITADEL_CONSOLE_ENV_PATH for (local) overwrite possibility

* name EnvOverwritePath

* fix: console env directory

* fix mount path

* fix default dir
This commit is contained in:
Livio Amstutz
2020-06-09 08:44:55 +02:00
committed by GitHub
parent 0da6dc1d66
commit 5e931a3c13
4 changed files with 10 additions and 9 deletions

View File

@@ -48,4 +48,4 @@ export CAOS_OIDC_DEV=true
export ZITADEL_COOKIE_DOMAIN=localhost export ZITADEL_COOKIE_DOMAIN=localhost
#Console #Console
export ZITADEL_CONSOLE_ENV_PATH=../../console/src/ export ZITADEL_CONSOLE_ENV_DIR=../../console/src/assets/

View File

@@ -191,7 +191,7 @@ Admin:
Console: Console:
Port: 50050 Port: 50050
EnvOverwritePath: $ZITADEL_CONSOLE_ENV_PATH EnvOverwriteDir: $ZITADEL_CONSOLE_ENV_DIR
Notification: Notification:

View File

@@ -72,7 +72,7 @@ spec:
- name: zitadel-secret - name: zitadel-secret
mountPath: /secret mountPath: /secret
- name: console-config - name: console-config
mountPath: /assets/environment.json mountPath: /console/environment.json
subPath: environment.json subPath: environment.json
imagePullSecrets: imagePullSecrets:
- name: githubsecret - name: githubsecret

View File

@@ -12,8 +12,8 @@ import (
) )
type Config struct { type Config struct {
Port string Port string
EnvOverwritePath string EnvOverwriteDir string
} }
type spaHandler struct { type spaHandler struct {
@@ -22,6 +22,7 @@ type spaHandler struct {
const ( const (
envRequestPath = "/assets/environment.json" envRequestPath = "/assets/environment.json"
envDefaultDir = "/console/"
) )
func (i *spaHandler) Open(name string) (http.File, error) { func (i *spaHandler) Open(name string) (http.File, error) {
@@ -38,11 +39,11 @@ func Start(ctx context.Context, config Config) error {
if err != nil { if err != nil {
return err return err
} }
envPath := envRequestPath envDir := envDefaultDir
if config.EnvOverwritePath != "" { if config.EnvOverwriteDir != "" {
envPath = config.EnvOverwritePath envDir = config.EnvOverwriteDir
} }
http.Handle("/", http.FileServer(&spaHandler{statikFS})) http.Handle("/", http.FileServer(&spaHandler{statikFS}))
http.Handle(envRequestPath, http.FileServer(http.Dir(envPath))) http.Handle(envRequestPath, http.StripPrefix("/assets", http.FileServer(http.Dir(envDir))))
return http.ListenAndServe(":"+config.Port, nil) return http.ListenAndServe(":"+config.Port, nil)
} }