Add EndpointType
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
ef676488b7
commit
4890eb4732
6 changed files with 48 additions and 11 deletions
|
|
@ -44,6 +44,7 @@ type (
|
|||
RunnerStatus string
|
||||
WebhookEndpointType string
|
||||
GithubAuthType string
|
||||
EndpointType string
|
||||
PoolBalancerType string
|
||||
ScaleSetState string
|
||||
ScaleSetMessageType string
|
||||
|
|
@ -76,6 +77,11 @@ const (
|
|||
PoolBalancerTypeNone PoolBalancerType = ""
|
||||
)
|
||||
|
||||
const (
|
||||
GithubEndpointType EndpointType = "github"
|
||||
GiteaEndpointType EndpointType = "gitea"
|
||||
)
|
||||
|
||||
const (
|
||||
// LXDProvider represents the LXD provider.
|
||||
LXDProvider ProviderType = "lxd"
|
||||
|
|
@ -1138,5 +1144,7 @@ type GithubEndpoint struct {
|
|||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
|
||||
EndpointType EndpointType `json:"endpoint_type,omitempty"`
|
||||
|
||||
Credentials []GithubCredentials `json:"credentials,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ type CreateGithubEndpointParams struct {
|
|||
APIBaseURL string `json:"api_base_url,omitempty"`
|
||||
UploadBaseURL string `json:"upload_base_url,omitempty"`
|
||||
BaseURL string `json:"base_url,omitempty"`
|
||||
EndpointType string `json:"endpoint_type,omitempty"`
|
||||
CACertBundle []byte `json:"ca_cert_bundle,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -289,6 +290,14 @@ func (c CreateGithubEndpointParams) Validate() error {
|
|||
return runnerErrors.NewBadRequestError("missing api_base_url")
|
||||
}
|
||||
|
||||
if c.EndpointType != "" {
|
||||
switch c.EndpointType {
|
||||
case string(GithubEndpointType), string(GiteaEndpointType):
|
||||
default:
|
||||
return runnerErrors.NewBadRequestError("invalid endpoint_type: %s", c.EndpointType)
|
||||
}
|
||||
}
|
||||
|
||||
url, err := url.Parse(c.APIBaseURL)
|
||||
if err != nil || url.Scheme == "" || url.Host == "" {
|
||||
return runnerErrors.NewBadRequestError("invalid api_base_url")
|
||||
|
|
@ -299,19 +308,21 @@ func (c CreateGithubEndpointParams) Validate() error {
|
|||
return runnerErrors.NewBadRequestError("invalid api_base_url")
|
||||
}
|
||||
|
||||
if c.UploadBaseURL == "" {
|
||||
return runnerErrors.NewBadRequestError("missing upload_base_url")
|
||||
}
|
||||
if c.EndpointType == string(GithubEndpointType) {
|
||||
if c.UploadBaseURL == "" {
|
||||
return runnerErrors.NewBadRequestError("missing upload_base_url")
|
||||
}
|
||||
|
||||
url, err = url.Parse(c.UploadBaseURL)
|
||||
if err != nil || url.Scheme == "" || url.Host == "" {
|
||||
return runnerErrors.NewBadRequestError("invalid upload_base_url")
|
||||
}
|
||||
url, err = url.Parse(c.UploadBaseURL)
|
||||
if err != nil || url.Scheme == "" || url.Host == "" {
|
||||
return runnerErrors.NewBadRequestError("invalid upload_base_url")
|
||||
}
|
||||
|
||||
switch url.Scheme {
|
||||
case httpsScheme, httpScheme:
|
||||
default:
|
||||
return runnerErrors.NewBadRequestError("invalid api_base_url")
|
||||
switch url.Scheme {
|
||||
case httpsScheme, httpScheme:
|
||||
default:
|
||||
return runnerErrors.NewBadRequestError("invalid api_base_url")
|
||||
}
|
||||
}
|
||||
|
||||
if c.BaseURL == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue