Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
24c06da9
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
24c06da9
编写于
7月 22, 2020
作者:
Z
zryfish
提交者:
GitHub
7月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix cronjob sort bug, daemonsets status bug, add ingress to v1alpha3 (#2541)
Signed-off-by:
N
Jeff
<
zw0948@gmail.com
>
上级
1096eb8a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
236 addition
and
7 deletion
+236
-7
pkg/models/resources/v1alpha2/cronjob/cronjobs.go
pkg/models/resources/v1alpha2/cronjob/cronjobs.go
+7
-3
pkg/models/resources/v1alpha2/interface.go
pkg/models/resources/v1alpha2/interface.go
+5
-2
pkg/models/resources/v1alpha3/daemonset/daemonset.go
pkg/models/resources/v1alpha3/daemonset/daemonset.go
+23
-1
pkg/models/resources/v1alpha3/deployment/deployments.go
pkg/models/resources/v1alpha3/deployment/deployments.go
+0
-1
pkg/models/resources/v1alpha3/ingress/ingresses.go
pkg/models/resources/v1alpha3/ingress/ingresses.go
+85
-0
pkg/models/resources/v1alpha3/ingress/ingresses_test.go
pkg/models/resources/v1alpha3/ingress/ingresses_test.go
+114
-0
pkg/models/resources/v1alpha3/resource/resource.go
pkg/models/resources/v1alpha3/resource/resource.go
+2
-0
未找到文件。
pkg/models/resources/v1alpha2/cronjob/cronjobs.go
浏览文件 @
24c06da9
...
...
@@ -106,12 +106,16 @@ func (c *cronJobSearcher) Search(namespace string, conditions *params.Conditions
}
}
sort
.
Slice
(
result
,
func
(
i
,
j
int
)
bool
{
return
c
.
compare
(
result
[
i
],
result
[
j
],
orderBy
)
&&
!
reverse
if
reverse
{
return
!
c
.
compare
(
result
[
i
],
result
[
j
],
orderBy
)
}
else
{
return
c
.
compare
(
result
[
i
],
result
[
j
],
orderBy
)
}
})
r
:=
make
([]
interface
{},
0
)
for
_
,
i
:=
range
result
{
r
=
append
(
r
,
i
)
for
i
:=
range
result
{
r
=
append
(
r
,
result
[
i
]
)
}
return
r
,
nil
}
pkg/models/resources/v1alpha2/interface.go
浏览文件 @
24c06da9
...
...
@@ -140,8 +140,11 @@ func FuzzyMatch(m map[string]string, key, value string) bool {
func
ObjectMetaCompare
(
left
,
right
metav1
.
ObjectMeta
,
compareField
string
)
bool
{
switch
compareField
{
case
CreateTime
:
if
left
.
CreationTimestamp
.
Equal
(
&
right
.
CreationTimestamp
)
{
return
strings
.
Compare
(
left
.
Name
,
right
.
Name
)
<=
0
if
left
.
CreationTimestamp
.
Time
.
Equal
(
right
.
CreationTimestamp
.
Time
)
{
if
left
.
Namespace
==
right
.
Namespace
{
return
strings
.
Compare
(
left
.
Name
,
right
.
Name
)
<
0
}
return
strings
.
Compare
(
left
.
Namespace
,
right
.
Namespace
)
<
0
}
return
left
.
CreationTimestamp
.
Time
.
Before
(
right
.
CreationTimestamp
.
Time
)
case
Name
:
...
...
pkg/models/resources/v1alpha3/daemonset/daemonset.go
浏览文件 @
24c06da9
...
...
@@ -23,6 +23,13 @@ import (
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"strings"
)
const
(
statusStopped
=
"stopped"
statusRunning
=
"running"
statusUpdating
=
"updating"
)
type
daemonSetGetter
struct
{
...
...
@@ -72,5 +79,20 @@ func (d *daemonSetGetter) filter(object runtime.Object, filter query.Filter) boo
if
!
ok
{
return
false
}
return
v1alpha3
.
DefaultObjectMetaFilter
(
daemonSet
.
ObjectMeta
,
filter
)
switch
filter
.
Field
{
case
query
.
FieldStatus
:
return
strings
.
Compare
(
daemonsetStatus
(
&
daemonSet
.
Status
),
string
(
filter
.
Value
))
==
0
default
:
return
v1alpha3
.
DefaultObjectMetaFilter
(
daemonSet
.
ObjectMeta
,
filter
)
}
}
func
daemonsetStatus
(
status
*
appsv1
.
DaemonSetStatus
)
string
{
if
status
.
DesiredNumberScheduled
==
0
&&
status
.
NumberReady
==
0
{
return
statusStopped
}
else
if
status
.
DesiredNumberScheduled
==
status
.
NumberReady
{
return
statusRunning
}
else
{
return
statusUpdating
}
}
pkg/models/resources/v1alpha3/deployment/deployments.go
浏览文件 @
24c06da9
...
...
@@ -90,7 +90,6 @@ func (d *deploymentsGetter) filter(object runtime.Object, filter query.Filter) b
}
switch
filter
.
Field
{
case
query
.
FieldStatus
:
return
strings
.
Compare
(
deploymentStatus
(
deployment
.
Status
),
string
(
filter
.
Value
))
==
0
default
:
...
...
pkg/models/resources/v1alpha3/ingress/ingresses.go
0 → 100644
浏览文件 @
24c06da9
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
ingress
import
(
"k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
)
type
ingressGetter
struct
{
sharedInformers
informers
.
SharedInformerFactory
}
func
New
(
sharedInformers
informers
.
SharedInformerFactory
)
v1alpha3
.
Interface
{
return
&
ingressGetter
{
sharedInformers
:
sharedInformers
}
}
func
(
g
*
ingressGetter
)
Get
(
namespace
,
name
string
)
(
runtime
.
Object
,
error
)
{
return
g
.
sharedInformers
.
Extensions
()
.
V1beta1
()
.
Ingresses
()
.
Lister
()
.
Ingresses
(
namespace
)
.
Get
(
name
)
}
func
(
g
*
ingressGetter
)
List
(
namespace
string
,
query
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
{
// first retrieves all deployments within given namespace
ingresses
,
err
:=
g
.
sharedInformers
.
Extensions
()
.
V1beta1
()
.
Ingresses
()
.
Lister
()
.
Ingresses
(
namespace
)
.
List
(
query
.
Selector
())
if
err
!=
nil
{
return
nil
,
err
}
var
result
[]
runtime
.
Object
for
_
,
ingress
:=
range
ingresses
{
result
=
append
(
result
,
ingress
)
}
return
v1alpha3
.
DefaultList
(
result
,
query
,
g
.
compare
,
g
.
filter
),
nil
}
func
(
g
*
ingressGetter
)
compare
(
left
runtime
.
Object
,
right
runtime
.
Object
,
field
query
.
Field
)
bool
{
leftIngress
,
ok
:=
left
.
(
*
v1beta1
.
Ingress
)
if
!
ok
{
return
false
}
rightIngress
,
ok
:=
right
.
(
*
v1beta1
.
Ingress
)
if
!
ok
{
return
false
}
switch
field
{
case
query
.
FieldUpdateTime
:
fallthrough
default
:
return
v1alpha3
.
DefaultObjectMetaCompare
(
leftIngress
.
ObjectMeta
,
rightIngress
.
ObjectMeta
,
field
)
}
}
func
(
g
*
ingressGetter
)
filter
(
object
runtime
.
Object
,
filter
query
.
Filter
)
bool
{
deployment
,
ok
:=
object
.
(
*
v1beta1
.
Ingress
)
if
!
ok
{
return
false
}
switch
filter
.
Field
{
default
:
return
v1alpha3
.
DefaultObjectMetaFilter
(
deployment
.
ObjectMeta
,
filter
)
}
}
pkg/models/resources/v1alpha3/ingress/ingresses_test.go
0 → 100644
浏览文件 @
24c06da9
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
ingress
import
(
"github.com/google/go-cmp/cmp"
"k8s.io/api/extensions/v1beta1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"testing"
)
func
TestListIngresses
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
description
string
namespace
string
query
*
query
.
Query
expected
*
api
.
ListResult
expectedErr
error
}{
{
"test name filter"
,
"bar"
,
&
query
.
Query
{
Pagination
:
&
query
.
Pagination
{
Limit
:
1
,
Offset
:
0
,
},
SortBy
:
query
.
FieldName
,
Ascending
:
false
,
Filters
:
map
[
query
.
Field
]
query
.
Value
{
query
.
FieldName
:
query
.
Value
(
"foo2"
)},
},
&
api
.
ListResult
{
Items
:
[]
interface
{}{
foo2
,
},
TotalItems
:
1
,
},
nil
,
},
}
getter
:=
prepare
()
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
description
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
getter
.
List
(
test
.
namespace
,
test
.
query
)
if
test
.
expectedErr
!=
nil
&&
err
!=
test
.
expectedErr
{
t
.
Errorf
(
"expected error, got nothing"
)
}
else
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
diff
:=
cmp
.
Diff
(
got
,
test
.
expected
);
diff
!=
""
{
t
.
Errorf
(
"%T differ (-got, +want): %s"
,
test
.
expected
,
diff
)
}
})
}
}
var
(
foo1
=
&
v1beta1
.
Ingress
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo1"
,
Namespace
:
"bar"
,
},
}
foo2
=
&
v1beta1
.
Ingress
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo2"
,
Namespace
:
"bar"
,
},
}
bar1
=
&
v1beta1
.
Ingress
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar1"
,
Namespace
:
"bar"
,
},
}
ingresses
=
[]
interface
{}{
foo1
,
foo2
,
bar1
}
)
func
prepare
()
v1alpha3
.
Interface
{
client
:=
fake
.
NewSimpleClientset
()
informer
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
for
_
,
ingress
:=
range
ingresses
{
informer
.
Extensions
()
.
V1beta1
()
.
Ingresses
()
.
Informer
()
.
GetIndexer
()
.
Add
(
ingress
)
}
return
New
(
informer
)
}
pkg/models/resources/v1alpha3/resource/resource.go
浏览文件 @
24c06da9
...
...
@@ -43,6 +43,7 @@ import (
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/federatednamespace"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/globalrole"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/globalrolebinding"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/ingress"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/namespace"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/networkpolicy"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/node"
...
...
@@ -77,6 +78,7 @@ func NewResourceGetter(factory informers.InformerFactory) *ResourceGetter {
getters
[
schema
.
GroupVersionResource
{
Group
:
""
,
Version
:
"v1"
,
Resource
:
"configmaps"
}]
=
configmap
.
New
(
factory
.
KubernetesSharedInformerFactory
())
getters
[
schema
.
GroupVersionResource
{
Group
:
""
,
Version
:
"v1"
,
Resource
:
"pods"
}]
=
pod
.
New
(
factory
.
KubernetesSharedInformerFactory
())
getters
[
schema
.
GroupVersionResource
{
Group
:
""
,
Version
:
"v1"
,
Resource
:
"nodes"
}]
=
node
.
New
(
factory
.
KubernetesSharedInformerFactory
())
getters
[
schema
.
GroupVersionResource
{
Group
:
"extensions"
,
Version
:
"v1beta1"
,
Resource
:
"ingresses"
}]
=
ingress
.
New
(
factory
.
KubernetesSharedInformerFactory
())
getters
[
schema
.
GroupVersionResource
{
Group
:
"app.k8s.io"
,
Version
:
"v1beta1"
,
Resource
:
"applications"
}]
=
application
.
New
(
factory
.
ApplicationSharedInformerFactory
())
getters
[
schema
.
GroupVersionResource
{
Group
:
"networking.k8s.io"
,
Version
:
"v1"
,
Resource
:
"networkpolicies"
}]
=
networkpolicy
.
New
(
factory
.
KubernetesSharedInformerFactory
())
getters
[
devopsv1alpha3
.
SchemeGroupVersion
.
WithResource
(
devopsv1alpha3
.
ResourcePluralDevOpsProject
)]
=
devops
.
New
(
factory
.
KubeSphereSharedInformerFactory
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录