From 21837f9b25feb54302333e5fc7688ba823c611cc Mon Sep 17 00:00:00 2001 From: justusbunsi Date: Sun, 17 Oct 2021 16:01:15 +0200 Subject: [PATCH] Export webhook and token struct Signed-off-by: Steven Kriegler --- internal/settings/gitea.go | 4 ++-- internal/settings/settings_test.go | 28 ++++++++++++++-------------- internal/settings/sonarqube.go | 4 ++-- internal/settings/token.go | 8 ++++---- internal/settings/webhook.go | 8 ++++---- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/settings/gitea.go b/internal/settings/gitea.go index 375efcc..b095e42 100644 --- a/internal/settings/gitea.go +++ b/internal/settings/gitea.go @@ -7,6 +7,6 @@ type GiteaRepository struct { type giteaConfig struct { Url string - Token *token - Webhook *webhook + Token *Token + Webhook *Webhook } diff --git a/internal/settings/settings_test.go b/internal/settings/settings_test.go index 8c5522a..3df25d6 100644 --- a/internal/settings/settings_test.go +++ b/internal/settings/settings_test.go @@ -58,10 +58,10 @@ func TestLoadGiteaStructure(t *testing.T) { expected := giteaConfig{ Url: "https://example.com/gitea", - Token: &token{ + Token: &Token{ Value: "d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565", }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "haxxor-gitea-secret", }, } @@ -77,10 +77,10 @@ func TestLoadGiteaStructureInjectedEnvs(t *testing.T) { expected := giteaConfig{ Url: "https://example.com/gitea", - Token: &token{ + Token: &Token{ Value: "injected-token", }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "injected-webhook-secret", }, } @@ -99,10 +99,10 @@ func TestLoadSonarQubeStructure(t *testing.T) { expected := sonarQubeConfig{ Url: "https://example.com/sonarqube", - Token: &token{ + Token: &Token{ Value: "a09eb5785b25bb2cbacf48808a677a0709f02d8e", }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "haxxor-sonarqube-secret", }, } @@ -133,10 +133,10 @@ projects: expected := sonarQubeConfig{ Url: "https://example.com/sonarqube", - Token: &token{ + Token: &Token{ Value: "fake-sonarqube-token", }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "", }, AdditionalMetrics: []string{ @@ -157,10 +157,10 @@ func TestLoadSonarQubeStructureInjectedEnvs(t *testing.T) { expected := sonarQubeConfig{ Url: "https://example.com/sonarqube", - Token: &token{ + Token: &Token{ Value: "injected-token", }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "injected-webhook-secret", }, } @@ -209,11 +209,11 @@ projects: expectedGitea := giteaConfig{ Url: "https://example.com/gitea", - Token: &token{ + Token: &Token{ Value: "d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565", file: giteaTokenFile, }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "gitea-totally-secret", secretFile: giteaWebhookSecretFile, }, @@ -221,11 +221,11 @@ projects: expectedSonarQube := sonarQubeConfig{ Url: "https://example.com/sonarqube", - Token: &token{ + Token: &Token{ Value: "a09eb5785b25bb2cbacf48808a677a0709f02d8e", file: sonarqubeTokenFile, }, - Webhook: &webhook{ + Webhook: &Webhook{ Secret: "sonarqube-totally-secret", secretFile: sonarqubeWebhookSecretFile, }, diff --git a/internal/settings/sonarqube.go b/internal/settings/sonarqube.go index 1c7fde2..645f9d2 100644 --- a/internal/settings/sonarqube.go +++ b/internal/settings/sonarqube.go @@ -4,8 +4,8 @@ import "strings" type sonarQubeConfig struct { Url string - Token *token - Webhook *webhook + Token *Token + Webhook *Webhook AdditionalMetrics []string } diff --git a/internal/settings/token.go b/internal/settings/token.go index 6905656..0c47dfd 100644 --- a/internal/settings/token.go +++ b/internal/settings/token.go @@ -5,12 +5,12 @@ import ( "io/ioutil" ) -type token struct { +type Token struct { Value string file string } -func (t *token) lookupSecret(errCallback func(string)) { +func (t *Token) lookupSecret(errCallback func(string)) { if t.file == "" { return } @@ -24,8 +24,8 @@ func (t *token) lookupSecret(errCallback func(string)) { t.Value = string(content) } -func NewToken(extractor func(string) string, confContainer string, errCallback func(string)) *token { - t := &token{ +func NewToken(extractor func(string) string, confContainer string, errCallback func(string)) *Token { + t := &Token{ Value: extractor(fmt.Sprintf("%s.token.value", confContainer)), file: extractor(fmt.Sprintf("%s.token.file", confContainer)), } diff --git a/internal/settings/webhook.go b/internal/settings/webhook.go index 0b8374d..53f50e8 100644 --- a/internal/settings/webhook.go +++ b/internal/settings/webhook.go @@ -5,12 +5,12 @@ import ( "io/ioutil" ) -type webhook struct { +type Webhook struct { Secret string secretFile string } -func (w *webhook) lookupSecret(errCallback func(string)) { +func (w *Webhook) lookupSecret(errCallback func(string)) { if w.secretFile == "" { return } @@ -24,8 +24,8 @@ func (w *webhook) lookupSecret(errCallback func(string)) { w.Secret = string(content) } -func NewWebhook(extractor func(string) string, confContainer string, errCallback func(string)) *webhook { - w := &webhook{ +func NewWebhook(extractor func(string) string, confContainer string, errCallback func(string)) *Webhook { + w := &Webhook{ Secret: extractor(fmt.Sprintf("%s.webhook.secret", confContainer)), secretFile: extractor(fmt.Sprintf("%s.webhook.secretFile", confContainer)), }