mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-09 09:05:26 +00:00
Some cleanups about host config (#2490)
This commit is contained in:
parent
baaf8b97e1
commit
ecdc729cdc
4 changed files with 12 additions and 12 deletions
|
@ -96,5 +96,5 @@ func SetupGlobalLogger(c *cli.Context) {
|
||||||
log.Logger = log.With().Caller().Logger()
|
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") {
|
if strings.Contains(c.String("server-host"), "://localhost") {
|
||||||
log.Warn().Msg(
|
log.Warn().Msg(
|
||||||
"WOODPECKER_HOST should probably be publicly accessible (not localhost)",
|
"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.Logs,
|
||||||
server.Config.Services.Pubsub,
|
server.Config.Services.Pubsub,
|
||||||
_store,
|
_store,
|
||||||
server.Config.Server.Host,
|
|
||||||
)
|
)
|
||||||
proto.RegisterWoodpeckerServer(grpcServer, woodpeckerServer)
|
proto.RegisterWoodpeckerServer(grpcServer, woodpeckerServer)
|
||||||
|
|
||||||
|
@ -206,11 +209,9 @@ func run(c *cli.Context) error {
|
||||||
|
|
||||||
// http to https redirect
|
// http to https redirect
|
||||||
redirect := func(w http.ResponseWriter, req *http.Request) {
|
redirect := func(w http.ResponseWriter, req *http.Request) {
|
||||||
serverHost := server.Config.Server.Host
|
serverURL, _ := url.Parse(server.Config.Server.Host)
|
||||||
serverHost = strings.TrimPrefix(serverHost, "http://")
|
|
||||||
serverHost = strings.TrimPrefix(serverHost, "https://")
|
|
||||||
req.URL.Scheme = "https"
|
req.URL.Scheme = "https"
|
||||||
req.URL.Host = serverHost
|
req.URL.Host = serverURL.Host
|
||||||
|
|
||||||
w.Header().Set("Strict-Transport-Security", "max-age=31536000")
|
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.Cert = c.String("server-cert")
|
||||||
server.Config.Server.Key = c.String("server-key")
|
server.Config.Server.Key = c.String("server-key")
|
||||||
server.Config.Server.AgentToken = c.String("agent-secret")
|
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") {
|
if c.IsSet("server-webhook-host") {
|
||||||
server.Config.Server.WebhookHost = c.String("server-webhook-host")
|
server.Config.Server.WebhookHost = c.String("server-webhook-host")
|
||||||
} else {
|
} else {
|
||||||
server.Config.Server.WebhookHost = c.String("server-host")
|
server.Config.Server.WebhookHost = serverHost
|
||||||
}
|
}
|
||||||
if c.IsSet("server-dev-oauth-host") {
|
if c.IsSet("server-dev-oauth-host") {
|
||||||
server.Config.Server.OAuthHost = c.String("server-dev-oauth-host")
|
server.Config.Server.OAuthHost = c.String("server-dev-oauth-host")
|
||||||
} else {
|
} 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.Port = c.String("server-addr")
|
||||||
server.Config.Server.PortTLS = c.String("server-addr-tls")
|
server.Config.Server.PortTLS = c.String("server-addr-tls")
|
||||||
|
|
|
@ -46,7 +46,6 @@ type RPC struct {
|
||||||
pubsub pubsub.Publisher
|
pubsub pubsub.Publisher
|
||||||
logger logging.Log
|
logger logging.Log
|
||||||
store store.Store
|
store store.Store
|
||||||
host string
|
|
||||||
pipelineTime *prometheus.GaugeVec
|
pipelineTime *prometheus.GaugeVec
|
||||||
pipelineCount *prometheus.CounterVec
|
pipelineCount *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ type WoodpeckerServer struct {
|
||||||
peer RPC
|
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{
|
pipelineTime := promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: "woodpecker",
|
Namespace: "woodpecker",
|
||||||
Name: "pipeline_time",
|
Name: "pipeline_time",
|
||||||
|
@ -54,7 +54,6 @@ func NewWoodpeckerServer(forge forge.Forge, queue queue.Queue, logger logging.Lo
|
||||||
queue: queue,
|
queue: queue,
|
||||||
pubsub: pubsub,
|
pubsub: pubsub,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
host: host,
|
|
||||||
pipelineTime: pipelineTime,
|
pipelineTime: pipelineTime,
|
||||||
pipelineCount: pipelineCount,
|
pipelineCount: pipelineCount,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue