Commit graph

159 commits

Author SHA1 Message Date
Ionut Balutoiu
85fd3924ee Fix azure and openstack external providers
* The `{{ .RunnerUsername }}` is not replaced in any external providers' scripts.
  However, we can safely assume that the username is properly created by
  cloud-init before the userdata is executed.
* Correctly use the `OS_TO_GH_ARCH_MAP` bash map.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-10-21 10:26:06 +03:00
Gabriel
0699973abe
Merge pull request #43 from mihaelabalutoiu/add-db-repositories-unit-tests
Add unit tests for the `database/sql/repositories.go`
2022-10-18 16:59:09 +03:00
Mihaela Balutoiu
989717dcfa Add unit tests for the database/sql/repositories.go
Add more test cases regarding the SQL database interactions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-18 16:44:10 +03:00
Gabriel
19e31cc922
Merge pull request #42 from mihaelabalutoiu/fix-error-wrap
Fixed error wrap
2022-10-18 10:17:07 +03:00
Gabriel
8db1f05d09
Merge pull request #41 from gabriel-samfira/do-not-remove-foreign-runners
Don't remove foreign runners
2022-10-18 08:46:15 +03:00
Gabriel Adrian Samfira
49fbc110d5
Don't remove foreign runners
When garm starts up, it attempts to cleanup any orphaned runners from
github. This, unfortunately ends up deleting manually set up runners.
This change looks for our controller ID in the labels of the runners and
only deleted runners that we created.

Fixes: #40

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-17 18:45:48 +03:00
Mihaela Balutoiu
36a51f83ab Fixed error wrap
The error is not wrapped correctly, because instead of using `q.Error`,
it uses `err`, which is defined elsewhere.

Also, the `UpdateRepository` and `CreateRepositoryPool` functions will
never fail on update/create repo, because it returns a nil error, instead
of wrap error.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-17 17:48:00 +03:00
Gabriel
996102fd98
Merge pull request #39 from mihaelabalutoiu/add-db-repositories-unit-tests
Add more test cases for the `database/sql/repositories.go`
2022-10-17 13:39:29 +03:00
Mihaela Balutoiu
04e89ce1ab Add more test cases for the database/sql/repositories.go
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-17 13:35:38 +03:00
Gabriel
5ff935a4da
Merge pull request #38 from mihaelabalutoiu/add-db-repositories-unit-tests
Add `repositories.go` unit testing
2022-10-14 19:15:33 +03:00
Mihaela Balutoiu
98306dd25a Add repositories.go unit testing
Add initial unit tests for the `database/sql/repositories.go` from `sql`package.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-14 18:10:34 +03:00
Gabriel
68100e438b
Merge pull request #36 from mihaelabalutoiu/add-db-pools-unit-tests
Add `pools.go` database unit tests
2022-10-13 18:39:07 +03:00
Mihaela Balutoiu
c65cf9ab0c Add pools.go database unit tests
Add full tests coverage for `database/sql/pools.go` file.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-13 17:57:00 +03:00
Gabriel
50aa7fbd1a
Merge pull request #35 from mihaelabalutoiu/add-db-pools-unit-tests
Add `pools.go` unit tests
2022-10-13 16:43:59 +03:00
Mihaela Balutoiu
1197e82752 Add pools.go unit tests
Add initial unit tests for the `database/sql/pools.go` from `sql` package.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-13 15:18:26 +03:00
Gabriel
e9e6e507a4
Merge pull request #34 from mihaelabalutoiu/add-db-organizations-unit-tests
Add `organizations.go` database unit testing
2022-10-12 19:18:42 +03:00
Mihaela Balutoiu
8d138afde2 Add organizations.go database unit testing
Add more test cases regarding the SQL database interactions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-12 17:27:08 +03:00
Gabriel
e82c97bbc6
Merge pull request #31 from mihaelabalutoiu/fix-error-wrap
Fixed error wrap
2022-10-10 14:52:16 +03:00
Mihaela Balutoiu
1116de7608 Fixed error wrap
The error is not wrapped correctly, because instead of using `q.Error`,
it uses `err`, which is defined elsewhere.

Also, the `UpdateOrganization` and `CreateOrganizationPool` functions will
never fail on update/create org, because it returns a nil error, instead
of wrap error.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-10 14:45:55 +03:00
Gabriel
59c8f397ac
Merge pull request #28 from mercedes-benz/no-404
feat: webhook does not return error on 'instance not found'.
2022-10-07 12:27:47 +03:00
Michael Kuhnt
5bfecbaa30 feat: webhook does not return error on 'instance not found'.
This case is probably caused by a webhook event that was meant for
another runner controller / manager. No need to report this as
error, we can simply ignore this and avoid noise in the logs.
2022-10-07 11:18:25 +02:00
Gabriel
e0d1de69e4
Merge pull request #27 from mihaelabalutoiu/add-db-organizations-unit-tests
Add more `organizations.go` unit testing
2022-10-06 13:40:05 +03:00
Mihaela Balutoiu
23f521b682 Add more organizations.go unit testing 2022-10-06 11:59:05 +03:00
Gabriel
e83f06529a
Merge pull request #26 from gabriel-samfira/make-queries-case-insensitive
Make owners and repos case insensitive
2022-10-06 11:26:17 +03:00
Gabriel Adrian Samfira
0ff2fd2e06
Make owners and repos case insensitive
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>
2022-10-05 18:14:07 +03:00
Gabriel
8ca9a82529
Merge pull request #24 from mihaelabalutoiu/add-db-organizations-unit-tests
Add `organizations.go` unit tests
2022-10-05 16:17:14 +03:00
Mihaela Balutoiu
5692439dda Add organizations.go unit tests 2022-10-03 17:55:35 +03:00
Gabriel
e9aba82ec1
Merge pull request #23 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` database unit tests
2022-09-28 18:01:39 +03:00
Mihaela Balutoiu
723c9c3d60 Add instances.go database unit tests
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>
2022-09-28 17:29:40 +03:00
Gabriel
3c49df5144
Merge pull request #22 from mihaelabalutoiu/add-db-instances-unit-tests
Add more `instances.go` unit tests
2022-09-21 20:37:29 +03:00
Mihaela Balutoiu
898e098ff8 Add more instances.go unit tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-09-21 20:34:14 +03:00
Gabriel
d9332f21ae
Merge pull request #21 from ionutbalutoiu/add-badge-link
Add link to `Go Tests` README badge
2022-09-21 18:40:16 +03:00
Ionut Balutoiu
b8e6d56428 Add link to Go Tests README badge
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>
2022-09-21 18:26:43 +03:00
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