Skip to content

Commit af9200d

Browse files
committed
remove the function HelperConfVars
1 parent 6180d82 commit af9200d

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

brcc-go-sdk/rcc.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package rcc
77

88
import (
9-
"bytes"
109
"context"
1110
"regexp"
1211

@@ -67,22 +66,22 @@ func GetAllKeys() []string {
6766
var osEnvVarReg = regexp.MustCompile(`\{rcc\.([A-Za-z0-9_\.]+)(\|[^}]+)?\}`)
6867

6968
// HelperConfVars 将配置文件中的 {rcc.xxx} 的内容,从rcc变量中读取并替换
70-
func HelperConfVars(content []byte) ([]byte, error) {
71-
contentNew := osEnvVarReg.ReplaceAllFunc(content, func(subStr []byte) []byte {
72-
// 将 {rcc.xxx} 中的 xxx 部分取出
73-
// 或者 将 {rcc.yyy|val} 中的 yyy|val 部分取出
74-
75-
keyWithDefaultVal := subStr[len("{rcc.") : len(subStr)-1] // eg: xxx 或者 yyy|val
76-
idx := bytes.Index(keyWithDefaultVal, []byte("|"))
77-
if idx > 0 {
78-
// {env.变量名|默认值} 有默认值的格式
79-
key := string(keyWithDefaultVal[:idx]) // eg: yyy
80-
defaultVal := keyWithDefaultVal[idx+1:] // eg: val
81-
return []byte(GetValue(key, string(defaultVal)))
82-
}
83-
84-
// {env.变量名} 无默认值的部分
85-
return []byte(GetValue(string(keyWithDefaultVal), ""))
86-
})
87-
return contentNew, nil
88-
}
69+
//func HelperConfVars(content []byte) ([]byte, error) {
70+
// contentNew := osEnvVarReg.ReplaceAllFunc(content, func(subStr []byte) []byte {
71+
// // 将 {rcc.xxx} 中的 xxx 部分取出
72+
// // 或者 将 {rcc.yyy|val} 中的 yyy|val 部分取出
73+
//
74+
// keyWithDefaultVal := subStr[len("{rcc.") : len(subStr)-1] // eg: xxx 或者 yyy|val
75+
// idx := bytes.Index(keyWithDefaultVal, []byte("|"))
76+
// if idx > 0 {
77+
// // {env.变量名|默认值} 有默认值的格式
78+
// key := string(keyWithDefaultVal[:idx]) // eg: yyy
79+
// defaultVal := keyWithDefaultVal[idx+1:] // eg: val
80+
// return []byte(GetValue(key, string(defaultVal)))
81+
// }
82+
//
83+
// // {env.变量名} 无默认值的部分
84+
// return []byte(GetValue(string(keyWithDefaultVal), ""))
85+
// })
86+
// return contentNew, nil
87+
//}

0 commit comments

Comments
 (0)