Move URLs from default section of config to DB

This change moves the callback_url, metadata_url and webhooks_url from
the config to the database. The goal is to move as much as possible from
the config to the DB, in preparation for a potential refactor that will
allow GARM to scale out. This would allow multiple nodes to share a single
source of truth.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-06-05 06:41:16 +00:00
parent 7ee235aeb0
commit 9748aa47af
22 changed files with 1067 additions and 177 deletions

View file

@ -501,3 +501,34 @@ func (u UpdateGithubCredentialsParams) Validate() error {
return nil
}
type UpdateControllerParams struct {
MetadataURL *string `json:"metadata_url,omitempty"`
CallbackURL *string `json:"callback_url,omitempty"`
WebhookURL *string `json:"webhook_url,omitempty"`
}
func (u UpdateControllerParams) Validate() error {
if u.MetadataURL != nil {
u, err := url.Parse(*u.MetadataURL)
if err != nil || u.Scheme == "" || u.Host == "" {
return runnerErrors.NewBadRequestError("invalid metadata_url")
}
}
if u.CallbackURL != nil {
u, err := url.Parse(*u.CallbackURL)
if err != nil || u.Scheme == "" || u.Host == "" {
return runnerErrors.NewBadRequestError("invalid callback_url")
}
}
if u.WebhookURL != nil {
u, err := url.Parse(*u.WebhookURL)
if err != nil || u.Scheme == "" || u.Host == "" {
return runnerErrors.NewBadRequestError("invalid webhook_url")
}
}
return nil
}