From 0da6dc1d660be82a6933db6c2c27f62ab9edd697 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 9 Jun 2020 07:38:44 +0200 Subject: [PATCH] fix: serve console env from os (not statik) (#187) * fix: serve console env from os (not statik) * ZITADEL_CONSOLE_ENV_PATH for (local) overwrite possibility * name EnvOverwritePath --- cmd/zitadel/caos_local.sh | 5 ++++- cmd/zitadel/startup.yaml | 1 + k8s/base/deployment.yaml | 2 +- pkg/console/console.go | 12 +++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/zitadel/caos_local.sh b/cmd/zitadel/caos_local.sh index 7b4451192..e5e075487 100755 --- a/cmd/zitadel/caos_local.sh +++ b/cmd/zitadel/caos_local.sh @@ -45,4 +45,7 @@ export ZITADEL_AUTHORIZE=http://localhost:50022 export ZITADEL_OAUTH=http://localhost:50022 export ZITADEL_CONSOLE=http://localhost:4200 export CAOS_OIDC_DEV=true -export ZITADEL_COOKIE_DOMAIN=localhost \ No newline at end of file +export ZITADEL_COOKIE_DOMAIN=localhost + +#Console +export ZITADEL_CONSOLE_ENV_PATH=../../console/src/ \ No newline at end of file diff --git a/cmd/zitadel/startup.yaml b/cmd/zitadel/startup.yaml index 318628aca..6f45d5726 100644 --- a/cmd/zitadel/startup.yaml +++ b/cmd/zitadel/startup.yaml @@ -191,6 +191,7 @@ Admin: Console: Port: 50050 + EnvOverwritePath: $ZITADEL_CONSOLE_ENV_PATH Notification: diff --git a/k8s/base/deployment.yaml b/k8s/base/deployment.yaml index 5f2c373ef..61cdf98c7 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: /app/console/dist/assets/environment.json + mountPath: /assets/environment.json subPath: environment.json imagePullSecrets: - name: githubsecret diff --git a/pkg/console/console.go b/pkg/console/console.go index d68ededd7..787687848 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -12,13 +12,18 @@ import ( ) type Config struct { - Port string + Port string + EnvOverwritePath string } type spaHandler struct { fileSystem http.FileSystem } +const ( + envRequestPath = "/assets/environment.json" +) + func (i *spaHandler) Open(name string) (http.File, error) { ret, err := i.fileSystem.Open(name) if !os.IsNotExist(err) || path.Ext(name) != "" { @@ -33,6 +38,11 @@ func Start(ctx context.Context, config Config) error { if err != nil { return err } + envPath := envRequestPath + if config.EnvOverwritePath != "" { + envPath = config.EnvOverwritePath + } http.Handle("/", http.FileServer(&spaHandler{statikFS})) + http.Handle(envRequestPath, http.FileServer(http.Dir(envPath))) return http.ListenAndServe(":"+config.Port, nil) }