Commit graph

126 commits

Author SHA1 Message Date
Gabriel
93619b8d4e
Merge pull request #19 from gabriel-samfira/fetch-runner-name-from-api
Attempt to fetch runner name from API
2022-09-20 16:50:13 +03:00
Gabriel Adrian Samfira
e8fa6dba6e
Attempt to fetch runner name from API
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>
2022-09-20 14:46:44 +03:00
Gabriel
8cec645b10
Merge pull request #18 from mihaelabalutoiu/cleanup-unused-struct-field
Cleanup unused struct field and Fix typo
2022-09-16 15:02:39 +03:00
mihaelabalutoiu
6039a97d5a Fix typo 2022-09-15 19:18:28 +03:00
mihaelabalutoiu
e2ada6d1e3 Cleanup unused struct field
Remove `Pool` field from `CreateInstanceParams` struct, because
this is given as a separate parameter to the `CreateInstance` function.
2022-09-15 19:11:37 +03:00
Gabriel
775dd51782
Merge pull request #16 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` unit tests
2022-09-15 19:01:13 +03:00
mihaelabalutoiu
797ec21dd9 Add instances.go unit tests 2022-09-15 18:59:16 +03:00
Gabriel
476c3b814f
Merge pull request #17 from gabriel-samfira/create-testing-package
Create a testing package for common utilities
2022-09-15 18:03:06 +03:00
Gabriel Adrian Samfira
b4ac128673
Create a testing package for common utilities
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-15 17:48:09 +03:00
Gabriel
a2cd015533
Merge pull request #15 from mihaelabalutoiu/cleanup-duplicate-code
Cleanup duplicate code
2022-09-14 15:55:23 +03:00
mihaelabalutoiu
8c910d904f Cleanup duplicate code 2022-09-14 12:55:26 +03:00
Gabriel
777c41e411
Merge pull request #14 from mihaelabalutoiu/add-db-ctrl-unit-tests
Add `controller.go` unit tests
2022-09-13 15:23:50 +03:00
mihaelabalutoiu
6fe6680e52 Fix database.go typo 2022-09-13 15:01:17 +03:00
mihaelabalutoiu
bdb087578a Add controller.go unit tests 2022-09-13 14:21:21 +03:00
Gabriel
5759b74e0d
Merge pull request #12 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-09 17:51:11 +03:00
Gabriel
8b1c8860a0
Merge pull request #13 from mihaelabalutoiu/update-organizations-unit-tests
Update `organizations.go` unit tests
2022-09-09 17:50:05 +03:00
mihaelabalutoiu
8215edfe26 Update organization.go unit tests 2022-09-09 16:38:52 +03:00
mihaelabalutoiu
54f2dd6154 Add repositories.go unit tests 2022-09-09 15:57:18 +03:00
Gabriel
8e3b1e508c
Merge pull request #11 from mihaelabalutoiu/add-repositories-unit-tests
Add more `repositories.go` unit testing
2022-09-09 11:33:20 +03:00
mihaelabalutoiu
c5158fbf5c Add more repositories.go unit testing 2022-09-09 10:47:36 +03:00
Gabriel
16a81cfd1b
Merge pull request #10 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-07 18:25:27 +03:00
mihaelabalutoiu
505489eddf Add repositories.go unit tests 2022-09-07 16:49:42 +03:00
Gabriel
2ccfbc480b
Merge pull request #9 from ionutbalutoiu/add-go-tests-github-workflow
Add go tests GitHub workflow
2022-09-07 16:36:28 +03:00
Ionut Balutoiu
30c1510967 Add Go Tests GitHub workflow
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:33:13 +03:00
Ionut Balutoiu
8f29f90488 Add 'go test' Makefile target
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:32:29 +03:00
Gabriel Adrian Samfira
3949912678
Update gitignore
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:36:35 +03:00
Gabriel Adrian Samfira
d4b7fca9f6
Fix test config_dir
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:42 +03:00
Gabriel Adrian Samfira
99856af4de
Silence gorm default logger
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>
2022-09-06 21:35:01 +03:00
Gabriel
c0df364bb0
Merge pull request #8 from mihaelabalutoiu/add-organizations-unit-tests
Add `organizations.go` unit tests and `PoolManagerController` mocks
2022-09-06 20:12:46 +03:00
mihaelabalutoiu
1a7c31c8ea Add more organizations.go unit testing
Also, update vendor with the `github.com/stretchr/testify/suite`.
2022-09-06 18:04:51 +03:00
mihaelabalutoiu
3094ad09be Add PoolManagerController mocks 2022-09-01 16:08:56 +03:00
Gabriel
b74b829ce6
Merge pull request #7 from mihaelabalutoiu/refactor-code
Refactor code to allow more unit testing
2022-08-19 13:07:12 +03:00
Ionut Balutoiu
7b6c2e6106 Refactor code to allow more unit testing
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.
2022-08-18 17:47:05 +03:00
Gabriel
ad97baac70
Merge pull request #6 from mihaelabalutoiu/add-unit-tests
Add unit tests
2022-08-01 18:08:52 +03:00
mihaelabalutoiu
a869b5d743 Add unit tests 2022-08-01 12:34:59 +03:00
Gabriel
cd4e4fb985
Merge pull request #5 from mihaelabalutoiu/dev
Fix `NewConfig` func & and add more unit tests
2022-07-26 14:24:53 +03:00
mihaelabalutoiu
229946a4c0 Add unit tests for full coverage to the NewConfig function 2022-07-26 13:43:56 +03:00
mihaelabalutoiu
795b7ebb56 Add missing assertion 2022-07-26 13:43:35 +03:00
mihaelabalutoiu
c523032c86 Fix NewConfig function
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.
2022-07-21 11:51:52 +03:00
Gabriel Adrian Samfira
067197c1b5 Fix instance JWT token expiration
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>
2022-07-17 07:24:19 +00:00
Gabriel Adrian Samfira
5d02de92d3 Clarify external provider docs 2022-07-17 06:34:50 +00:00
Gabriel Adrian Samfira
74a1863f63 Update docs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-16 18:14:38 +00:00
Gabriel Adrian Samfira
95db6599ff Make external provider less opinionated about executable
You can now specify the absolute path to a provider executable instead
of specifying a provider directory with a "garm-external-provider" in it.
2022-07-16 18:00:07 +00:00
Gabriel Adrian Samfira
5b651eeb3f Update example config with LXD instance type setting
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-16 13:52:38 +00:00
Gabriel Adrian Samfira
3da860eea6 Always lookup images in simplestreams
This change makes sure we always download the latest image from
simplestreams. We no longer copy labels from simplestreams so we need
to lookup the hash of the image against simplestreams. This means that
in airgapped environments, the operator will have to manually tag images
and use the tag name in favor of remote:image_name.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-16 13:47:17 +00:00
Gabriel Adrian Samfira
dede5cc465 Allow deletion of a runner in error state
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-16 13:41:26 +00:00
Gabriel Adrian Samfira
ecd476af02 Add container support to LXD provider plus fixes
* Add the ability to define an LXD provider which spins up containers
    instead of virtual machines.
  * Loading an LXD provider that is not reachable no longer crashes garm
    on startup.
  * Labels are no longer copied on image import. The LXD provider will
    resolve the image fingerprint from the simplestreams server every time.
    The image will be copied locally if a new version exists.
2022-07-12 13:34:12 +00:00
Gabriel Adrian Samfira
5566cde77f A few fixes
* CLI properly formats the IP addresses in runner show
  * LXD provider now waits for an IP address before returning on Create
  * Added a few mocks for testing

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-10 14:52:15 +00:00
Gabriel Adrian Samfira
afb1d31394 Slight cleanup
* added interface for the github client. This will help mocking it
out for testing.
  * removed some unused code
  * moved some code around

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-07 16:48:00 +00:00
Gabriel Adrian Samfira
fb0bcbe3eb Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-06 22:08:22 +00:00