Files
oc-monitord/conf/conf.go
T

61 lines
1.6 KiB
Go
Raw Normal View History

2024-07-25 18:48:25 +02:00
package conf
2026-05-27 16:09:45 +02:00
import (
"sync"
"time"
"cloud.o-forge.io/core/oc-lib/config"
)
2024-07-25 18:48:25 +02:00
type Config struct {
2024-08-19 11:43:40 +02:00
ExecutionID string
2025-02-05 08:36:26 +01:00
PeerID string
2024-08-22 10:52:49 +02:00
Timeout int
2024-08-19 11:43:40 +02:00
WorkflowID string
2025-02-05 08:36:26 +01:00
Logs string
2025-02-14 12:00:29 +01:00
Mode string
KubeHost string
KubePort string
KubeCA string
KubeCert string
KubeData string
2026-03-25 11:13:12 +01:00
ArgoHost string // when executed in a container will replace addresses with "localhost" in their url
2026-05-27 16:09:45 +02:00
// OCNamespace est le namespace Kubernetes où tournent les composants OpenCloud (NATS, etc.).
// Utilisé pour construire le FQDN NATS accessible depuis n'importe quel namespace.
// Valeur par défaut : "opencloud".
NatsUrl string
OCNamespace string
// ScheduledTime is the wall-clock time at which the Argo workflow must be submitted.
// oc-monitord completes pre-pull + infra setup first, then waits until this time.
// Zero value means "submit immediately after prep".
ScheduledTime time.Time
}
// NATSPodURL retourne l'URL NATS utilisable depuis un pod dans n'importe quel namespace.
// Les pods Argo tournent dans le namespace executions_id, pas dans OCNamespace,
// donc le FQDN complet est nécessaire pour atteindre le service NATS.
func (c *Config) NATSPodURL() string {
if config.GetConfig().NATSUrl == "" {
ns := c.OCNamespace
if ns == "" {
ns = "opencloud"
}
return "nats." + ns + ".svc.cluster.local:4222"
}
return config.GetConfig().NATSUrl
2024-07-25 18:48:25 +02:00
}
var instance *Config
var once sync.Once
func GetConfig() *Config {
once.Do(func() {
instance = &Config{}
})
return instance
}
2024-08-06 11:42:37 +02:00
func GetConfFromArgs(argument string) {
2024-07-25 18:48:25 +02:00
2024-08-06 11:42:37 +02:00
}