Skip to content

Commit

Permalink
feat hepa api proxy host pass-through set default as true
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey committed Apr 17, 2024
1 parent 7b69390 commit 3e1e321
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/erda-project/erda/internal/tools/orchestrator/hepa/apipolicy"
annotationscommon "github.com/erda-project/erda/internal/tools/orchestrator/hepa/common"
"github.com/erda-project/erda/internal/tools/orchestrator/hepa/config"
gatewayproviders "github.com/erda-project/erda/internal/tools/orchestrator/hepa/gateway-providers"
providerDto "github.com/erda-project/erda/internal/tools/orchestrator/hepa/gateway-providers/dto"
mseCommon "github.com/erda-project/erda/internal/tools/orchestrator/hepa/gateway-providers/mse/common"
Expand All @@ -42,7 +43,7 @@ func (policy Policy) CreateDefaultConfig(gatewayProvider string, ctx map[string]
ClientRespTimeout: 60,
ProxyReqTimeout: 60,
ProxyRespTimeout: 60,
HostPassthrough: false,
HostPassthrough: config.APIProxyPolicyHostPassThrough(),
SSLRedirect: true,
}
dto.Switch = false
Expand Down
16 changes: 16 additions & 0 deletions internal/tools/orchestrator/hepa/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@

package config

import "github.com/erda-project/erda/pkg/envconf"

type Conf struct {
APIProxyPolicyHostPassThrough bool `file:"api_proxy_policy_host_pass_through" default:"true"`
}

var cfg Conf

func Load() {
envconf.MustLoad(&cfg)
}

func APIProxyPolicyHostPassThrough() bool {
return cfg.APIProxyPolicyHostPassThrough
}

var ServerConf *ServerConfig
var LogConf *LogConfig

Expand Down
2 changes: 2 additions & 0 deletions internal/tools/orchestrator/hepa/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ type provider struct {
}

func (p *provider) Init(ctx servicehub.Context) error {
config.Load()
config.ServerConf = &p.Cfg.Server
config.LogConf = &p.Cfg.Log
common.InitLogger()
orm.Init()
logrus.Info(version.String())
logrus.Infof("server conf: %+v", config.ServerConf)
logrus.Infof("log conf: %+v", config.LogConf)
logrus.Infof("default api proxy policy host pass through: %v", config.APIProxyPolicyHostPassThrough())
orgCache.CacheInit(p.Org)
p.HttpServer.GET("/api/gateway/openapi/metrics/*", func(resp http.ResponseWriter, req *http.Request) {
path := strings.Replace(req.URL.Path, "/api/gateway/openapi/metrics/charts", "/api/metrics", 1)
Expand Down

0 comments on commit 3e1e321

Please sign in to comment.