package config import ( "fmt" ) // RedisConfig 是Redis相关配置 type RedisConfig struct { Host string `mapstructure:"host"` Password string `mapstructure:"password"` DB int `mapstructure:"db"` } // DockerConfig Docker配置 type DockerConfig struct { Host string `mapstructure:"host"` // Docker daemon 主机地址 APIVersion string `mapstructure:"apiVersion"` // Docker API版本 ImageName string `mapstructure:"imageName"` // 微信机器人Docker镜像名称 Network string `mapstructure:"network"` // 容器网络 Redis RedisConfig `mapstructure:"redis"` // Redis配置 } // Validate 验证Docker配置 func (c *DockerConfig) Validate() error { if c.ImageName == "" { return fmt.Errorf("docker image name cannot be empty") } // 如果没有指定Docker主机,则使用默认值 if c.Host == "" { c.Host = "unix:///var/run/docker.sock" } if c.Network == "" { c.Network = "bridge" } return nil }