Commit graph

15 commits

Author SHA1 Message Date
justusbunsi b632381c90
Write tests for Gitea client
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/36
2022-07-12 18:31:25 +02:00
justusbunsi f808a58177
Refactor internal name to url-like one
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 16:57:12 +02:00
justusbunsi b6b9087651
Initialize SonarQube SDK with its settings
Instead of using global settings. This is important for validated
configuration reloads.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 12:26:10 +02:00
justusbunsi 51211d77cd
Change internal name
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-11 17:39:22 +02:00
justusbunsi 1b02303a4a
Use buffered channel as per docs
https://pkg.go.dev/os/signal#Notify

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 20:11:55 +02:00
justusbunsi 7e008773b0
Remove fvbock/endless as dependency
Fixes: #31

Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/32
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-07 19:56:26 +02:00
justusbunsi eb3cb301fc
Allow changing the port
This introduces a new application option `--port`/`-p` to switch the
listening port from 3000 (default) to another port.

Docker image can be configured using the corresponding environment
variable `GITEA_SQ_BOT_PORT`.

Helm Chart allows setting `.Values.app.listeningPort`

Resolves: #25

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-06-17 13:34:06 +02:00
justusbunsi dc3969cd05
Improve configuration file flexibility
Instead of re-inventing the wheel regarding configuration location
handling and validation, this introduces a new command flag `--config`
allowing for full flexibility of configuration filename and location.
This flag can also be defined via environment variable which allows
an easy way of starting the bot from command line, inside a Docker
container or using the Helm Chart.

It makes the custom environment lookup unnecessary and reduces some
complexity during startup and for writing tests.

Resolves: #10

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-05-22 14:03:23 +02:00
justusbunsi e203034228 Rewrite API entrypoint to be testable (#22)
The current code base regarding API entrypoint is not testable as it
directly connects to Gitea when creating the API endpoints. This
prevented my from writing tests in the past for that part.

As the SonarQube quality gate broke due to changes in the API entrypoint
logic, tests are now required to satisfy the quality gate.

Therefore, the instantiation of the API handlers is now decoupled from
building the bot API endpoints and follows the same interface wrapper
strategy as used for the Gitea API client. This makes it testable.

Now, tests are written for the most parts of the API entrypoint. I've
also noticed that there was much overhead within the tests for a
non-implemented function `fetchDetails`. So I dropped that function for
now.

Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>

Co-authored-by: justusbunsi <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://codeberg.org/justusbunsi/gitea-sonarqube-bot/pulls/22
2022-05-21 18:21:05 +02:00
justusbunsi 46c5ab2aec
Rename webhook_handler to api
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-10-10 16:18:14 +02:00
justusbunsi a1990a60f4
Format code
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-10-03 17:57:22 +02:00
justusbunsi 2af7ba3da1
Make application runnable
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-07-11 15:17:03 +02:00
justusbunsi 4ba781d74f
Respect go package concepts
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-06-29 08:09:21 +02:00
justusbunsi 5c6229be8f
Allow custom config path via environment variable
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-06-20 15:39:54 +02:00
justusbunsi 706aeb0d0f
Load config.yaml from config directory
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-06-20 15:16:06 +02:00