From c613be6b3f0faa2e5f83561f8cef9ce258b0a51d Mon Sep 17 00:00:00 2001 From: SimFG Date: Wed, 14 Aug 2024 19:31:08 +0800 Subject: [PATCH] use the env config to replace the default value when connecting the etcd Signed-off-by: SimFG --- states/etcd_connect.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/states/etcd_connect.go b/states/etcd_connect.go index b8131af5..3352422d 100644 --- a/states/etcd_connect.go +++ b/states/etcd_connect.go @@ -91,7 +91,19 @@ func (s *disconnectState) getTLSConfig(cp *ConnectParams) (*tls.Config, error) { }, nil } +func (s *disconnectState) readEnv(cp *ConnectParams) { + if cp.EtcdAddr == "127.0.0.1:2379" && os.Getenv("MILVUS_ETCD_ADDR") != "" { + cp.EtcdAddr = os.Getenv("MILVUS_ETCD_ADDR") + fmt.Println("using env MILVUS_ETCD_ADDR,", cp.EtcdAddr) + } + if cp.RootPath == "by-dev" && os.Getenv("MILVUS_ROOT_PATH") != "" { + cp.RootPath = os.Getenv("MILVUS_ROOT_PATH") + fmt.Println("using env MILVUS_ROOT_PATH,", cp.RootPath) + } +} + func (s *disconnectState) ConnectCommand(ctx context.Context, cp *ConnectParams) error { + s.readEnv(cp) tls, err := s.getTLSConfig(cp) if err != nil { return errors.Wrap(err, "failed to load tls certificates")