Github treats owners (users and orgs) and repos as case insensitive. To
github, https://github.com/cloudbase/garm is equivalent to
https://github.com/CloudBase/GaRm. This commit makes the sql store
backend, case insensitive when querying repos and orgs.
Fixes: #25
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Add more test cases regarding the SQL database interactions.
Moreover, add `go-sqlmock` dependency used to mock SQL DB instructions.
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Make sure that the README `Go Test` badge has a link to the GitHub
page with latest workflow results.
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
In some cases, runner information is not sent via webhook by Github when
a workflow job transitions to in_progress. We need to know the runner
name in order to update the state in the database. Attempt to fetch the
runner from the API using the workflow ID.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Disable the default logger for gorm when debug is not set on the sql
store backend. By default gorm will print error level log messages,
which includes queries which find no results, which is not really an
error.
These messages will show up if debug is enabled on the sql store
backend.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
In order to allow mocking for some of the `runner` functions, we created a
separate interface (called `PoolManagerController`) with `Create`, `Get`,
`Delete` operations for the `organization` / `repository` pool managers.
Furthermore, a new runner struct (`poolManagerCtrl`) implements this new
interface. The existing code is refactored to use the `poolManagerCtrl`
whenever the pool managers for `org` / `repo` are handled.
This allows more unit testing for the runner functions since `poolManagerCtrl`
field can be mocked now.
Besides this, there are some typos fixed as well.
Move the default setting before validating the config, otherwise the code will
never run. This happens because the `Validate()` function will always fail when
`config.Default.ConfigDir` is empty.
The instance JWT token expiration time was set at 15 minutes, regardless
of bootstrap timeout. This meant that instances that take longer than 15
minutes, would not be able to send their status updates and github agent
ID back to garm.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>