Add frontend #1

Merged
KartoffelChipss merged 50 commits from feature/frontend into main 2026-05-06 20:16:59 +02:00
4 changed files with 12 additions and 11 deletions
Showing only changes of commit b0dc65cb3e - Show all commits
+2 -1
View File
@@ -5,12 +5,13 @@ import (
"strings"
)
func NewProvider(serverType, protocol, baseUrl string) (GitProvider, error) {
func NewProvider(serverType, protocol, baseUrl, authToken string) (GitProvider, error) {
switch strings.ToLower(serverType) {
case "github":
return &GitHubProvider{
protocol: protocol,
baseUrl: baseUrl,
authToken: authToken,
}, nil
default:
return nil, fmt.Errorf("unsupported git provider: %s", serverType)
+4 -3
View File
@@ -15,20 +15,21 @@ import (
type GitHubProvider struct {
protocol string
baseUrl string
authToken string
}
var _ GitProvider = (*GitHubProvider)(nil)
func (p *GitHubProvider) FetchAndDeployBranch(owner, repo, branch, authToken, destPath string) (*DeployResult, error) {
func (p *GitHubProvider) FetchAndDeployBranch(owner, repo, branch, destPath string) (*DeployResult, error) {
baseUrl := strings.TrimSuffix(p.baseUrl, "/")
apiUrl := fmt.Sprintf("%s://api.%s/", p.protocol, baseUrl)
result, err := fetchBranchHead(apiUrl, owner, repo, branch, authToken)
result, err := fetchBranchHead(apiUrl, owner, repo, branch, p.authToken)
if err != nil {
return nil, fmt.Errorf("fetching branch head: %w", err)
}
if err = downloadAndExtract(owner, repo, branch, authToken, destPath); err != nil {
if err = downloadAndExtract(owner, repo, branch, p.authToken, destPath); err != nil {
return nil, err
}
+1 -1
View File
@@ -6,5 +6,5 @@ type DeployResult struct {
}
type GitProvider interface {
FetchAndDeployBranch(owner, repo, branch, authToken, destPath string) (*DeployResult, error)
FetchAndDeployBranch(owner, repo, branch, destPath string) (*DeployResult, error)
}
+1 -2
View File
@@ -129,7 +129,7 @@ func (h *DeploySiteHandler) PostDeploy(c fiber.Ctx) error {
})
}
provider, err := gitprovider.NewProvider(gitServer.Type, gitServer.Protocol, gitServer.BaseUrl)
provider, err := gitprovider.NewProvider(gitServer.Type, gitServer.Protocol, gitServer.BaseUrl, gitServer.AuthToken)
if err != nil {
return c.Status(400).JSON(models.APIError{
Message: "Unsupported git provider: " + gitServer.Type,
@@ -140,7 +140,6 @@ func (h *DeploySiteHandler) PostDeploy(c fiber.Ctx) error {
site.Owner,
site.Repository,
site.Branch,
gitServer.AuthToken,
sitePath,
)