8e4e45047d
This container's network is configured based on parameters in the config file. If configured correctly, this will allow the pipeline script to speak to the cursorius server over the pipeline api.
87 lines
1.7 KiB
Go
87 lines
1.7 KiB
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 MountType string
|
|
|
|
const (
|
|
Bind MountType = "bind"
|
|
Volume = "volume"
|
|
)
|
|
|
|
type MountConf struct {
|
|
Type MountType
|
|
Source string
|
|
}
|
|
|
|
type PipelineConf struct {
|
|
AccessURL string // URL that the pipeline runner can access the server at
|
|
DockerNetwork *string // Name of the docker network that should be assigned to the pipeline script runner
|
|
WorkingDir string
|
|
MountConf MountConf // This script describes how to mount WorkingDir into the pipeline executor container
|
|
}
|
|
|
|
type Config struct {
|
|
Address string
|
|
Port int
|
|
PipelineConf PipelineConf
|
|
Jobs map[string]Job
|
|
Runners map[string]Runner
|
|
}
|
|
|
|
func GetConfig() (config.Config[Config], error) {
|
|
defaultNetworkName := "cursorius"
|
|
configData := config.Config[Config]{
|
|
Name: "cursorius",
|
|
Filename: "server",
|
|
Config: Config{
|
|
Address: "127.0.0.1",
|
|
Port: 45420,
|
|
PipelineConf: PipelineConf{
|
|
AccessURL: "cursorius-server:45420",
|
|
DockerNetwork: &defaultNetworkName,
|
|
WorkingDir: "/opt/cursorius/working",
|
|
MountConf: MountConf{
|
|
Type: Bind,
|
|
Source: "/opt/cursorius/working",
|
|
},
|
|
},
|
|
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
|
|
}
|