Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
KubeSphere
kubesphere
提交
6fbaedfa
K
kubesphere
项目概览
KubeSphere
/
kubesphere
通知
143
Star
32
Fork
5
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6fbaedfa
编写于
3月 22, 2021
作者:
K
KubeSphere CI Bot
提交者:
GitHub
3月 22, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3524 from LinuxSuRen/set-default-weather-score
Set default value of weatherScore to 100
上级
fb2db3e1
727dffff
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
50 addition
and
3 deletion
+50
-3
pkg/simple/client/devops/jenkins/pipeline.go
pkg/simple/client/devops/jenkins/pipeline.go
+2
-3
pkg/simple/client/devops/pipeline.go
pkg/simple/client/devops/pipeline.go
+12
-0
pkg/simple/client/devops/pipeline_test.go
pkg/simple/client/devops/pipeline_test.go
+36
-0
未找到文件。
pkg/simple/client/devops/jenkins/pipeline.go
浏览文件 @
6fbaedfa
...
@@ -122,13 +122,12 @@ func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
...
@@ -122,13 +122,12 @@ func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
return
nil
,
err
return
nil
,
err
}
}
pipelienList
:=
devops
.
PipelineList
{
Total
:
count
}
pipelienList
,
err
:=
devops
.
UnmarshalPipeline
(
count
,
res
)
err
=
json
.
Unmarshal
(
res
,
&
pipelienList
.
Items
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
pipelienList
,
err
return
pipelienList
,
err
}
}
func
(
p
*
Pipeline
)
searchPipelineCount
()
(
int
,
error
)
{
func
(
p
*
Pipeline
)
searchPipelineCount
()
(
int
,
error
)
{
...
...
pkg/simple/client/devops/pipeline.go
浏览文件 @
6fbaedfa
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
devops
package
devops
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"io"
"io"
"net/http"
"net/http"
...
@@ -97,6 +98,17 @@ type Pipeline struct {
...
@@ -97,6 +98,17 @@ type Pipeline struct {
TotalNumberOfPullRequests
int
`json:"totalNumberOfPullRequests,omitempty" description:"total number of pull requests"`
TotalNumberOfPullRequests
int
`json:"totalNumberOfPullRequests,omitempty" description:"total number of pull requests"`
}
}
// UnmarshalPipeline unmarshal data into the Pipeline list
func
UnmarshalPipeline
(
total
int
,
data
[]
byte
)
(
pipelineList
*
PipelineList
,
err
error
)
{
pipelineList
=
&
PipelineList
{
Total
:
total
}
pipelineList
.
Items
=
make
([]
Pipeline
,
total
)
for
i
,
_
:=
range
pipelineList
.
Items
{
pipelineList
.
Items
[
i
]
.
WeatherScore
=
100
}
err
=
json
.
Unmarshal
(
data
,
&
pipelineList
.
Items
)
return
}
// GetPipeBranchRun & SearchPipelineRuns
// GetPipeBranchRun & SearchPipelineRuns
type
PipelineRunList
struct
{
type
PipelineRunList
struct
{
Items
[]
PipelineRun
`json:"items"`
Items
[]
PipelineRun
`json:"items"`
...
...
pkg/simple/client/devops/pipeline_test.go
浏览文件 @
6fbaedfa
package
devops
package
devops
import
(
import
(
"fmt"
"gotest.tools/assert"
"gotest.tools/assert"
"testing"
"testing"
)
)
...
@@ -32,3 +33,38 @@ func TestApprovable(t *testing.T) {
...
@@ -32,3 +33,38 @@ func TestApprovable(t *testing.T) {
assert
.
Equal
(
t
,
input
.
Approvable
(
"good"
),
true
,
"should be approvable"
)
assert
.
Equal
(
t
,
input
.
Approvable
(
"good"
),
true
,
"should be approvable"
)
assert
.
Equal
(
t
,
input
.
Approvable
(
"bad"
),
true
,
"should be approvable"
)
assert
.
Equal
(
t
,
input
.
Approvable
(
"bad"
),
true
,
"should be approvable"
)
}
}
func
TestPipelineJsonMarshall
(
t
*
testing
.
T
)
{
const
name
=
"fakeName"
var
err
error
var
pipelineText
string
var
pipelienList
*
PipelineList
pipelineText
=
fmt
.
Sprintf
(
`[{"displayName":"%s", "weatherScore": 11}]`
,
name
)
pipelienList
,
err
=
UnmarshalPipeline
(
1
,
[]
byte
(
pipelineText
))
assert
.
NilError
(
t
,
err
,
"pipeline json marshal should be success"
)
assert
.
Equal
(
t
,
pipelienList
.
Total
,
1
)
assert
.
Equal
(
t
,
len
(
pipelienList
.
Items
),
1
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
DisplayName
,
name
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
WeatherScore
,
11
)
// test against the default value of weatherScore, it should be 100
pipelineText
=
fmt
.
Sprintf
(
`[{"displayName":"%s"}]`
,
name
)
pipelienList
,
err
=
UnmarshalPipeline
(
1
,
[]
byte
(
pipelineText
))
assert
.
NilError
(
t
,
err
,
"pipeline json marshal should be success"
)
assert
.
Equal
(
t
,
pipelienList
.
Total
,
1
)
assert
.
Equal
(
t
,
len
(
pipelienList
.
Items
),
1
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
DisplayName
,
name
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
WeatherScore
,
100
)
// test against multiple items
pipelineText
=
fmt
.
Sprintf
(
`[{"displayName":"%s"}, {"displayName":"%s-1"}]`
,
name
,
name
)
pipelienList
,
err
=
UnmarshalPipeline
(
2
,
[]
byte
(
pipelineText
))
assert
.
NilError
(
t
,
err
,
"pipeline json marshal should be success"
)
assert
.
Equal
(
t
,
pipelienList
.
Total
,
2
)
assert
.
Equal
(
t
,
len
(
pipelienList
.
Items
),
2
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
DisplayName
,
name
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
0
]
.
WeatherScore
,
100
)
assert
.
Equal
(
t
,
pipelienList
.
Items
[
1
]
.
DisplayName
,
fmt
.
Sprintf
(
"%s-1"
,
name
))
assert
.
Equal
(
t
,
pipelienList
.
Items
[
1
]
.
WeatherScore
,
100
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录