Use "-gitea-url" instead of "-gitea-host" or simiar

This allows to use another schema than https:// to connect to Gitea
This commit is contained in:
2025-04-07 14:20:26 +02:00
parent 5ea5f05b02
commit d3f1b36676
5 changed files with 21 additions and 15 deletions

View File

@@ -24,6 +24,7 @@ import (
"fmt"
"io"
"log"
"net/url"
"os"
"path"
"path/filepath"
@@ -139,10 +140,15 @@ type GiteaTransport struct {
client *apiclient.GiteaAPI
}
func AllocateGiteaTransport(host string) Gitea {
func AllocateGiteaTransport(giteaUrl string) Gitea {
var r GiteaTransport
r.transport = transport.New(host, apiclient.DefaultBasePath, [](string){"https"})
url, err := url.Parse(giteaUrl)
if err != nil {
log.Panicln("Failed to parse gitea url:", err)
}
r.transport = transport.New(url.Hostname(), apiclient.DefaultBasePath, [](string){url.Scheme})
r.transport.DefaultAuthentication = transport.BearerToken(giteaToken)
r.client = apiclient.New(r.transport, nil)