Format code
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
This commit is contained in:
parent
16f545f179
commit
a1990a60f4
|
@ -3,6 +3,7 @@ package gitea_sdk
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitea-sonarqube-pr-bot/internal/settings"
|
"gitea-sonarqube-pr-bot/internal/settings"
|
||||||
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package sonarqube_sdk
|
package sonarqube_sdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"gitea-sonarqube-pr-bot/internal/settings"
|
"gitea-sonarqube-pr-bot/internal/settings"
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,7 +83,7 @@ func Load(configPath string) {
|
||||||
|
|
||||||
Projects = projects
|
Projects = projects
|
||||||
|
|
||||||
errCallback := func(msg string) {panic(msg)}
|
errCallback := func(msg string) { panic(msg) }
|
||||||
|
|
||||||
Gitea = giteaConfig{
|
Gitea = giteaConfig{
|
||||||
Url: r.GetString("gitea.url"),
|
Url: r.GetString("gitea.url"),
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultConfig []byte = []byte(
|
var defaultConfig []byte = []byte(
|
||||||
`gitea:
|
`gitea:
|
||||||
url: https://example.com/gitea
|
url: https://example.com/gitea
|
||||||
token:
|
token:
|
||||||
value: d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565
|
value: d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565
|
||||||
|
@ -38,7 +38,7 @@ func WriteConfigFile(t *testing.T, content []byte) {
|
||||||
os.Remove(config)
|
os.Remove(config)
|
||||||
})
|
})
|
||||||
|
|
||||||
_ = ioutil.WriteFile(config, content,0444)
|
_ = ioutil.WriteFile(config, content, 0444)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadWithMissingFile(t *testing.T) {
|
func TestLoadWithMissingFile(t *testing.T) {
|
||||||
|
@ -135,19 +135,19 @@ func TestLoadSonarQubeStructureInjectedEnvs(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadStructureWithFileReferenceResolving(t *testing.T) {
|
func TestLoadStructureWithFileReferenceResolving(t *testing.T) {
|
||||||
giteaWebhookSecretFile := path.Join(os.TempDir(), "webhook-secret-gitea")
|
giteaWebhookSecretFile := path.Join(os.TempDir(), "webhook-secret-gitea")
|
||||||
_ = ioutil.WriteFile(giteaWebhookSecretFile, []byte(`gitea-totally-secret`),0444)
|
_ = ioutil.WriteFile(giteaWebhookSecretFile, []byte(`gitea-totally-secret`), 0444)
|
||||||
|
|
||||||
giteaTokenFile := path.Join(os.TempDir(), "token-secret-gitea")
|
giteaTokenFile := path.Join(os.TempDir(), "token-secret-gitea")
|
||||||
_ = ioutil.WriteFile(giteaTokenFile, []byte(`d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565`),0444)
|
_ = ioutil.WriteFile(giteaTokenFile, []byte(`d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565`), 0444)
|
||||||
|
|
||||||
sonarqubeWebhookSecretFile := path.Join(os.TempDir(), "webhook-secret-sonarqube")
|
sonarqubeWebhookSecretFile := path.Join(os.TempDir(), "webhook-secret-sonarqube")
|
||||||
_ = ioutil.WriteFile(sonarqubeWebhookSecretFile, []byte(`sonarqube-totally-secret`),0444)
|
_ = ioutil.WriteFile(sonarqubeWebhookSecretFile, []byte(`sonarqube-totally-secret`), 0444)
|
||||||
|
|
||||||
sonarqubeTokenFile := path.Join(os.TempDir(), "token-secret-sonarqube")
|
sonarqubeTokenFile := path.Join(os.TempDir(), "token-secret-sonarqube")
|
||||||
_ = ioutil.WriteFile(sonarqubeTokenFile, []byte(`a09eb5785b25bb2cbacf48808a677a0709f02d8e`),0444)
|
_ = ioutil.WriteFile(sonarqubeTokenFile, []byte(`a09eb5785b25bb2cbacf48808a677a0709f02d8e`), 0444)
|
||||||
|
|
||||||
WriteConfigFile(t, []byte(
|
WriteConfigFile(t, []byte(
|
||||||
`gitea:
|
`gitea:
|
||||||
url: https://example.com/gitea
|
url: https://example.com/gitea
|
||||||
token:
|
token:
|
||||||
value: fake-gitea-token
|
value: fake-gitea-token
|
||||||
|
@ -213,7 +213,7 @@ func TestLoadProjectsStructure(t *testing.T) {
|
||||||
|
|
||||||
expectedProjects := []Project{
|
expectedProjects := []Project{
|
||||||
Project{
|
Project{
|
||||||
SonarQube: struct {Key string}{
|
SonarQube: struct{ Key string }{
|
||||||
Key: "gitea-sonarqube-pr-bot",
|
Key: "gitea-sonarqube-pr-bot",
|
||||||
},
|
},
|
||||||
Gitea: GiteaRepository{
|
Gitea: GiteaRepository{
|
||||||
|
@ -228,7 +228,7 @@ func TestLoadProjectsStructure(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadProjectsStructureWithNoMapping(t *testing.T) {
|
func TestLoadProjectsStructureWithNoMapping(t *testing.T) {
|
||||||
invalidConfig := []byte(
|
invalidConfig := []byte(
|
||||||
`gitea:
|
`gitea:
|
||||||
url: https://example.com/gitea
|
url: https://example.com/gitea
|
||||||
token:
|
token:
|
||||||
value: d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565
|
value: d0fcdeb5eaa99c506831f9eb4e63fc7cc484a565
|
||||||
|
|
|
@ -20,7 +20,7 @@ func Serve(c *cli.Context) error {
|
||||||
fmt.Println("Hi! I'm the Gitea-SonarQube-PR bot. At your service.")
|
fmt.Println("Hi! I'm the Gitea-SonarQube-PR bot. At your service.")
|
||||||
|
|
||||||
var wait time.Duration
|
var wait time.Duration
|
||||||
flag.DurationVar(&wait, "graceful-timeout", time.Second * 15, "the duration for which the server gracefully wait for existing connections to finish")
|
flag.DurationVar(&wait, "graceful-timeout", time.Second*15, "the duration for which the server gracefully wait for existing connections to finish")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package webhook_handler
|
package webhook_handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,15 +2,15 @@ package webhook_handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gitea-sonarqube-pr-bot/internal/settings"
|
|
||||||
giteaSdk "gitea-sonarqube-pr-bot/internal/clients/gitea_sdk"
|
giteaSdk "gitea-sonarqube-pr-bot/internal/clients/gitea_sdk"
|
||||||
sqSdk "gitea-sonarqube-pr-bot/internal/clients/sonarqube_sdk"
|
sqSdk "gitea-sonarqube-pr-bot/internal/clients/sonarqube_sdk"
|
||||||
|
"gitea-sonarqube-pr-bot/internal/settings"
|
||||||
webhook "gitea-sonarqube-pr-bot/internal/webhooks/sonarqube"
|
webhook "gitea-sonarqube-pr-bot/internal/webhooks/sonarqube"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package sonarqube
|
package sonarqube
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue