Added Woodpecker Host Config used for Webhooks (#1869)

When SCM and Woodpecker are deployed in the same cluster, I want that
SCM requests Woodpecker directly by internal URL.


![Webhook-host-diagram](https://github.com/woodpecker-ci/woodpecker/assets/127358482/c4689d55-839a-4731-95b3-5734ba561e5f)
 
This PR adds optional URL used for Webhook calls.
This commit is contained in:
Thomas Anderson 2023-06-18 15:47:40 +03:00 committed by GitHub
parent 6ab9f802d1
commit 0c3021473f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 1 deletions

View file

@ -45,6 +45,11 @@ var flags = []cli.Flag{
Name: "server-host",
Usage: "server fully qualified url (<scheme>://<host>)",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_WEBHOOK_HOST"},
Name: "server-webhook-host",
Usage: "server fully qualified url for forge's Webhooks (<scheme>://<host>)",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_ROOT_URL"},
Name: "root-url",

View file

@ -341,6 +341,11 @@ func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) {
server.Config.Server.Key = c.String("server-key")
server.Config.Server.AgentToken = c.String("agent-secret")
server.Config.Server.Host = c.String("server-host")
if c.IsSet("server-webhook-host") {
server.Config.Server.WebhookHost = c.String("server-webhook-host")
} else {
server.Config.Server.WebhookHost = c.String("server-host")
}
if c.IsSet("server-dev-oauth-host") {
server.Config.Server.OAuthHost = c.String("server-dev-oauth-host")
} else {

View file

@ -131,6 +131,13 @@ Server fully qualified URL of the user-facing hostname.
Example: `WOODPECKER_HOST=http://woodpecker.example.org`
### `WOODPECKER_WEBHOOK_HOST`
> Default: value from `WOODPECKER_HOST` config env
Server fully qualified URL of the Webhook-facing hostname.
Example: `WOODPECKER_WEBHOOK_HOST=http://woodpecker-server.cicd.svc.cluster.local:8000`
### `WOODPECKER_SERVER_ADDR`
> Default: `:8000`

View file

@ -110,7 +110,7 @@ func PostRepo(c *gin.Context) {
link := fmt.Sprintf(
"%s/hook?access_token=%s",
server.Config.Server.Host,
server.Config.Server.WebhookHost,
sig,
)

View file

@ -59,6 +59,7 @@ var Config = struct {
Cert string
OAuthHost string
Host string
WebhookHost string
Port string
PortTLS string
AgentToken string