i_application.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package infra
  2. import (
  3. "cicv-data-closedloop/common/util"
  4. _ "embed"
  5. "fmt"
  6. "gopkg.in/yaml.v2"
  7. )
  8. type ApplicationYamlStruct struct {
  9. ApplicationName string `yaml:"application-name"`
  10. Web WebStruct `yaml:"web"`
  11. Log LogStruct `yaml:"log"`
  12. Redis RedisStruct `yaml:"redis"`
  13. Kafka KafkaStruct `yaml:"kafka"`
  14. Oss OssStruct `yaml:"oss"`
  15. GpuNodeList []GpuNode `yaml:"gpu-node-list"`
  16. K8s K8sStruct `yaml:"k8s"`
  17. }
  18. type WebStruct struct {
  19. IpPrivate string `yaml:"ip-private"`
  20. Port string `yaml:"port"`
  21. RoutePrefix string `yaml:"route-prefix"`
  22. Token string `yaml:"token"`
  23. WhiteList []string `yaml:"white-list"`
  24. }
  25. type LogStruct struct {
  26. Dir string `yaml:"dir"`
  27. Prefix string `yaml:"prefix"`
  28. }
  29. type RedisStruct struct {
  30. Addr string `yaml:"addr"`
  31. Password string `yaml:"password"`
  32. Db int `yaml:"db"`
  33. }
  34. type KafkaStruct struct {
  35. Partition int32 `yaml:"partition"`
  36. Broker string `yaml:"broker"`
  37. }
  38. type OssStruct struct {
  39. Type string `yaml:"type"`
  40. IsUseCname bool `yaml:"is-use-cname"`
  41. Endpoint string `yaml:"endpoint"`
  42. AccessKeyId string `yaml:"access-key-id"`
  43. AccessKeySecret string `yaml:"access-key-secret"`
  44. BucketName string `yaml:"bucket-name"`
  45. }
  46. type GpuNode struct {
  47. Hostname string `yaml:"hostname"`
  48. Ip string `yaml:"ip"`
  49. Parallelism int64 `yaml:"parallelism"`
  50. }
  51. type K8sStruct struct {
  52. PodYamlDir string `yaml:"pod-yaml-dir"`
  53. VtdPodTemplateYaml string `yaml:"vtd-pod-template-yaml"`
  54. AlgorithmTarTempDir string `yaml:"algorithm-tar-temp-dir"`
  55. RegistryUri string `yaml:"registry-uri"`
  56. NamespaceName string `yaml:"namespace-name"`
  57. VtdImage string `yaml:"vtd-image"`
  58. VtdCommand string `yaml:"vtd-command"`
  59. }
  60. var (
  61. //go:embed application.yaml
  62. applicationYamlBytes []byte
  63. ApplicationYaml ApplicationYamlStruct
  64. )
  65. func InitApplication() {
  66. _ = yaml.Unmarshal(applicationYamlBytes, &ApplicationYaml)
  67. fmt.Println("加载配置文件内容为:", ApplicationYaml)
  68. // 创建镜像下载目录
  69. util.CreateDir(ApplicationYaml.K8s.AlgorithmTarTempDir)
  70. }