From fe5bc2fa3184d850fa80371efdeebe22b2b733f9 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Fri, 5 Apr 2019 16:23:54 +0200 Subject: [PATCH] gw repos: use config provided gitServerURL --- examples/config.yml | 2 ++ internal/services/config/config.go | 1 + internal/services/gateway/api/repos.go | 11 +++++------ internal/services/gateway/gateway.go | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/config.yml b/examples/config.yml index a9ae6cc..0926eaa 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -3,6 +3,8 @@ gateway: webExposedURL: "http://172.17.0.1:8080" runServiceURL: "http://localhost:4000" configStoreURL: "http://localhost:4002" + gitServerURL: "http://172.17.0.1:4003" + web: listenAddress: ":8000" tokenSigning: diff --git a/internal/services/config/config.go b/internal/services/config/config.go index ff15f2b..6b6ef82 100644 --- a/internal/services/config/config.go +++ b/internal/services/config/config.go @@ -43,6 +43,7 @@ type Gateway struct { RunServiceURL string `yaml:"runServiceURL"` ConfigStoreURL string `yaml:"configStoreURL"` + GitServerURL string `yaml:"gitServerURL"` Web Web `yaml:"web"` Etcd Etcd `yaml:"etcd"` diff --git a/internal/services/gateway/api/repos.go b/internal/services/gateway/api/repos.go index 4e9daa3..ff1f168 100644 --- a/internal/services/gateway/api/repos.go +++ b/internal/services/gateway/api/repos.go @@ -19,19 +19,18 @@ import ( "net/http" "net/url" - csapi "github.com/sorintlab/agola/internal/services/configstore/api" "go.uber.org/zap" "github.com/gorilla/mux" ) type ReposHandler struct { - log *zap.SugaredLogger - configstoreClient *csapi.Client + log *zap.SugaredLogger + gitServerURL string } -func NewReposHandler(logger *zap.Logger, configstoreClient *csapi.Client) *ReposHandler { - return &ReposHandler{log: logger.Sugar(), configstoreClient: configstoreClient} +func NewReposHandler(logger *zap.Logger, gitServerURL string) *ReposHandler { + return &ReposHandler{log: logger.Sugar(), gitServerURL: gitServerURL} } func (h *ReposHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -41,7 +40,7 @@ func (h *ReposHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.log.Infof("path: %s", path) - u, err := url.Parse("http://172.17.0.1:4003") + u, err := url.Parse(h.gitServerURL) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/internal/services/gateway/gateway.go b/internal/services/gateway/gateway.go index 65280d0..53479ff 100644 --- a/internal/services/gateway/gateway.go +++ b/internal/services/gateway/gateway.go @@ -194,7 +194,7 @@ func (g *Gateway) Run(ctx context.Context) error { logsHandler := api.NewLogsHandler(logger, g.runserviceClient) - reposHandler := api.NewReposHandler(logger, g.configstoreClient) + reposHandler := api.NewReposHandler(logger, g.c.GitServerURL) loginUserHandler := api.NewLoginUserHandler(logger, g.ch) authorizeHandler := api.NewAuthorizeHandler(logger, g.ch)