From 36a64f4fe397badf854c0899bed7f92202f8d3eb Mon Sep 17 00:00:00 2001 From: kandrusyak Date: Fri, 30 Jun 2023 19:08:44 +0300 Subject: [PATCH] add share path --- config/config.go | 6 ++++-- deploy/templates/deployment.yaml | 2 ++ main.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 3e94962..804b3b7 100644 --- a/config/config.go +++ b/config/config.go @@ -5,7 +5,8 @@ import ( ) type ServerConfig struct { - Port string + Port string + SharePath string } type Config struct { @@ -15,7 +16,8 @@ type Config struct { func New() *Config { return &Config{ Server: ServerConfig{ - Port: getEnv("PORT", ""), + Port: getEnv("PORT", ""), + SharePath: getEnv("SHARE_PATH", "public"), }, } } diff --git a/deploy/templates/deployment.yaml b/deploy/templates/deployment.yaml index 9b2cd68..58a3263 100644 --- a/deploy/templates/deployment.yaml +++ b/deploy/templates/deployment.yaml @@ -27,6 +27,8 @@ spec: value: Europe/Moscow - name: PORT value: {{ .Values.app.server.port | quote }} + - name: SHARE_PATH + value: /app/public image: {{ .Values.app.image }}:{{ .Chart.AppVersion }} #"docker-registry.dopcore.com/andrusyakka/urban-couscous:latest" imagePullPolicy: Always diff --git a/main.go b/main.go index a4e7b07..a81493f 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ func upload(c echo.Context) error { uuid := uuid2.New().String() fileName := uuid + "-" + file.Filename - dst, err := os.Create("public/" + fileName) + dst, err := os.Create(config.Env.Server.SharePath + "/" + fileName) if err != nil { return err } @@ -51,7 +51,7 @@ func main() { e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Static("/", "public") + e.Static("/", config.Env.Server.SharePath) e.POST("/upload", upload) e.Logger.Fatal(e.Start(":" + config.Env.Server.Port))