From 8f5727ad103797b507b0a6678b4088dd2c6e3c67 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Fri, 16 Dec 2022 01:01:15 +0100 Subject: [PATCH] fixes --- src/go.mod | 2 +- src/go.sum | 2 ++ src/internal/app/server/server.go | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/go.mod b/src/go.mod index 8dc398b..6d9e5b6 100644 --- a/src/go.mod +++ b/src/go.mod @@ -3,7 +3,7 @@ module git.pbiernat.dev/egommerce/catalog-service go 1.18 require ( - git.pbiernat.dev/egommerce/go-api-pkg v0.0.108 + git.pbiernat.dev/egommerce/go-api-pkg v0.0.113 github.com/gofiber/fiber/v2 v2.40.1 github.com/google/uuid v1.3.0 github.com/jackc/pgx/v4 v4.17.2 diff --git a/src/go.sum b/src/go.sum index b338c11..8180fa4 100644 --- a/src/go.sum +++ b/src/go.sum @@ -10,6 +10,8 @@ git.pbiernat.dev/egommerce/go-api-pkg v0.0.107 h1:yigpHD40ocyiamWc7GUVPgeaVtmz1V git.pbiernat.dev/egommerce/go-api-pkg v0.0.107/go.mod h1:nAwcw2MZtn/54YKq8VQK6RJAsiuoLUtPuazXg8JcqK8= git.pbiernat.dev/egommerce/go-api-pkg v0.0.108 h1:gr5kzKNR3sCxTz+nbqtOM7vdIely5ZWb8itSLAjTo0I= git.pbiernat.dev/egommerce/go-api-pkg v0.0.108/go.mod h1:nAwcw2MZtn/54YKq8VQK6RJAsiuoLUtPuazXg8JcqK8= +git.pbiernat.dev/egommerce/go-api-pkg v0.0.113 h1:kf7HesezhXIAMNYgLCm8x6YVqyLqJRqaPKIFEXf4xSs= +git.pbiernat.dev/egommerce/go-api-pkg v0.0.113/go.mod h1:nAwcw2MZtn/54YKq8VQK6RJAsiuoLUtPuazXg8JcqK8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= diff --git a/src/internal/app/server/server.go b/src/internal/app/server/server.go index 6c06312..b43cddd 100644 --- a/src/internal/app/server/server.go +++ b/src/internal/app/server/server.go @@ -3,6 +3,7 @@ package server import ( "bytes" "encoding/json" + "errors" "fmt" "os" "os/signal" @@ -117,14 +118,18 @@ func (s *Server) GetRequestID(c *fiber.Ctx) (string, error) { } func (s *Server) updateKVConfig() error { // FIXME: duplicated in cmd/worker/main.go - data, _, err := s.discovery.KV().Get(s.kvNmspc, nil) + config, _, err := s.discovery.KV().Get(s.kvNmspc, nil) if err != nil { fmt.Println(err) return err } - kvCnf := bytes.NewBuffer(data.Value) + if config == nil { + return errors.New("empty KV config data") + } + + kvCnf := bytes.NewBuffer(config.Value) decoder := json.NewDecoder(kvCnf) if err := decoder.Decode(&s.conf); err != nil { return err