Skip to content

fix: fatal log removed #5043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions api/router/GrafanaRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type GrafanaRouterImpl struct {
grafanaProxy func(writer http.ResponseWriter, request *http.Request)
}

func NewGrafanaRouterImpl(logger *zap.SugaredLogger, grafanaCfg *grafana.Config) *GrafanaRouterImpl {
func NewGrafanaRouterImpl(logger *zap.SugaredLogger, grafanaCfg *grafana.Config) (*GrafanaRouterImpl, error) {
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Expand All @@ -31,12 +31,15 @@ func NewGrafanaRouterImpl(logger *zap.SugaredLogger, grafanaCfg *grafana.Config)
ExpectContinueTimeout: 1 * time.Second,
},
}
grafanaProxy := grafana.NewGrafanaHTTPReverseProxy(fmt.Sprintf("http://%s:%s", grafanaCfg.Host, grafanaCfg.Port), client.Transport)
grafanaProxy, err := grafana.NewGrafanaHTTPReverseProxy(fmt.Sprintf("http://%s:%s", grafanaCfg.Host, grafanaCfg.Port), client.Transport)
if err != nil {
return nil, err
}
router := &GrafanaRouterImpl{
grafanaProxy: grafanaProxy,
logger: logger,
}
return router
return router, nil
}

func (router GrafanaRouterImpl) initGrafanaRouter(grafanaRouter *mux.Router) {
Expand Down
1 change: 0 additions & 1 deletion client/argocdServer/connection/Tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func GetTLS(cert *tls.Certificate) credentials.TransportCredentials {
//These certificates are to be read from secret create by argocd
//cert, err := tls.X509KeyPair([]byte(TLSCert), []byte(TLSKey))
//if err != nil {
// log.Fatal(err)
//}
certPool := x509.NewCertPool()
pemCertBytes, _ := EncodeX509KeyPair(*cert)
Expand Down
195 changes: 0 additions & 195 deletions client/argocdServer/connection/proxy.go

This file was deleted.

63 changes: 0 additions & 63 deletions client/argocdServer/connection/proxy_test.go

This file was deleted.

9 changes: 6 additions & 3 deletions client/dashboard/DashboardRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DashboardRouterImpl struct {
dashboardProxy func(writer http.ResponseWriter, request *http.Request)
}

func NewDashboardRouterImpl(logger *zap.SugaredLogger, dashboardCfg *Config) *DashboardRouterImpl {
func NewDashboardRouterImpl(logger *zap.SugaredLogger, dashboardCfg *Config) (*DashboardRouterImpl, error) {
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Expand All @@ -32,12 +32,15 @@ func NewDashboardRouterImpl(logger *zap.SugaredLogger, dashboardCfg *Config) *Da
ExpectContinueTimeout: 1 * time.Second,
},
}
dashboardProxy := proxy.NewDashboardHTTPReverseProxy(fmt.Sprintf("http://%s:%s", dashboardCfg.Host, dashboardCfg.Port), client.Transport)
dashboardProxy, err := proxy.NewDashboardHTTPReverseProxy(fmt.Sprintf("http://%s:%s", dashboardCfg.Host, dashboardCfg.Port), client.Transport)
if err != nil {
return nil, err
}
router := &DashboardRouterImpl{
dashboardProxy: dashboardProxy,
logger: logger,
}
return router
return router, nil
}

func (router DashboardRouterImpl) InitDashboardRouter(dashboardRouter *mux.Router) {
Expand Down
9 changes: 6 additions & 3 deletions client/grafana/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import (
"net/url"
)

func NewGrafanaHTTPReverseProxy(serverAddr string, transport http.RoundTripper) func(writer http.ResponseWriter, request *http.Request) {
func NewGrafanaHTTPReverseProxy(serverAddr string, transport http.RoundTripper) (func(writer http.ResponseWriter, request *http.Request), error) {
target, err := url.Parse(serverAddr)
if err != nil {
log.Fatal(err)
log.Println(err)
return func(writer http.ResponseWriter, request *http.Request) {
http.Error(writer, "error while parsing target url", http.StatusInternalServerError)
}, err
}
proxy := httputil.NewSingleHostReverseProxy(target)
proxy.Transport = transport

return func(w http.ResponseWriter, r *http.Request) {
proxy.ServeHTTP(w, r)
}
}, nil
}
Loading
Loading