Add gitservers to backend
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package models
|
||||
|
||||
import "errors"
|
||||
|
||||
type GitServer struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Protocol string `json:"protocol"`
|
||||
BaseUrl string `json:"baseUrl"`
|
||||
Type string `json:"type"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
func ValidateGitServer(gs *GitServer) error {
|
||||
if gs.Name == "" {
|
||||
return errors.New("name is required")
|
||||
}
|
||||
if gs.Protocol == "" {
|
||||
return errors.New("protocol is required")
|
||||
}
|
||||
if gs.Protocol != "http" && gs.Protocol != "https" {
|
||||
return errors.New("protocol must be either 'http' or 'https'")
|
||||
}
|
||||
if gs.BaseUrl == "" {
|
||||
return errors.New("baseUrl is required")
|
||||
}
|
||||
if gs.Type == "" {
|
||||
return errors.New("type is required")
|
||||
}
|
||||
if gs.Type != "github" && gs.Type != "gitlab" && gs.Type != "gitea" {
|
||||
return errors.New("type must be either 'github', 'gitlab' or 'gitea'")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user