From 5e931a3c13e751078baffe43efa58f8675b9ae3a Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 9 Jun 2020 08:44:55 +0200 Subject: [PATCH] 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 --- cmd/zitadel/caos_local.sh | 2 +- cmd/zitadel/startup.yaml | 2 +- k8s/base/deployment.yaml | 2 +- pkg/console/console.go | 13 +++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd/zitadel/caos_local.sh b/cmd/zitadel/caos_local.sh index e5e0754874..ca95a147dd 100755 --- a/cmd/zitadel/caos_local.sh +++ b/cmd/zitadel/caos_local.sh @@ -48,4 +48,4 @@ export CAOS_OIDC_DEV=true export ZITADEL_COOKIE_DOMAIN=localhost #Console -export ZITADEL_CONSOLE_ENV_PATH=../../console/src/ \ No newline at end of file +export ZITADEL_CONSOLE_ENV_DIR=../../console/src/assets/ \ No newline at end of file diff --git a/cmd/zitadel/startup.yaml b/cmd/zitadel/startup.yaml index 6f45d5726b..f589ab0362 100644 --- a/cmd/zitadel/startup.yaml +++ b/cmd/zitadel/startup.yaml @@ -191,7 +191,7 @@ Admin: Console: Port: 50050 - EnvOverwritePath: $ZITADEL_CONSOLE_ENV_PATH + EnvOverwriteDir: $ZITADEL_CONSOLE_ENV_DIR Notification: diff --git a/k8s/base/deployment.yaml b/k8s/base/deployment.yaml index 61cdf98c79..8b7e96021a 100644 --- a/k8s/base/deployment.yaml +++ b/k8s/base/deployment.yaml @@ -72,7 +72,7 @@ spec: - name: zitadel-secret mountPath: /secret - name: console-config - mountPath: /assets/environment.json + mountPath: /console/environment.json subPath: environment.json imagePullSecrets: - name: githubsecret diff --git a/pkg/console/console.go b/pkg/console/console.go index 7876878482..3b5eaac8e7 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -12,8 +12,8 @@ import ( ) type Config struct { - Port string - EnvOverwritePath string + Port string + EnvOverwriteDir string } type spaHandler struct { @@ -22,6 +22,7 @@ type spaHandler struct { const ( envRequestPath = "/assets/environment.json" + envDefaultDir = "/console/" ) func (i *spaHandler) Open(name string) (http.File, error) { @@ -38,11 +39,11 @@ func Start(ctx context.Context, config Config) error { if err != nil { return err } - envPath := envRequestPath - if config.EnvOverwritePath != "" { - envPath = config.EnvOverwritePath + envDir := envDefaultDir + if config.EnvOverwriteDir != "" { + envDir = config.EnvOverwriteDir } 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) }