Export webhook and token struct
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
This commit is contained in:
parent
e01096a7fe
commit
21837f9b25
|
@ -7,6 +7,6 @@ type GiteaRepository struct {
|
|||
|
||||
type giteaConfig struct {
|
||||
Url string
|
||||
Token *token
|
||||
Webhook *webhook
|
||||
Token *Token
|
||||
Webhook *Webhook
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -4,8 +4,8 @@ import "strings"
|
|||
|
||||
type sonarQubeConfig struct {
|
||||
Url string
|
||||
Token *token
|
||||
Webhook *webhook
|
||||
Token *Token
|
||||
Webhook *Webhook
|
||||
AdditionalMetrics []string
|
||||
}
|
||||
|
||||
|
|
|
@ -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)),
|
||||
}
|
||||
|
|
|
@ -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)),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue