package config import ( "fmt" ) // 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"` // 容器网络 Memory int64 `mapstructure:"memory"` // 内存限制 } // 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" } if c.Memory == 0 { c.Memory = 512 // 默认内存限制为512M } return nil }