From 0e22c766813b83d28f356d8ed4bc446e353134f8 Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:28:24 -0300
Subject: [PATCH 1/7] feat(conf): remove AuthenticationToken

---
 conf/options.go | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/conf/options.go b/conf/options.go
index 6b1ad41..ef8a813 100644
--- a/conf/options.go
+++ b/conf/options.go
@@ -8,12 +8,11 @@ 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
+	GitlabURL   string
+	PollerCron  string
+	PollerIDs   []int
+	ServerPort  uint
+	Services    Services.KnownServices
+	LogLevel    string
 }
-- 
GitLab


From e0fe2b83f53add781dde916df533f64af0e65a72 Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:29:50 -0300
Subject: [PATCH 2/7] feat(conf): rename GitlabURL to ProxyURL

---
 conf/options.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/conf/options.go b/conf/options.go
index ef8a813..00312f3 100644
--- a/conf/options.go
+++ b/conf/options.go
@@ -9,7 +9,7 @@ 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 {
 	GitlabToken string
-	GitlabURL   string
+	ProxyURL    string
 	PollerCron  string
 	PollerIDs   []int
 	ServerPort  uint
-- 
GitLab


From a3cce3508264749aec4af17d32902322c866eb4a Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:32:59 -0300
Subject: [PATCH 3/7] refactor(client): use the new configuration options

---
 client/client.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/client/client.go b/client/client.go
index 1172fc2..956444d 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
-- 
GitLab


From 994edda47e1a6db304772aa20d12b4630560d2ef Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:33:09 -0300
Subject: [PATCH 4/7] refactor(server): use the new configuration options

---
 server/server.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/server.go b/server/server.go
index 54e2b28..5767d5a 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
-- 
GitLab


From 9134d212091e0ed86f5f181e23b1f7bc82086595 Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:33:18 -0300
Subject: [PATCH 5/7] tests(server): use the new configuration options

---
 server/server_test.go | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/server/server_test.go b/server/server_test.go
index cda70ce..0b6319e 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,
-- 
GitLab


From 4cc25b289e9e7e36af555cf7e22916fa733364e2 Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:49:33 -0300
Subject: [PATCH 6/7] feat(conf): add ProxyToken

---
 conf/options.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/conf/options.go b/conf/options.go
index 00312f3..b5b91d3 100644
--- a/conf/options.go
+++ b/conf/options.go
@@ -10,6 +10,7 @@ import "gitlab.alpinelinux.org/Cogitri/aports-qa-bot/Services"
 type Options struct {
 	GitlabToken string
 	ProxyURL    string
+	ProxyToken  string
 	PollerCron  string
 	PollerIDs   []int
 	ServerPort  uint
-- 
GitLab


From e78d983fd4edd6af79df496e6d1350ac94d52e3f Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Thu, 27 May 2021 15:50:38 -0300
Subject: [PATCH 7/7] chore(conf): update coniguration

---
 conf.json | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/conf.json b/conf.json
index 1cc152a..b6c8424 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",
-- 
GitLab