Skip to content

Commit

Permalink
Fix webhook calls for instances pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
databus23 committed Oct 9, 2024
1 parent 226d9f6 commit e1e02c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
12 changes: 10 additions & 2 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
"net/url"
"path/filepath"
"strings"

Expand Down Expand Up @@ -96,12 +97,19 @@ func (gh *GithubWebhookHandler) ServeHTTP(rw http.ResponseWriter, req *http.Requ
} else {
debugf("resource %s/%s has no path filter: %#v", pipeline.Name, resource.Name, resource.Source)
}
webhookURL := fmt.Sprintf("%s/api/v1/teams/%s/pipelines/%s/resources/%s/check/webhook?webhook_token=%s",
queryParams := url.Values{}
for key, vals := range pipeline.QueryParams {
for _, val := range vals {
queryParams.Add(key, val)
}
}
queryParams.Set("webhook_token", resource.WebhookToken)
webhookURL := fmt.Sprintf("%s/api/v1/teams/%s/pipelines/%s/resources/%s/check/webhook?%s",
concourseURL,
pipeline.Team,
pipeline.Name,
resource.Name,
resource.WebhookToken,
queryParams.Encode(),
)
gh.queue.Add(webhookURL)
}
Expand Down
21 changes: 12 additions & 9 deletions resource_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package main
import (
"fmt"
"log"
"net/url"
"sync"

"github.com/concourse/concourse/atc"
)

type Pipeline struct {
ID int
Name string
Version string
Team string
Resources []atc.ResourceConfig
ID int
Name string
Version string
Team string
Resources []atc.ResourceConfig
QueryParams url.Values
}

var (
Expand Down Expand Up @@ -60,10 +62,11 @@ func UpdateCache(cclient client) error {
//add or replace cache for pipeline
if !inCache || cachedPipeline.(Pipeline).Version != version {
newCacheObj := Pipeline{
ID: pipeline.ID,
Name: pipeline.Name,
Team: pipeline.TeamName,
Version: version,
ID: pipeline.ID,
Name: pipeline.Name,
Team: pipeline.TeamName,
Version: version,
QueryParams: pipeline.Ref().QueryParams(),
}
for _, resource := range config.Resources {
//Skip resources without webhook tokens
Expand Down

0 comments on commit e1e02c3

Please sign in to comment.