57 lines
871 B
Go
57 lines
871 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.ohea.xyz/golang/config"
|
|
)
|
|
|
|
type WebhookSender string
|
|
|
|
const (
|
|
Gitea WebhookSender = "gitea"
|
|
)
|
|
|
|
type Webhook struct {
|
|
Sender WebhookSender
|
|
Secret string
|
|
}
|
|
|
|
type Job struct {
|
|
URL string
|
|
Webhook *Webhook
|
|
Cron *string
|
|
PollInterval uint64
|
|
}
|
|
|
|
type Runner struct {
|
|
Secret string
|
|
}
|
|
|
|
type Config struct {
|
|
Address string
|
|
Port int
|
|
Jobs map[string]Job
|
|
Runners map[string]Runner
|
|
}
|
|
|
|
func GetConfig() (config.Config[Config], error) {
|
|
configData := config.Config[Config]{
|
|
Name: "cursorius",
|
|
Filename: "server",
|
|
Config: Config{
|
|
Address: "127.0.0.1",
|
|
Port: 45420,
|
|
Jobs: make(map[string]Job),
|
|
Runners: make(map[string]Runner),
|
|
},
|
|
}
|
|
|
|
_, err := configData.Get()
|
|
if err != nil {
|
|
return configData, fmt.Errorf("Could not read config file: %v", err)
|
|
}
|
|
|
|
return configData, nil
|
|
}
|