diff --git a/client/client.go b/client/client.go index 1172fc2031db21324fbb11bd1f9c5959a502cb7a..956444df3e1e7a3ae6506f730a35ffefdc852ad3 100644 --- a/client/client.go +++ b/client/client.go @@ -29,7 +29,10 @@ func NewClient(config *conf.Options) (*Client, error) { client.Config = config client.Cron = cron.New() - gitlabClient, err := gitlab.NewClient(config.AuthenticationToken, gitlab.WithBaseURL(config.GitlabURL)) + gitlabClient, err := gitlab.NewClient( + "", // We can have an empty token here since the token is stored in the proxy bot + gitlab.WithBaseURL(config.ProxyURL), + ) if err != nil { return nil, err diff --git a/conf.json b/conf.json index 1cc152a61e92d9512672df411e72bbd1274dc9e2..b6c842426c54c5bb1692c421e6d2ace51e8a240c 100644 --- a/conf.json +++ b/conf.json @@ -1,14 +1,13 @@ { - "AuthenticationToken": "", "GitlabToken": "", - "GitlabURL": "https://gitlab.alpinelinux.org", + "ProxyToken": "", + "ProxyURL": "http://localhost:8084", "PollerIDs": [ 1 ], "PollerCron": "@hourly", "ServerPort": 80, - "Services": - { + "Services": { "WebHook": { "MinimumRequiredSettings": "DryRun", "CancelMergeRequestPipelines": "DryRun", diff --git a/conf/options.go b/conf/options.go index 6b1ad41ce8c53fa4fd3e684831df199ac8a74356..b5b91d38e7159689ab301d9f0d5768c25ac7c35f 100644 --- a/conf/options.go +++ b/conf/options.go @@ -8,12 +8,12 @@ import "gitlab.alpinelinux.org/Cogitri/aports-qa-bot/Services" // Options holds all configuration options for the server and poller pat of aports-qa-bot type Options struct { - AuthenticationToken string - GitlabToken string - GitlabURL string - PollerCron string - PollerIDs []int - ServerPort uint - Services Services.KnownServices - LogLevel string + GitlabToken string + ProxyURL string + ProxyToken string + PollerCron string + PollerIDs []int + ServerPort uint + Services Services.KnownServices + LogLevel string } diff --git a/server/server.go b/server/server.go index 54e2b287019c73534881afbf736f04173a30ea80..5767d5a9c9aee5b80fdbdee4290d0589e0e4e54b 100644 --- a/server/server.go +++ b/server/server.go @@ -32,7 +32,10 @@ type WebhookEventListener struct { func NewWebhookEventListener(config *conf.Options) (*WebhookEventListener, error) { l := new(WebhookEventListener) l.config = config - client, err := gitlab.NewClient(config.AuthenticationToken, gitlab.WithBaseURL(config.GitlabURL)) + client, err := gitlab.NewClient( + "", // We can have an empty token here since the token is stored in the proxy bot + gitlab.WithBaseURL(config.ProxyURL), + ) if err != nil { return nil, err diff --git a/server/server_test.go b/server/server_test.go index cda70ceef15245d5e409ed8115c4f47151eec523..0b6319eb385f0714179c23a475c9fcd9385755a0 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -18,10 +18,9 @@ const mergeRequestJobJSON = "{\"object_kind\":\"merge_request\",\"user\":{\"name func TestCreateMergeRequestJob(t *testing.T) { config := conf.Options{ - AuthenticationToken: "test", - GitlabToken: "test", - GitlabURL: "https://127.0.0.1:8081", - ServerPort: 8082, + GitlabToken: "test", + ProxyURL: "https://127.0.0.1:8081", + ServerPort: 8082, Services: Services.KnownServices{ WebHook: Services.WebHookServices{ MinimumRequiredSettings: Services.DryRun, @@ -70,10 +69,9 @@ func TestCreateMergeRequestJob(t *testing.T) { func TestCreateMergeRequestJobBadGitlabToken(t *testing.T) { config := conf.Options{ - AuthenticationToken: "test", - GitlabToken: "test", - GitlabURL: "https://127.0.0.1:8081", - ServerPort: 8082, + GitlabToken: "test", + ProxyURL: "https://127.0.0.1:8081", + ServerPort: 8082, Services: Services.KnownServices{ WebHook: Services.WebHookServices{ MinimumRequiredSettings: Services.DryRun,