This commit is contained in:
el 2025-04-01 16:33:54 +02:00
commit d05799fe65
60 changed files with 7078 additions and 0 deletions

View file

@ -0,0 +1,40 @@
package config
import (
"os"
"time"
)
// Config représente la configuration de l'agent
type Config struct {
ServerURL string
Name string
Hostname string
IPAddress string
DockerVersion string
HeartbeatInterval time.Duration
}
// DefaultConfig retourne une configuration par défaut
func DefaultConfig() Config {
hostname, _ := os.Hostname()
return Config{
ServerURL: "http://localhost:8000",
Name: "",
Hostname: hostname,
IPAddress: "127.0.0.1", // À remplacer par l'adresse IP réelle
DockerVersion: "unknown",
HeartbeatInterval: 30 * time.Second,
}
}
// Validate vérifie que la configuration est valide
func (c *Config) Validate() error {
if c.Name == "" {
return ErrNameRequired
}
if c.ServerURL == "" {
return ErrServerURLRequired
}
return nil
}

View file

@ -0,0 +1,8 @@
package config
import "errors"
var (
ErrNameRequired = errors.New("le nom de l'agent est requis")
ErrServerURLRequired = errors.New("l'URL du serveur est requise")
)