1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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"`
- CallbackUri string `yaml:"callback-uri"`
- PlatformType string `yaml:"platform-type"`
- }
- var (
- //go:embed application.yaml
- applicationYamlBytes []byte
- ApplicationYaml ApplicationYamlStruct
- )
- func InitApplication() {
- _ = yaml.Unmarshal(applicationYamlBytes, &ApplicationYaml)
- fmt.Println("加载配置文件内容为:", ApplicationYaml)
- // 创建镜像下载目录
- util.CreateDir(ApplicationYaml.K8s.AlgorithmTarTempDir)
- }
|