123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package infra
- import (
- "cicv-data-closedloop/common/util"
- _ "embed"
- "fmt"
- "gopkg.in/yaml.v2"
- )
- type ApplicationYamlStruct struct {
- ApplicationName string `yaml:"application-name"`
- Web WebStruct `yaml:"web"`
- Log LogStruct `yaml:"log"`
- Redis RedisStruct `yaml:"redis"`
- Kafka KafkaStruct `yaml:"kafka"`
- Oss OssStruct `yaml:"oss"`
- GpuNodeList []GpuNode `yaml:"gpu-node-list"`
- K8s K8sStruct `yaml:"k8s"`
- }
- type WebStruct struct {
- IpPrivate string `yaml:"ip-private"`
- Port string `yaml:"port"`
- RoutePrefix string `yaml:"route-prefix"`
- Token string `yaml:"token"`
- WhiteList []string `yaml:"white-list"`
- }
- type LogStruct struct {
- Dir string `yaml:"dir"`
- Prefix string `yaml:"prefix"`
- }
- type RedisStruct struct {
- Addr string `yaml:"addr"`
- Password string `yaml:"password"`
- Db int `yaml:"db"`
- }
- type KafkaStruct struct {
- Partition int32 `yaml:"partition"`
- Broker string `yaml:"broker"`
- }
- type OssStruct struct {
- Type string `yaml:"type"`
- IsUseCname bool `yaml:"is-use-cname"`
- Endpoint string `yaml:"endpoint"`
- AccessKeyId string `yaml:"access-key-id"`
- AccessKeySecret string `yaml:"access-key-secret"`
- BucketName string `yaml:"bucket-name"`
- }
- type GpuNode struct {
- Hostname string `yaml:"hostname"`
- Ip string `yaml:"ip"`
- Parallelism int64 `yaml:"parallelism"`
- }
- type K8sStruct struct {
- PodYamlDir string `yaml:"pod-yaml-dir"`
- VtdPodTemplateYaml string `yaml:"vtd-pod-template-yaml"`
- AlgorithmTarTempDir string `yaml:"algorithm-tar-temp-dir"`
- RegistryUri string `yaml:"registry-uri"`
- NamespaceName string `yaml:"namespace-name"`
- VtdImage string `yaml:"vtd-image"`
- VtdCommand string `yaml:"vtd-command"`
- }
- var (
- //go:embed application.yaml
- applicationYamlBytes []byte
- ApplicationYaml ApplicationYamlStruct
- )
- func InitApplication() {
- _ = yaml.Unmarshal(applicationYamlBytes, &ApplicationYaml)
- fmt.Println("加载配置文件内容为:", ApplicationYaml)
- // 创建镜像下载目录
- util.CreateDir(ApplicationYaml.K8s.AlgorithmTarTempDir)
- }
|