gw repos: use config provided gitServerURL

This commit is contained in:
Simone Gotti 2019-04-05 16:23:54 +02:00
parent ac28731d11
commit fe5bc2fa31
4 changed files with 9 additions and 7 deletions

View File

@ -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:

View File

@ -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"`

View File

@ -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

View File

@ -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)