Add gitservers to backend

This commit is contained in:
2026-05-02 17:37:36 +02:00
parent 38d2083d06
commit 76e3454c4c
6 changed files with 311 additions and 0 deletions
+34
View File
@@ -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
}