Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
3acd6fef
Z
zendata
项目概览
易企天创
/
zendata
大约 1 年 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3acd6fef
编写于
3月 12, 2021
作者:
陈
陈琦
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issue of load res from file path
上级
babe2895
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
53 deletion
+23
-53
.zd.conf
.zd.conf
+1
-1
src/gen/list.go
src/gen/list.go
+1
-1
src/gen/res.go
src/gen/res.go
+3
-2
src/gen/text.go
src/gen/text.go
+2
-1
src/utils/file/file.go
src/utils/file/file.go
+10
-4
src/zd.go
src/zd.go
+3
-3
test/test-apache-log.yaml
test/test-apache-log.yaml
+3
-41
未找到文件。
.zd.conf
浏览文件 @
3acd6fef
Version
=
1
.
8
Version
=
1
.
8
Language
=
zh
src/gen/list.go
浏览文件 @
3acd6fef
...
...
@@ -268,7 +268,7 @@ func CreateValuesFromYaml(field *model.DefField, yamlFile, stepStr string, repea
configDir
:=
vari
.
ConfigFileDir
res
:=
vari
.
Res
configFile
:=
fileUtils
.
ComputerReferFilePath
(
yamlFile
)
configFile
:=
fileUtils
.
ComputerReferFilePath
(
yamlFile
,
nil
)
fieldsToExport
:=
make
([]
string
,
0
)
// set to empty to use all fields
rows
,
colIsNumArr
,
_
:=
GenerateOnTopLevel
(
""
,
configFile
,
&
fieldsToExport
)
if
field
.
Rand
{
...
...
src/gen/res.go
浏览文件 @
3acd6fef
...
...
@@ -145,9 +145,9 @@ func getResFromInstances(insts model.ResInstances) (groupedValue map[string][]st
}
// gen values
field
:=
convertInstantToField
(
insts
,
inst
)
field
FromInsts
:=
convertInstantToField
(
insts
,
inst
)
group
:=
inst
.
Instance
groupedValue
[
group
]
=
GenerateForField
(
&
field
,
false
)
groupedValue
[
group
]
=
GenerateForField
(
&
field
FromInsts
,
false
)
}
return
groupedValue
...
...
@@ -251,6 +251,7 @@ func convertInstantToField(insts model.ResInstances, inst model.ResInstancesItem
copier
.
Copy
(
&
child
,
inst
)
field
.
Fields
=
append
(
field
.
Fields
,
child
)
field
.
FileDir
=
insts
.
FileDir
return
field
}
...
...
src/gen/text.go
浏览文件 @
3acd6fef
...
...
@@ -16,6 +16,7 @@ import (
func
CreateFieldValuesFromText
(
field
*
model
.
DefField
,
fieldValue
*
model
.
FieldWithValues
)
{
ranges
:=
strings
.
Split
(
strings
.
TrimSpace
(
field
.
Range
),
","
)
for
_
,
rang
:=
range
ranges
{
rang
=
strings
.
TrimSpace
(
rang
)
repeat
,
repeatTag
,
rangWithoutRepeat
:=
ParseRepeat
(
rang
)
...
...
@@ -30,7 +31,7 @@ func CreateFieldValuesFromText(field *model.DefField, fieldValue *model.FieldWit
// read from file
list
:=
make
([]
string
,
0
)
realPath
:=
fileUtils
.
ComputerReferFilePath
(
file
)
realPath
:=
fileUtils
.
ComputerReferFilePath
(
file
,
field
)
content
,
err
:=
ioutil
.
ReadFile
(
realPath
)
if
err
!=
nil
{
logUtils
.
PrintTo
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_read_file"
,
file
+
" - "
+
realPath
))
...
...
src/utils/file/file.go
浏览文件 @
3acd6fef
...
...
@@ -2,6 +2,7 @@ package fileUtils
import
(
"github.com/easysoft/zendata/res"
"github.com/easysoft/zendata/src/model"
commonUtils
"github.com/easysoft/zendata/src/utils/common"
constant
"github.com/easysoft/zendata/src/utils/const"
i118Utils
"github.com/easysoft/zendata/src/utils/i118"
...
...
@@ -312,9 +313,14 @@ func ConvertResExcelPath(from, dir string) (ret, sheet string) {
return
}
func
ComputerReferFilePath
(
file
string
)
(
resPath
string
)
{
func
ComputerReferFilePath
(
file
string
,
field
*
model
.
DefField
)
(
resPath
string
)
{
resPath
=
file
if
filepath
.
IsAbs
(
resPath
)
&&
FileExist
(
resPath
)
{
if
IsAbsPath
(
resPath
)
&&
FileExist
(
resPath
)
{
return
}
resPath
=
field
.
FileDir
+
file
if
FileExist
(
resPath
)
{
return
}
...
...
@@ -328,11 +334,11 @@ func ComputerReferFilePath(file string) (resPath string) {
return
}
resPath
=
vari
.
ZdPath
+
constant
.
ResDir
Yaml
+
constant
.
PthSep
+
file
resPath
=
vari
.
ZdPath
+
constant
.
ResDir
Users
+
constant
.
PthSep
+
file
if
FileExist
(
resPath
)
{
return
}
resPath
=
vari
.
ZdPath
+
constant
.
ResDir
Users
+
constant
.
PthSep
+
file
resPath
=
vari
.
ZdPath
+
constant
.
ResDir
Yaml
+
constant
.
PthSep
+
file
if
FileExist
(
resPath
)
{
return
}
...
...
src/zd.go
浏览文件 @
3acd6fef
...
...
@@ -204,7 +204,7 @@ func main() {
func
toGen
()
{
tmStart
:=
time
.
Now
()
if
vari
.
Verbose
{
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"Start at %s"
,
tmStart
.
Format
(
"2006-01-02 15:04:05"
)))
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"Start at %s
.
"
,
tmStart
.
Format
(
"2006-01-02 15:04:05"
)))
}
if
vari
.
RunMode
==
constant
.
RunModeServer
{
...
...
@@ -256,10 +256,10 @@ func toGen() {
tmEnd
:=
time
.
Now
()
if
vari
.
Verbose
{
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"End at %s"
,
tmEnd
.
Format
(
"2006-01-02 15:04:05"
)))
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"End at %s
.
"
,
tmEnd
.
Format
(
"2006-01-02 15:04:05"
)))
dur
:=
tmEnd
.
Unix
()
-
tmStart
.
Unix
()
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"Duriation %d"
,
dur
))
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"Duriation %d
sec.
"
,
dur
))
}
}
...
...
test/test-apache-log.yaml
浏览文件 @
3acd6fef
...
...
@@ -2,45 +2,7 @@ title: test
desc
:
描述
version
:
1.0
fields
:
# 127.0.0.1 - - [10/Jan/2021:14:02:05 +0800] "GET /index.php HTTP/1.1" 200 1404 "-" "<AGENT>"
# - field: apache log
# from: log.apache.access.v1.yaml
# use: log
-
field
:
host
from
:
ip.v2.yaml
use
:
ipC{10},ipB{10},ipA{10}
postfix
:
"
-
-
"
-
field
:
date time
range
:
"
(-1W):60"
# 支持当前时间的运算,Y、M、D、W、h、m、s分别对应年、月、日、周、时、分、秒。
type
:
timestamp
# 月份、星期几的长、短格式,可用January、Jan、Monday、Mon字符串。
format
:
"
DD/Jan/YYYY:hh:mm:ss"
prefix
:
"
["
postfix
:
"
+0800]
"
-
field
:
request uri
range
:
yaml/log/uri.txt:R
prefix
:
'
"GET
/'
postfix
:
'
HTTP/1.1"
'
-
field
:
response code
range
:
200{50},404,500
postfix
:
"
"
rand
:
true
-
field
:
request size
range
:
100-1900:R{3},10000-99999{10}
postfix
:
"
"
rand
:
true
-
field
:
request-size
range
:
[]{
8
}
,
[
"
-"
]
# 空或-
postfix
:
"
"
rand
:
true
-
field
:
agent
range
:
yaml/log/agent.txt:R
prefix
:
'
"'
postfix
:
'
"'
\ No newline at end of file
-
field
:
apache log
from
:
log.apache.access.v1.yaml
use
:
log
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录