From 4a8d37bde1f4b317ab2e8b2800b3749b90666148 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 11 Apr 2022 16:18:36 +0800 Subject: [PATCH] getui --- config/config.yaml | 2 ++ internal/api/third/minio_init.go | 9 ++++++++- pkg/common/config/config.go | 12 +++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index da30523d0..c78611634 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -93,6 +93,8 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 bucket: openim location: us-east-1 endpoint: http://127.0.0.1:9000 + endpointInner: http://127.0.0.1:9000 #minio内网地址 + endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问 accessKeyID: user12345 secretAccessKey: key12345 ali: # ali oss diff --git a/internal/api/third/minio_init.go b/internal/api/third/minio_init.go index 23ad88405..b3d66b934 100644 --- a/internal/api/third/minio_init.go +++ b/internal/api/third/minio_init.go @@ -17,7 +17,14 @@ var ( func MinioInit() { operationID := utils.OperationIDGenerator() log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio) - minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint) + var initUrl string + if config.Config.Credential.Minio.EndpointInnerEnable { + initUrl = config.Config.Credential.Minio.EndpointInner + } else { + initUrl = config.Config.Credential.Minio.Endpoint + } + log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl) + minioUrl, err := url2.Parse(initUrl) if err != nil { log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error()) return diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index b497ee268..4cc5fed27 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -56,11 +56,13 @@ type config struct { OssRoleArn string `yaml:"OssRoleArn"` } Minio struct { - Bucket string `yaml:"bucket"` - Location string `yaml:"location"` - Endpoint string `yaml:"endpoint"` - AccessKeyID string `yaml:"accessKeyID"` - SecretAccessKey string `yaml:"secretAccessKey"` + Bucket string `yaml:"bucket"` + Location string `yaml:"location"` + Endpoint string `yaml:"endpoint"` + AccessKeyID string `yaml:"accessKeyID"` + SecretAccessKey string `yaml:"secretAccessKey"` + EndpointInner string `yaml:"endpointInner"` + EndpointInnerEnable bool `yaml:"endpointInnerEnable"` } `yaml:"minio"` }