The params package should not depend on config. The params packages
should be consumable by external applications that wish to interact with
garm, and it makes no sense to pull in the config package just for some
constants. As such, the following changes have been made:
* Moved some types from config to params
* Moved defaults in a new leaf package called appdefaults
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This change renames the module from "garm" to "github.com/cloudbase/garm".
This will make it easier to consume public functions defined in garm, by
external applications, without having to resort to replace.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Extra specs is an opaque valid JSON that can be set on a pool and which
will be passed along to the provider as part of instance bootstrap params.
This field is meant to allow operators to send extra configuration values
to external or built-in providers. The extra specs is not interpreted or
useful in any way to garm itself, but it may be useful to the provider
which interacts with the IaaS.
The extra specs are not meant to be used for secrets. Adding sensitive
information to this field is highly discouraged. This field is meant as a
means to add fine tuning knobs to the providers, on a per pool basis.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
There are several fields that are common among some of the data
structures in garm. The RunnerPrefix is just one of them. Perhaps we
should move some of the rest in a common type and embed that into the
types that share those fields.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Define a metadata subrouter and move the token endpoint there. We may
end up needing multiple endpoints for various purposes in the future.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This change adds a github registration endpoint that instances can use
to fetch a github registration token.
This change also invalidates disables access to an instance to the token
and status updates endpoints once the instance transitions from
"pending" or "installing" to any other state.
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>
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>
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>
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>
* 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>
Pools can now define a bootstrap timeout for runners. The timeout can
be defined per pool and indicates the amount of time after which a runner
is considered defunct and removed.
If a runner doesn't join github in the configured amount of time, and it
receives no updates indicating that it is installing the runner via instance
status updates, it is considered defunct.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Runners can now be manually removed using the CLI. Some restrictions apply:
* A runner must be idle in github. Github will not allow us to remove a runner
that is running a workflow.
* The runner status must be "running"
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
When deleting a VM, we try to force stop it. If the VM is already stopped,
LXD will return an error. Unfortunately, we can't import the drivers package
from LXD without also pulling in a bunch of linux specific CGO dependencies
which we want to avoid.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>