autogits/obs-staging-bot/main.go

59 lines
1015 B
Go
Raw Normal View History

2024-07-07 21:08:41 +02:00
package main
import (
2024-07-18 17:26:17 +02:00
"os"
2024-07-16 22:05:44 +02:00
2024-07-07 21:08:41 +02:00
"src.opensuse.org/autogits/common"
)
const (
GitAuthor = "GiteaBot - Obs Staging"
2024-07-16 17:05:43 +02:00
ObsBuildBot = "/obsbuild"
2024-07-07 21:08:41 +02:00
)
var GiteaToken string
2024-07-16 22:05:44 +02:00
var runId uint
2024-07-07 21:08:41 +02:00
2024-07-16 22:05:44 +02:00
2024-07-18 17:26:17 +02:00
func allocateRequestHandler() *common.RequestHandler {
2024-07-16 22:05:44 +02:00
return &common.RequestHandler {
2024-07-18 17:26:17 +02:00
Logger: common.CreateStdoutLogger(os.Stdout, os.Stdout),
2024-07-16 22:05:44 +02:00
}
}
2024-07-07 21:08:41 +02:00
2024-07-18 16:43:27 +02:00
func PollWorkNotifications() {
h := allocateRequestHandler()
data, err := h.GetNotifications(nil)
if err != nil {
h.LogPlainError(err)
return
}
if data != nil {
for _, notification := range data {
h.Log("[+] id: %d", notification.ID)
h.Log(" title: %s", notification.Subject.Title)
h.Log(" subj: %#v", notification.Subject)
}
}
}
2024-07-16 17:05:43 +02:00
func main() {
var defs common.ListenDefinitions
2024-07-07 21:08:41 +02:00
2024-07-16 17:05:43 +02:00
defs.Url = ObsBuildBot
defs.GitAuthor = GitAuthor
2024-07-07 21:08:41 +02:00
2024-07-16 17:05:43 +02:00
common.RequireGiteaSecretToken()
common.RequireObsSecretToken()
2024-07-16 22:05:44 +02:00
2024-07-18 16:43:27 +02:00
// go ProcessingObsMessages("rabbit.opensuse.org", "opensuse", "opensuse", "")
PollWorkNotifications()
2024-07-17 17:20:24 +02:00
stuck := make(chan int)
<-stuck
2024-07-07 21:08:41 +02:00
}