mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
Some cleanups about host config (#2490)
This commit is contained in:
parent
baaf8b97e1
commit
ecdc729cdc
@ -96,5 +96,5 @@ func SetupGlobalLogger(c *cli.Context) {
|
||||
log.Logger = log.With().Caller().Logger()
|
||||
}
|
||||
|
||||
log.Log().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
|
||||
log.Info().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ func run(c *cli.Context) error {
|
||||
)
|
||||
}
|
||||
|
||||
if _, err := url.Parse(c.String("server-host")); err != nil {
|
||||
log.Fatal().Err(err).Msg("could not parse WOODPECKER_HOST")
|
||||
}
|
||||
|
||||
if strings.Contains(c.String("server-host"), "://localhost") {
|
||||
log.Warn().Msg(
|
||||
"WOODPECKER_HOST should probably be publicly accessible (not localhost)",
|
||||
@ -136,7 +140,6 @@ func run(c *cli.Context) error {
|
||||
server.Config.Services.Logs,
|
||||
server.Config.Services.Pubsub,
|
||||
_store,
|
||||
server.Config.Server.Host,
|
||||
)
|
||||
proto.RegisterWoodpeckerServer(grpcServer, woodpeckerServer)
|
||||
|
||||
@ -206,11 +209,9 @@ func run(c *cli.Context) error {
|
||||
|
||||
// http to https redirect
|
||||
redirect := func(w http.ResponseWriter, req *http.Request) {
|
||||
serverHost := server.Config.Server.Host
|
||||
serverHost = strings.TrimPrefix(serverHost, "http://")
|
||||
serverHost = strings.TrimPrefix(serverHost, "https://")
|
||||
serverURL, _ := url.Parse(server.Config.Server.Host)
|
||||
req.URL.Scheme = "https"
|
||||
req.URL.Host = serverHost
|
||||
req.URL.Host = serverURL.Host
|
||||
|
||||
w.Header().Set("Strict-Transport-Security", "max-age=31536000")
|
||||
|
||||
@ -327,16 +328,17 @@ func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) {
|
||||
server.Config.Server.Cert = c.String("server-cert")
|
||||
server.Config.Server.Key = c.String("server-key")
|
||||
server.Config.Server.AgentToken = c.String("agent-secret")
|
||||
server.Config.Server.Host = c.String("server-host")
|
||||
serverHost := c.String("server-host")
|
||||
server.Config.Server.Host = serverHost
|
||||
if c.IsSet("server-webhook-host") {
|
||||
server.Config.Server.WebhookHost = c.String("server-webhook-host")
|
||||
} else {
|
||||
server.Config.Server.WebhookHost = c.String("server-host")
|
||||
server.Config.Server.WebhookHost = serverHost
|
||||
}
|
||||
if c.IsSet("server-dev-oauth-host") {
|
||||
server.Config.Server.OAuthHost = c.String("server-dev-oauth-host")
|
||||
} else {
|
||||
server.Config.Server.OAuthHost = c.String("server-host")
|
||||
server.Config.Server.OAuthHost = serverHost
|
||||
}
|
||||
server.Config.Server.Port = c.String("server-addr")
|
||||
server.Config.Server.PortTLS = c.String("server-addr-tls")
|
||||
|
@ -46,7 +46,6 @@ type RPC struct {
|
||||
pubsub pubsub.Publisher
|
||||
logger logging.Log
|
||||
store store.Store
|
||||
host string
|
||||
pipelineTime *prometheus.GaugeVec
|
||||
pipelineCount *prometheus.CounterVec
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ type WoodpeckerServer struct {
|
||||
peer RPC
|
||||
}
|
||||
|
||||
func NewWoodpeckerServer(forge forge.Forge, queue queue.Queue, logger logging.Log, pubsub pubsub.Publisher, store store.Store, host string) proto.WoodpeckerServer {
|
||||
func NewWoodpeckerServer(forge forge.Forge, queue queue.Queue, logger logging.Log, pubsub pubsub.Publisher, store store.Store) proto.WoodpeckerServer {
|
||||
pipelineTime := promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: "woodpecker",
|
||||
Name: "pipeline_time",
|
||||
@ -54,7 +54,6 @@ func NewWoodpeckerServer(forge forge.Forge, queue queue.Queue, logger logging.Lo
|
||||
queue: queue,
|
||||
pubsub: pubsub,
|
||||
logger: logger,
|
||||
host: host,
|
||||
pipelineTime: pipelineTime,
|
||||
pipelineCount: pipelineCount,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user