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:
@@ -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)
|
||||
|
||||
@@ -123,7 +123,7 @@ func PeriodReviewCheck(gitea common.Gitea) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
giteaHost := flag.String("gitea-host", "src.opensuse.org", "Gitea instance used for reviews")
|
||||
giteaUrl := flag.String("gitea-url", "https://src.opensuse.org", "Gitea instance used for reviews")
|
||||
rabbitMqHost := flag.String("rabbit-host", "rabbit.opensuse.org", "RabbitMQ instance where Gitea webhook notifications are sent")
|
||||
interval := flag.Int64("internval", 5, "Notification polling interval in minutes (min 1 min)")
|
||||
configFile := flag.String("config", "", "PrjGit listing config file")
|
||||
@@ -153,7 +153,7 @@ func main() {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
gitea := common.AllocateGiteaTransport(*giteaHost)
|
||||
gitea := common.AllocateGiteaTransport(*giteaUrl)
|
||||
configs, err = common.ResolveWorkflowConfigs(gitea, configData)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
|
||||
@@ -299,8 +299,8 @@ func generateObsPrjMeta(git common.Git, gitea common.Gitea, pr *models.PullReque
|
||||
meta.Description = fmt.Sprintf(`Pull request build job PR#%d to branch %s of %s/%s`,
|
||||
pr.Index, pr.Base.Name, pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name)
|
||||
meta.Url = fmt.Sprintf(
|
||||
"https://%s/%s/%s/pulls/%d",
|
||||
giteaHost,
|
||||
"%s/%s/%s/pulls/%d",
|
||||
giteaUrl,
|
||||
url.PathEscape(pr.Base.Repo.Owner.UserName),
|
||||
url.PathEscape(pr.Base.Repo.Name),
|
||||
pr.Index,
|
||||
@@ -579,8 +579,8 @@ func processPullNotification(gitea common.Gitea, thread *models.NotificationThre
|
||||
}
|
||||
}
|
||||
|
||||
func pollWorkNotifications(giteaHost string) {
|
||||
gitea := common.AllocateGiteaTransport(giteaHost)
|
||||
func pollWorkNotifications(giteaUrl string) {
|
||||
gitea := common.AllocateGiteaTransport(giteaUrl)
|
||||
data, err := gitea.GetPullNotifications(nil)
|
||||
|
||||
if err != nil {
|
||||
@@ -609,7 +609,7 @@ var ListPullNotificationsOnly bool
|
||||
var ProcessIDOnly int64
|
||||
var Debug bool
|
||||
var BuildRoot string
|
||||
var giteaHost string
|
||||
var giteaUrl string
|
||||
var giteaUseSshClone bool
|
||||
var obsApiHost string
|
||||
var obsWebHost string
|
||||
@@ -627,7 +627,7 @@ func main() {
|
||||
flag.BoolVar(&ListPullNotificationsOnly, "list-notifications-only", false, "Only lists notifications without acting on them")
|
||||
flag.Int64Var(&ProcessIDOnly, "id", -1, "Process only the specific ID and ignore the rest. Use for debugging")
|
||||
flag.StringVar(&BuildRoot, "build-root", "", "Default build location for staging projects. Default is bot's home project")
|
||||
flag.StringVar(&giteaHost, "gitea", "src.opensuse.org", "Gitea instance")
|
||||
flag.StringVar(&giteaUrl, "gitea-url", "https://src.opensuse.org", "Gitea instance")
|
||||
flag.BoolVar(&giteaUseSshClone, "use-ssh-clone", false, "enforce cloning via ssh")
|
||||
flag.StringVar(&obsApiHost, "obs", "api.opensuse.org", "API for OBS instance")
|
||||
flag.StringVar(&obsWebHost, "obs-web", "", "Web OBS instance, if not derived from the obs config")
|
||||
@@ -643,7 +643,7 @@ func main() {
|
||||
// go ProcessingObsMessages("rabbit.opensuse.org", "opensuse", "opensuse", "")
|
||||
|
||||
for {
|
||||
pollWorkNotifications(giteaHost)
|
||||
pollWorkNotifications(giteaUrl)
|
||||
if Debug {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ func updateConfiguration(configFilename string, orgs *[]string) {
|
||||
|
||||
func main() {
|
||||
configFilename := flag.String("config", "", "List of PrjGit")
|
||||
giteaHost := flag.String("gitea", "src.opensuse.org", "Gitea instance")
|
||||
giteaUrl := flag.String("gitea-url", "https://src.opensuse.org", "Gitea instance")
|
||||
rabbitUrl := flag.String("url", "amqps://rabbit.opensuse.org", "URL for RabbitMQ instance")
|
||||
flag.BoolVar(&DebugMode, "debug", false, "Extra debugging information")
|
||||
flag.BoolVar(&checkOnStart, "check-on-start", false, "Check all repositories for consistency on start, without delays")
|
||||
@@ -530,7 +530,7 @@ func main() {
|
||||
|
||||
checkInterval = time.Duration(*checkIntervalHours) * time.Hour
|
||||
|
||||
gitea = common.AllocateGiteaTransport(*giteaHost)
|
||||
gitea = common.AllocateGiteaTransport(*giteaUrl)
|
||||
CurrentUser, err := gitea.GetCurrentUser()
|
||||
if err != nil {
|
||||
log.Fatalln("Cannot fetch current user:", err)
|
||||
|
||||
@@ -65,7 +65,7 @@ func main() {
|
||||
}
|
||||
|
||||
workflowConfig := flag.String("config", "", "Repository and workflow definition file")
|
||||
giteaHost := flag.String("gitea", "src.opensuse.org", "Gitea instance")
|
||||
giteaUrl := flag.String("gitea-url", "https://src.opensuse.org", "Gitea instance")
|
||||
rabbitUrl := flag.String("url", "amqps://rabbit.opensuse.org", "URL for RabbitMQ instance")
|
||||
flag.BoolVar(&DebugMode, "debug", false, "Extra debugging information")
|
||||
checkOnStart := flag.Bool("check-on-start", false, "Check all repositories for consistency on start, without delays")
|
||||
@@ -79,7 +79,7 @@ func main() {
|
||||
log.Fatalln("No configuratio file specified. Aborting")
|
||||
}
|
||||
|
||||
gitea := common.AllocateGiteaTransport(*giteaHost)
|
||||
gitea := common.AllocateGiteaTransport(*giteaUrl)
|
||||
config, err := common.ReadConfigFile(*workflowConfig)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user