2025-04-02 14:29:44 +08:00

40 lines
997 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}