Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
c40d1542
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看板
未验证
提交
c40d1542
编写于
1月 04, 2020
作者:
Z
zryfish
提交者:
GitHub
1月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor code structure (#1738)
上级
eceadec6
变更
49
隐藏空白更改
内联
并排
Showing
49 changed file
with
692 addition
and
449 deletion
+692
-449
pkg/api/types.go
pkg/api/types.go
+0
-12
pkg/api/utils.go
pkg/api/utils.go
+16
-0
pkg/apis/logging/v1alpha2/fluentbit_types.go
pkg/apis/logging/v1alpha2/fluentbit_types.go
+7
-0
pkg/apis/logging/v1alpha2/fluentbit_types_test.go
pkg/apis/logging/v1alpha2/fluentbit_types_test.go
+1
-0
pkg/apis/logging/v1alpha2/v1alpha2_suite_test.go
pkg/apis/logging/v1alpha2/v1alpha2_suite_test.go
+1
-0
pkg/apiserver/openpitrix/applications.go
pkg/apiserver/openpitrix/applications.go
+3
-3
pkg/apiserver/openpitrix/apps.go
pkg/apiserver/openpitrix/apps.go
+31
-30
pkg/apiserver/openpitrix/attachments.go
pkg/apiserver/openpitrix/attachments.go
+8
-8
pkg/apiserver/openpitrix/categories.go
pkg/apiserver/openpitrix/categories.go
+12
-10
pkg/apiserver/openpitrix/repos.go
pkg/apiserver/openpitrix/repos.go
+14
-13
pkg/apiserver/terminal/terminal.go
pkg/apiserver/terminal/terminal.go
+0
-50
pkg/apiserver/workspaces/workspaces.go
pkg/apiserver/workspaces/workspaces.go
+0
-18
pkg/kapis/devops/v1alpha2/handler.go
pkg/kapis/devops/v1alpha2/handler.go
+1
-0
pkg/kapis/iam/v1alpha2/handler.go
pkg/kapis/iam/v1alpha2/handler.go
+1
-0
pkg/kapis/logging/v1alpha2/handler.go
pkg/kapis/logging/v1alpha2/handler.go
+1
-0
pkg/kapis/openpitrix/v1/handler.go
pkg/kapis/openpitrix/v1/handler.go
+65
-3
pkg/kapis/openpitrix/v1/register.go
pkg/kapis/openpitrix/v1/register.go
+28
-27
pkg/kapis/resources/v1alpha3/handler.go
pkg/kapis/resources/v1alpha3/handler.go
+2
-2
pkg/kapis/servicemesh/metrics/v1alpha2/handler.go
pkg/kapis/servicemesh/metrics/v1alpha2/handler.go
+1
-0
pkg/kapis/tenant/v1alpha2/handler.go
pkg/kapis/tenant/v1alpha2/handler.go
+1
-0
pkg/kapis/terminal/install/install.go
pkg/kapis/terminal/install/install.go
+1
-1
pkg/kapis/terminal/v1alpha2/handler.go
pkg/kapis/terminal/v1alpha2/handler.go
+43
-0
pkg/kapis/terminal/v1alpha2/register.go
pkg/kapis/terminal/v1alpha2/register.go
+10
-11
pkg/models/log/logcrd.go
pkg/models/log/logcrd.go
+19
-19
pkg/models/log/types.go
pkg/models/log/types.go
+0
-6
pkg/models/openpitrix/app/apps.go
pkg/models/openpitrix/app/apps.go
+27
-25
pkg/models/openpitrix/application/applications.go
pkg/models/openpitrix/application/applications.go
+13
-11
pkg/models/openpitrix/attachment/attachments.go
pkg/models/openpitrix/attachment/attachments.go
+5
-3
pkg/models/openpitrix/category/categories.go
pkg/models/openpitrix/category/categories.go
+10
-8
pkg/models/openpitrix/repo/repos.go
pkg/models/openpitrix/repo/repos.go
+14
-12
pkg/models/openpitrix/types/types.go
pkg/models/openpitrix/types/types.go
+1
-1
pkg/models/openpitrix/utils/convert.go
pkg/models/openpitrix/utils/convert.go
+39
-38
pkg/models/resources/v1alpha2/application/appplications.go
pkg/models/resources/v1alpha2/application/appplications.go
+1
-3
pkg/models/resources/v1alpha3/deployment/deployments.go
pkg/models/resources/v1alpha3/deployment/deployments.go
+8
-6
pkg/models/resources/v1alpha3/deployment/deployments_test.go
pkg/models/resources/v1alpha3/deployment/deployments_test.go
+0
-1
pkg/models/resources/v1alpha3/interface.go
pkg/models/resources/v1alpha3/interface.go
+54
-6
pkg/models/resources/v1alpha3/namespace/namespaces.go
pkg/models/resources/v1alpha3/namespace/namespaces.go
+75
-0
pkg/models/resources/v1alpha3/namespace/namespaces_test.go
pkg/models/resources/v1alpha3/namespace/namespaces_test.go
+1
-0
pkg/models/resources/v1alpha3/resource/resource.go
pkg/models/resources/v1alpha3/resource/resource.go
+4
-44
pkg/models/terminal/terminal.go
pkg/models/terminal/terminal.go
+20
-12
pkg/simple/client/cache/cache.go
pkg/simple/client/cache/cache.go
+1
-38
pkg/simple/client/cache/simple_cache.go
pkg/simple/client/cache/simple_cache.go
+40
-0
pkg/simple/client/devops/interface.go
pkg/simple/client/devops/interface.go
+1
-0
pkg/simple/client/monitoring/interface.go
pkg/simple/client/monitoring/interface.go
+39
-0
pkg/simple/client/monitoring/prometheus.go
pkg/simple/client/monitoring/prometheus.go
+31
-0
pkg/simple/client/monitoring/prometheus_options.go
pkg/simple/client/monitoring/prometheus_options.go
+41
-0
pkg/simple/client/monitoring/prometheus_test.go
pkg/simple/client/monitoring/prometheus_test.go
+1
-0
pkg/simple/client/prometheus/prometheus.go
pkg/simple/client/prometheus/prometheus.go
+0
-2
pkg/simple/client/s3/s3.go
pkg/simple/client/s3/s3.go
+0
-26
未找到文件。
pkg/api/types.go
浏览文件 @
c40d1542
package
api
package
api
import
(
import
(
"github.com/emicklei/go-restful"
corev1
"k8s.io/api/core/v1"
corev1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"net/http"
)
)
type
ListResult
struct
{
type
ListResult
struct
{
...
@@ -158,13 +156,3 @@ const (
...
@@ -158,13 +156,3 @@ const (
ResourceKindS2iBuilder
=
"s2ibuilders"
ResourceKindS2iBuilder
=
"s2ibuilders"
ResourceKindApplication
=
"applications"
ResourceKindApplication
=
"applications"
)
)
func
HandleInternalError
(
response
*
restful
.
Response
,
err
error
)
{
statusCode
:=
http
.
StatusInternalServerError
response
.
WriteError
(
statusCode
,
err
)
}
func
HandleBadRequest
(
response
*
restful
.
Response
,
err
error
)
{
}
pkg/api/utils.go
0 → 100644
浏览文件 @
c40d1542
package
api
import
(
"github.com/emicklei/go-restful"
"net/http"
)
func
HandleInternalError
(
response
*
restful
.
Response
,
err
error
)
{
statusCode
:=
http
.
StatusInternalServerError
response
.
WriteError
(
statusCode
,
err
)
}
func
HandleBadRequest
(
response
*
restful
.
Response
,
err
error
)
{
}
pkg/apis/logging/v1alpha2/fluentbit_types.go
浏览文件 @
c40d1542
...
@@ -69,3 +69,10 @@ type FluentBitList struct {
...
@@ -69,3 +69,10 @@ type FluentBitList struct {
metav1
.
ListMeta
`json:"metadata"`
metav1
.
ListMeta
`json:"metadata"`
Items
[]
FluentBit
`json:"items"`
Items
[]
FluentBit
`json:"items"`
}
}
type
FluentbitOutputsResult
struct
{
Status
int
`json:"status" description:"response status"`
Error
string
`json:"error,omitempty" description:"debug information"`
Outputs
[]
OutputPlugin
`json:"outputs,omitempty" description:"array of fluent bit output plugins"`
}
\ No newline at end of file
pkg/apis/logging/v1alpha2/fluentbit_types_test.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/apis/logging/v1alpha2/v1alpha2_suite_test.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/apiserver/openpitrix/applications.go
浏览文件 @
c40d1542
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/models/openpitrix
/type
"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha2"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha2"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
...
@@ -136,7 +136,7 @@ func DescribeApplication(req *restful.Request, resp *restful.Response) {
...
@@ -136,7 +136,7 @@ func DescribeApplication(req *restful.Request, resp *restful.Response) {
func
CreateApplication
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
CreateApplication
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
namespace
:=
req
.
PathParameter
(
"namespace"
)
namespace
:=
req
.
PathParameter
(
"namespace"
)
var
createClusterRequest
openpitrix
.
CreateClusterRequest
var
createClusterRequest
types
.
CreateClusterRequest
err
:=
req
.
ReadEntity
(
&
createClusterRequest
)
err
:=
req
.
ReadEntity
(
&
createClusterRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -159,7 +159,7 @@ func CreateApplication(req *restful.Request, resp *restful.Response) {
...
@@ -159,7 +159,7 @@ func CreateApplication(req *restful.Request, resp *restful.Response) {
}
}
func
ModifyApplication
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
ModifyApplication
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
modifyClusterAttributesRequest
openpitrix
.
ModifyClusterAttributesRequest
var
modifyClusterAttributesRequest
types
.
ModifyClusterAttributesRequest
clusterId
:=
req
.
PathParameter
(
"application"
)
clusterId
:=
req
.
PathParameter
(
"application"
)
namespaceName
:=
req
.
PathParameter
(
"namespace"
)
namespaceName
:=
req
.
PathParameter
(
"namespace"
)
err
:=
req
.
ReadEntity
(
&
modifyClusterAttributesRequest
)
err
:=
req
.
ReadEntity
(
&
modifyClusterAttributesRequest
)
...
...
pkg/apiserver/openpitrix/apps.go
浏览文件 @
c40d1542
...
@@ -24,7 +24,8 @@ import (
...
@@ -24,7 +24,8 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/models/openpitrix/app"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client"
...
@@ -37,7 +38,7 @@ func GetAppVersionPackage(req *restful.Request, resp *restful.Response) {
...
@@ -37,7 +38,7 @@ func GetAppVersionPackage(req *restful.Request, resp *restful.Response) {
appId
:=
req
.
PathParameter
(
"app"
)
appId
:=
req
.
PathParameter
(
"app"
)
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
result
,
err
:=
openpitrix
.
GetAppVersionPackage
(
appId
,
versionId
)
result
,
err
:=
app
.
GetAppVersionPackage
(
appId
,
versionId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -54,7 +55,7 @@ func GetAppVersionPackage(req *restful.Request, resp *restful.Response) {
...
@@ -54,7 +55,7 @@ func GetAppVersionPackage(req *restful.Request, resp *restful.Response) {
}
}
func
DoAppAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DoAppAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
doActionRequest
openpitrix
.
ActionRequest
var
doActionRequest
types
.
ActionRequest
err
:=
req
.
ReadEntity
(
&
doActionRequest
)
err
:=
req
.
ReadEntity
(
&
doActionRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -63,7 +64,7 @@ func DoAppAction(req *restful.Request, resp *restful.Response) {
...
@@ -63,7 +64,7 @@ func DoAppAction(req *restful.Request, resp *restful.Response) {
appId
:=
req
.
PathParameter
(
"app"
)
appId
:=
req
.
PathParameter
(
"app"
)
err
=
openpitrix
.
DoAppAction
(
appId
,
&
doActionRequest
)
err
=
app
.
DoAppAction
(
appId
,
&
doActionRequest
)
if
status
.
Code
(
err
)
==
codes
.
NotFound
{
if
status
.
Code
(
err
)
==
codes
.
NotFound
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotFound
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotFound
,
errors
.
Wrap
(
err
))
return
return
...
@@ -84,7 +85,7 @@ func DoAppAction(req *restful.Request, resp *restful.Response) {
...
@@ -84,7 +85,7 @@ func DoAppAction(req *restful.Request, resp *restful.Response) {
}
}
func
DoAppVersionAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DoAppVersionAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
doActionRequest
openpitrix
.
ActionRequest
var
doActionRequest
types
.
ActionRequest
err
:=
req
.
ReadEntity
(
&
doActionRequest
)
err
:=
req
.
ReadEntity
(
&
doActionRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -94,7 +95,7 @@ func DoAppVersionAction(req *restful.Request, resp *restful.Response) {
...
@@ -94,7 +95,7 @@ func DoAppVersionAction(req *restful.Request, resp *restful.Response) {
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
err
=
openpitrix
.
DoAppVersionAction
(
versionId
,
&
doActionRequest
)
err
=
app
.
DoAppVersionAction
(
versionId
,
&
doActionRequest
)
if
status
.
Code
(
err
)
==
codes
.
NotFound
{
if
status
.
Code
(
err
)
==
codes
.
NotFound
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotFound
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotFound
,
errors
.
Wrap
(
err
))
return
return
...
@@ -116,12 +117,12 @@ func DoAppVersionAction(req *restful.Request, resp *restful.Response) {
...
@@ -116,12 +117,12 @@ func DoAppVersionAction(req *restful.Request, resp *restful.Response) {
func
GetAppVersionFiles
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
GetAppVersionFiles
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
getAppVersionFilesRequest
:=
&
openpitrix
.
GetAppVersionFilesRequest
{}
getAppVersionFilesRequest
:=
&
types
.
GetAppVersionFilesRequest
{}
if
f
:=
req
.
QueryParameter
(
"files"
);
f
!=
""
{
if
f
:=
req
.
QueryParameter
(
"files"
);
f
!=
""
{
getAppVersionFilesRequest
.
Files
=
strings
.
Split
(
f
,
","
)
getAppVersionFilesRequest
.
Files
=
strings
.
Split
(
f
,
","
)
}
}
result
,
err
:=
openpitrix
.
GetAppVersionFiles
(
versionId
,
getAppVersionFilesRequest
)
result
,
err
:=
app
.
GetAppVersionFiles
(
versionId
,
getAppVersionFilesRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -162,7 +163,7 @@ func ListAppVersionAudits(req *restful.Request, resp *restful.Response) {
...
@@ -162,7 +163,7 @@ func ListAppVersionAudits(req *restful.Request, resp *restful.Response) {
conditions
.
Match
[
"version"
]
=
versionId
conditions
.
Match
[
"version"
]
=
versionId
}
}
result
,
err
:=
openpitrix
.
ListAppVersionAudits
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
app
.
ListAppVersionAudits
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -192,7 +193,7 @@ func ListReviews(req *restful.Request, resp *restful.Response) {
...
@@ -192,7 +193,7 @@ func ListReviews(req *restful.Request, resp *restful.Response) {
return
return
}
}
result
,
err
:=
openpitrix
.
ListAppVersionReviews
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
app
.
ListAppVersionReviews
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -225,7 +226,7 @@ func ListAppVersions(req *restful.Request, resp *restful.Response) {
...
@@ -225,7 +226,7 @@ func ListAppVersions(req *restful.Request, resp *restful.Response) {
}
}
conditions
.
Match
[
"app"
]
=
appId
conditions
.
Match
[
"app"
]
=
appId
result
,
err
:=
openpitrix
.
ListAppVersions
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
app
.
ListAppVersions
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -240,7 +241,7 @@ func ListAppVersions(req *restful.Request, resp *restful.Response) {
...
@@ -240,7 +241,7 @@ func ListAppVersions(req *restful.Request, resp *restful.Response) {
if
statistics
{
if
statistics
{
for
_
,
item
:=
range
result
.
Items
{
for
_
,
item
:=
range
result
.
Items
{
if
version
,
ok
:=
item
.
(
*
openpitrix
.
AppVersion
);
ok
{
if
version
,
ok
:=
item
.
(
*
types
.
AppVersion
);
ok
{
statisticsResult
,
err
:=
openpitrix
.
ListApplications
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"app_id"
:
version
.
AppId
,
"version_id"
:
version
.
VersionId
}},
0
,
0
,
""
,
false
)
statisticsResult
,
err
:=
openpitrix
.
ListApplications
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"app_id"
:
version
.
AppId
,
"version_id"
:
version
.
VersionId
}},
0
,
0
,
""
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorln
(
err
)
klog
.
Errorln
(
err
)
...
@@ -271,7 +272,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
...
@@ -271,7 +272,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
return
return
}
}
result
,
err
:=
openpitrix
.
ListApps
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
app
.
ListApps
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -286,7 +287,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
...
@@ -286,7 +287,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
if
statistics
{
if
statistics
{
for
_
,
item
:=
range
result
.
Items
{
for
_
,
item
:=
range
result
.
Items
{
if
app
,
ok
:=
item
.
(
*
openpitrix
.
App
);
ok
{
if
app
,
ok
:=
item
.
(
*
types
.
App
);
ok
{
status
:=
"active|used|enabled|stopped|pending|creating|upgrading|updating|rollbacking|stopping|starting|recovering|resizing|scaling|deleting"
status
:=
"active|used|enabled|stopped|pending|creating|upgrading|updating|rollbacking|stopping|starting|recovering|resizing|scaling|deleting"
statisticsResult
,
err
:=
openpitrix
.
ListApplications
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"app_id"
:
app
.
AppId
,
"status"
:
status
}},
0
,
0
,
""
,
false
)
statisticsResult
,
err
:=
openpitrix
.
ListApplications
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"app_id"
:
app
.
AppId
,
"status"
:
status
}},
0
,
0
,
""
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -304,7 +305,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
...
@@ -304,7 +305,7 @@ func ListApps(req *restful.Request, resp *restful.Response) {
func
ModifyApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
ModifyApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
patchAppRequest
openpitrix
.
ModifyAppRequest
var
patchAppRequest
types
.
ModifyAppRequest
err
:=
req
.
ReadEntity
(
&
patchAppRequest
)
err
:=
req
.
ReadEntity
(
&
patchAppRequest
)
appId
:=
req
.
PathParameter
(
"app"
)
appId
:=
req
.
PathParameter
(
"app"
)
...
@@ -313,7 +314,7 @@ func ModifyApp(req *restful.Request, resp *restful.Response) {
...
@@ -313,7 +314,7 @@ func ModifyApp(req *restful.Request, resp *restful.Response) {
return
return
}
}
err
=
openpitrix
.
PatchApp
(
appId
,
&
patchAppRequest
)
err
=
app
.
PatchApp
(
appId
,
&
patchAppRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -341,7 +342,7 @@ func ModifyApp(req *restful.Request, resp *restful.Response) {
...
@@ -341,7 +342,7 @@ func ModifyApp(req *restful.Request, resp *restful.Response) {
func
DescribeApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DescribeApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
appId
:=
req
.
PathParameter
(
"app"
)
appId
:=
req
.
PathParameter
(
"app"
)
result
,
err
:=
openpitrix
.
DescribeApp
(
appId
)
result
,
err
:=
app
.
DescribeApp
(
appId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -364,7 +365,7 @@ func DescribeApp(req *restful.Request, resp *restful.Response) {
...
@@ -364,7 +365,7 @@ func DescribeApp(req *restful.Request, resp *restful.Response) {
func
DeleteApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DeleteApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
appId
:=
req
.
PathParameter
(
"app"
)
appId
:=
req
.
PathParameter
(
"app"
)
err
:=
openpitrix
.
DeleteApp
(
appId
)
err
:=
app
.
DeleteApp
(
appId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -385,7 +386,7 @@ func DeleteApp(req *restful.Request, resp *restful.Response) {
...
@@ -385,7 +386,7 @@ func DeleteApp(req *restful.Request, resp *restful.Response) {
}
}
func
CreateApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
CreateApp
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
createAppRequest
:=
&
openpitrix
.
CreateAppRequest
{}
createAppRequest
:=
&
types
.
CreateAppRequest
{}
err
:=
req
.
ReadEntity
(
createAppRequest
)
err
:=
req
.
ReadEntity
(
createAppRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -399,13 +400,13 @@ func CreateApp(req *restful.Request, resp *restful.Response) {
...
@@ -399,13 +400,13 @@ func CreateApp(req *restful.Request, resp *restful.Response) {
var
result
interface
{}
var
result
interface
{}
if
validate
{
if
validate
{
validatePackageRequest
:=
&
openpitrix
.
ValidatePackageRequest
{
validatePackageRequest
:=
&
types
.
ValidatePackageRequest
{
VersionPackage
:
createAppRequest
.
VersionPackage
,
VersionPackage
:
createAppRequest
.
VersionPackage
,
VersionType
:
createAppRequest
.
VersionType
,
VersionType
:
createAppRequest
.
VersionType
,
}
}
result
,
err
=
openpitrix
.
ValidatePackage
(
validatePackageRequest
)
result
,
err
=
app
.
ValidatePackage
(
validatePackageRequest
)
}
else
{
}
else
{
result
,
err
=
openpitrix
.
CreateApp
(
createAppRequest
)
result
,
err
=
app
.
CreateApp
(
createAppRequest
)
}
}
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
...
@@ -427,7 +428,7 @@ func CreateApp(req *restful.Request, resp *restful.Response) {
...
@@ -427,7 +428,7 @@ func CreateApp(req *restful.Request, resp *restful.Response) {
}
}
func
CreateAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
CreateAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
createAppVersionRequest
openpitrix
.
CreateAppVersionRequest
var
createAppVersionRequest
types
.
CreateAppVersionRequest
err
:=
req
.
ReadEntity
(
&
createAppVersionRequest
)
err
:=
req
.
ReadEntity
(
&
createAppVersionRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -442,13 +443,13 @@ func CreateAppVersion(req *restful.Request, resp *restful.Response) {
...
@@ -442,13 +443,13 @@ func CreateAppVersion(req *restful.Request, resp *restful.Response) {
var
result
interface
{}
var
result
interface
{}
if
validate
{
if
validate
{
validatePackageRequest
:=
&
openpitrix
.
ValidatePackageRequest
{
validatePackageRequest
:=
&
types
.
ValidatePackageRequest
{
VersionPackage
:
createAppVersionRequest
.
Package
,
VersionPackage
:
createAppVersionRequest
.
Package
,
VersionType
:
createAppVersionRequest
.
Type
,
VersionType
:
createAppVersionRequest
.
Type
,
}
}
result
,
err
=
openpitrix
.
ValidatePackage
(
validatePackageRequest
)
result
,
err
=
app
.
ValidatePackage
(
validatePackageRequest
)
}
else
{
}
else
{
result
,
err
=
openpitrix
.
CreateAppVersion
(
&
createAppVersionRequest
)
result
,
err
=
app
.
CreateAppVersion
(
&
createAppVersionRequest
)
}
}
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
...
@@ -471,7 +472,7 @@ func CreateAppVersion(req *restful.Request, resp *restful.Response) {
...
@@ -471,7 +472,7 @@ func CreateAppVersion(req *restful.Request, resp *restful.Response) {
func
ModifyAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
ModifyAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
patchAppVersionRequest
openpitrix
.
ModifyAppVersionRequest
var
patchAppVersionRequest
types
.
ModifyAppVersionRequest
err
:=
req
.
ReadEntity
(
&
patchAppVersionRequest
)
err
:=
req
.
ReadEntity
(
&
patchAppVersionRequest
)
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
...
@@ -480,7 +481,7 @@ func ModifyAppVersion(req *restful.Request, resp *restful.Response) {
...
@@ -480,7 +481,7 @@ func ModifyAppVersion(req *restful.Request, resp *restful.Response) {
return
return
}
}
err
=
openpitrix
.
PatchAppVersion
(
versionId
,
&
patchAppVersionRequest
)
err
=
app
.
PatchAppVersion
(
versionId
,
&
patchAppVersionRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -503,7 +504,7 @@ func ModifyAppVersion(req *restful.Request, resp *restful.Response) {
...
@@ -503,7 +504,7 @@ func ModifyAppVersion(req *restful.Request, resp *restful.Response) {
func
DeleteAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DeleteAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
err
:=
openpitrix
.
DeleteAppVersion
(
versionId
)
err
:=
app
.
DeleteAppVersion
(
versionId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -526,7 +527,7 @@ func DeleteAppVersion(req *restful.Request, resp *restful.Response) {
...
@@ -526,7 +527,7 @@ func DeleteAppVersion(req *restful.Request, resp *restful.Response) {
func
DescribeAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DescribeAppVersion
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
versionId
:=
req
.
PathParameter
(
"version"
)
versionId
:=
req
.
PathParameter
(
"version"
)
result
,
err
:=
openpitrix
.
DescribeAppVersion
(
versionId
)
result
,
err
:=
app
.
DescribeAppVersion
(
versionId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
...
pkg/apiserver/openpitrix/attachments.go
浏览文件 @
c40d1542
...
@@ -19,19 +19,19 @@
...
@@ -19,19 +19,19 @@
package
openpitrix
package
openpitrix
import
(
import
(
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"kubesphere.io/kubesphere/pkg/models/openpitrix
"
"kubesphere.io/kubesphere/pkg/models/openpitrix/attachment
"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client"
"net/http"
"net/http"
)
)
func
DescribeAttachment
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DescribeAttachment
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
attachmentId
:=
req
.
PathParameter
(
"attachment"
)
attachmentId
:=
req
.
PathParameter
(
"attachment"
)
fileName
:=
req
.
QueryParameter
(
"filename"
)
fileName
:=
req
.
QueryParameter
(
"filename"
)
result
,
err
:=
openpitrix
.
DescribeAttachment
(
attachmentId
)
result
,
err
:=
attachment
.
DescribeAttachment
(
attachmentId
)
// file raw
// file raw
if
fileName
!=
""
{
if
fileName
!=
""
{
data
:=
result
.
AttachmentContent
[
fileName
]
data
:=
result
.
AttachmentContent
[
fileName
]
...
...
pkg/apiserver/openpitrix/categories.go
浏览文件 @
c40d1542
...
@@ -23,7 +23,9 @@ import (
...
@@ -23,7 +23,9 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/models/openpitrix/app"
"kubesphere.io/kubesphere/pkg/models/openpitrix/category"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client"
...
@@ -32,14 +34,14 @@ import (
...
@@ -32,14 +34,14 @@ import (
)
)
func
CreateCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
CreateCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
createCategoryRequest
:=
&
openpitrix
.
CreateCategoryRequest
{}
createCategoryRequest
:=
&
types
.
CreateCategoryRequest
{}
err
:=
req
.
ReadEntity
(
createCategoryRequest
)
err
:=
req
.
ReadEntity
(
createCategoryRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
return
return
}
}
result
,
err
:=
openpitrix
.
CreateCategory
(
createCategoryRequest
)
result
,
err
:=
category
.
CreateCategory
(
createCategoryRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -59,7 +61,7 @@ func CreateCategory(req *restful.Request, resp *restful.Response) {
...
@@ -59,7 +61,7 @@ func CreateCategory(req *restful.Request, resp *restful.Response) {
func
DeleteCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DeleteCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
categoryId
:=
req
.
PathParameter
(
"category"
)
categoryId
:=
req
.
PathParameter
(
"category"
)
err
:=
openpitrix
.
DeleteCategory
(
categoryId
)
err
:=
category
.
DeleteCategory
(
categoryId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -77,7 +79,7 @@ func DeleteCategory(req *restful.Request, resp *restful.Response) {
...
@@ -77,7 +79,7 @@ func DeleteCategory(req *restful.Request, resp *restful.Response) {
resp
.
WriteEntity
(
errors
.
None
)
resp
.
WriteEntity
(
errors
.
None
)
}
}
func
ModifyCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
ModifyCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
modifyCategoryRequest
openpitrix
.
ModifyCategoryRequest
var
modifyCategoryRequest
types
.
ModifyCategoryRequest
categoryId
:=
req
.
PathParameter
(
"category"
)
categoryId
:=
req
.
PathParameter
(
"category"
)
err
:=
req
.
ReadEntity
(
&
modifyCategoryRequest
)
err
:=
req
.
ReadEntity
(
&
modifyCategoryRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -85,7 +87,7 @@ func ModifyCategory(req *restful.Request, resp *restful.Response) {
...
@@ -85,7 +87,7 @@ func ModifyCategory(req *restful.Request, resp *restful.Response) {
return
return
}
}
err
=
openpitrix
.
PatchCategory
(
categoryId
,
&
modifyCategoryRequest
)
err
=
category
.
PatchCategory
(
categoryId
,
&
modifyCategoryRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -105,7 +107,7 @@ func ModifyCategory(req *restful.Request, resp *restful.Response) {
...
@@ -105,7 +107,7 @@ func ModifyCategory(req *restful.Request, resp *restful.Response) {
func
DescribeCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DescribeCategory
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
categoryId
:=
req
.
PathParameter
(
"category"
)
categoryId
:=
req
.
PathParameter
(
"category"
)
result
,
err
:=
openpitrix
.
DescribeCategory
(
categoryId
)
result
,
err
:=
category
.
DescribeCategory
(
categoryId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -140,7 +142,7 @@ func ListCategories(req *restful.Request, resp *restful.Response) {
...
@@ -140,7 +142,7 @@ func ListCategories(req *restful.Request, resp *restful.Response) {
return
return
}
}
result
,
err
:=
openpitrix
.
ListCategories
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
category
.
ListCategories
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -155,8 +157,8 @@ func ListCategories(req *restful.Request, resp *restful.Response) {
...
@@ -155,8 +157,8 @@ func ListCategories(req *restful.Request, resp *restful.Response) {
if
statistics
{
if
statistics
{
for
_
,
item
:=
range
result
.
Items
{
for
_
,
item
:=
range
result
.
Items
{
if
category
,
ok
:=
item
.
(
*
openpitrix
.
Category
);
ok
{
if
category
,
ok
:=
item
.
(
*
types
.
Category
);
ok
{
statisticsResult
,
err
:=
openpitrix
.
ListApps
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"category_id"
:
category
.
CategoryID
,
"status"
:
openpitrix
.
StatusActive
,
"repo"
:
openpitrix
.
BuiltinRepoId
}},
""
,
false
,
0
,
0
)
statisticsResult
,
err
:=
app
.
ListApps
(
&
params
.
Conditions
{
Match
:
map
[
string
]
string
{
"category_id"
:
category
.
CategoryID
,
"status"
:
app
.
StatusActive
,
"repo"
:
app
.
BuiltinRepoId
}},
""
,
false
,
0
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorln
(
err
)
klog
.
Errorln
(
err
)
resp
.
WriteHeaderAndEntity
(
http
.
StatusInternalServerError
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusInternalServerError
,
errors
.
Wrap
(
err
))
...
...
pkg/apiserver/openpitrix/repos.go
浏览文件 @
c40d1542
...
@@ -23,7 +23,8 @@ import (
...
@@ -23,7 +23,8 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/models/openpitrix/repo"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client"
...
@@ -32,7 +33,7 @@ import (
...
@@ -32,7 +33,7 @@ import (
)
)
func
CreateRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
CreateRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
createRepoRequest
:=
&
openpitrix
.
CreateRepoRequest
{}
createRepoRequest
:=
&
types
.
CreateRepoRequest
{}
err
:=
req
.
ReadEntity
(
createRepoRequest
)
err
:=
req
.
ReadEntity
(
createRepoRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusBadRequest
,
errors
.
Wrap
(
err
))
...
@@ -43,14 +44,14 @@ func CreateRepo(req *restful.Request, resp *restful.Response) {
...
@@ -43,14 +44,14 @@ func CreateRepo(req *restful.Request, resp *restful.Response) {
var
result
interface
{}
var
result
interface
{}
if
validate
{
if
validate
{
validateRepoRequest
:=
&
openpitrix
.
ValidateRepoRequest
{
validateRepoRequest
:=
&
types
.
ValidateRepoRequest
{
Type
:
createRepoRequest
.
Type
,
Type
:
createRepoRequest
.
Type
,
Url
:
createRepoRequest
.
URL
,
Url
:
createRepoRequest
.
URL
,
Credential
:
createRepoRequest
.
Credential
,
Credential
:
createRepoRequest
.
Credential
,
}
}
result
,
err
=
openpitrix
.
ValidateRepo
(
validateRepoRequest
)
result
,
err
=
repo
.
ValidateRepo
(
validateRepoRequest
)
}
else
{
}
else
{
result
,
err
=
openpitrix
.
CreateRepo
(
createRepoRequest
)
result
,
err
=
repo
.
CreateRepo
(
createRepoRequest
)
}
}
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
...
@@ -70,7 +71,7 @@ func CreateRepo(req *restful.Request, resp *restful.Response) {
...
@@ -70,7 +71,7 @@ func CreateRepo(req *restful.Request, resp *restful.Response) {
}
}
func
DoRepoAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DoRepoAction
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
repoActionRequest
:=
&
openpitrix
.
RepoActionRequest
{}
repoActionRequest
:=
&
types
.
RepoActionRequest
{}
repoId
:=
req
.
PathParameter
(
"repo"
)
repoId
:=
req
.
PathParameter
(
"repo"
)
err
:=
req
.
ReadEntity
(
repoActionRequest
)
err
:=
req
.
ReadEntity
(
repoActionRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -78,7 +79,7 @@ func DoRepoAction(req *restful.Request, resp *restful.Response) {
...
@@ -78,7 +79,7 @@ func DoRepoAction(req *restful.Request, resp *restful.Response) {
return
return
}
}
err
=
openpitrix
.
DoRepoAction
(
repoId
,
repoActionRequest
)
err
=
repo
.
DoRepoAction
(
repoId
,
repoActionRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -99,7 +100,7 @@ func DoRepoAction(req *restful.Request, resp *restful.Response) {
...
@@ -99,7 +100,7 @@ func DoRepoAction(req *restful.Request, resp *restful.Response) {
func
DeleteRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DeleteRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
repoId
:=
req
.
PathParameter
(
"repo"
)
repoId
:=
req
.
PathParameter
(
"repo"
)
err
:=
openpitrix
.
DeleteRepo
(
repoId
)
err
:=
repo
.
DeleteRepo
(
repoId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -118,7 +119,7 @@ func DeleteRepo(req *restful.Request, resp *restful.Response) {
...
@@ -118,7 +119,7 @@ func DeleteRepo(req *restful.Request, resp *restful.Response) {
}
}
func
ModifyRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
ModifyRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
var
updateRepoRequest
openpitrix
.
ModifyRepoRequest
var
updateRepoRequest
types
.
ModifyRepoRequest
repoId
:=
req
.
PathParameter
(
"repo"
)
repoId
:=
req
.
PathParameter
(
"repo"
)
err
:=
req
.
ReadEntity
(
&
updateRepoRequest
)
err
:=
req
.
ReadEntity
(
&
updateRepoRequest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -126,7 +127,7 @@ func ModifyRepo(req *restful.Request, resp *restful.Response) {
...
@@ -126,7 +127,7 @@ func ModifyRepo(req *restful.Request, resp *restful.Response) {
return
return
}
}
err
=
openpitrix
.
PatchRepo
(
repoId
,
&
updateRepoRequest
)
err
=
repo
.
PatchRepo
(
repoId
,
&
updateRepoRequest
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -147,7 +148,7 @@ func ModifyRepo(req *restful.Request, resp *restful.Response) {
...
@@ -147,7 +148,7 @@ func ModifyRepo(req *restful.Request, resp *restful.Response) {
func
DescribeRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
func
DescribeRepo
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
repoId
:=
req
.
PathParameter
(
"repo"
)
repoId
:=
req
.
PathParameter
(
"repo"
)
result
,
err
:=
openpitrix
.
DescribeRepo
(
repoId
)
result
,
err
:=
repo
.
DescribeRepo
(
repoId
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -179,7 +180,7 @@ func ListRepos(req *restful.Request, resp *restful.Response) {
...
@@ -179,7 +180,7 @@ func ListRepos(req *restful.Request, resp *restful.Response) {
return
return
}
}
result
,
err
:=
openpitrix
.
ListRepos
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
result
,
err
:=
repo
.
ListRepos
(
conditions
,
orderBy
,
reverse
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
@@ -205,7 +206,7 @@ func ListRepoEvents(req *restful.Request, resp *restful.Response) {
...
@@ -205,7 +206,7 @@ func ListRepoEvents(req *restful.Request, resp *restful.Response) {
return
return
}
}
result
,
err
:=
openpitrix
.
ListRepoEvents
(
repoId
,
conditions
,
limit
,
offset
)
result
,
err
:=
repo
.
ListRepoEvents
(
repoId
,
conditions
,
limit
,
offset
)
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
if
_
,
notEnabled
:=
err
.
(
client
.
ClientSetNotEnabledError
);
notEnabled
{
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
resp
.
WriteHeaderAndEntity
(
http
.
StatusNotImplemented
,
errors
.
Wrap
(
err
))
...
...
pkg/apiserver/terminal/terminal.go
已删除
100644 → 0
浏览文件 @
eceadec6
/*
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
terminal
import
(
"github.com/emicklei/go-restful"
"github.com/gorilla/websocket"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models/terminal"
"net/http"
)
var
upgrader
=
websocket
.
Upgrader
{
ReadBufferSize
:
1024
,
WriteBufferSize
:
1024
,
// Allow connections from any Origin
CheckOrigin
:
func
(
r
*
http
.
Request
)
bool
{
return
true
},
}
// Handles execute shell API call
func
HandleTerminalSession
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
namespace
:=
request
.
PathParameter
(
"namespace"
)
podName
:=
request
.
PathParameter
(
"pod"
)
containerName
:=
request
.
QueryParameter
(
"container"
)
shell
:=
request
.
QueryParameter
(
"shell"
)
conn
,
err
:=
upgrader
.
Upgrade
(
resp
.
ResponseWriter
,
request
.
Request
,
nil
)
if
err
!=
nil
{
klog
.
Warning
(
err
)
return
}
terminal
.
HandleSession
(
shell
,
namespace
,
podName
,
containerName
,
conn
)
}
pkg/apiserver/workspaces/workspaces.go
已删除
100644 → 0
浏览文件 @
eceadec6
/*
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
workspaces
pkg/kapis/devops/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/kapis/iam/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/kapis/logging/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/kapis/openpitrix/v1/handler.go
浏览文件 @
c40d1542
package
v1
package
v1
import
"github.com/emicklei/go-restful"
import
(
"github.com/emicklei/go-restful"
v1
"k8s.io/api/core/v1"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix/application"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/resource"
"kubesphere.io/kubesphere/pkg/server/params"
"openpitrix.io/openpitrix/pkg/pb"
)
type
openpitrixHandler
struct
{
type
openpitrixHandler
struct
{
namespacesGetter
*
resource
.
NamespacedResourceGetter
applicationOperator
application
.
Interface
}
}
func
newOpenpitrixHandler
()
*
openpitrixHandler
{
func
newOpenpitrixHandler
(
factory
informers
.
InformerFactory
,
client
pb
.
ClusterManagerClient
)
*
openpitrixHandler
{
return
&
openpitrixHandler
{}
return
&
openpitrixHandler
{
namespacesGetter
:
resource
.
New
(
factory
),
applicationOperator
:
application
.
NewApplicaitonOperator
(
factory
.
KubernetesSharedInformerFactory
(),
client
),
}
}
}
func
(
h
*
openpitrixHandler
)
handleListApplications
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
func
(
h
*
openpitrixHandler
)
handleListApplications
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
limit
,
offset
:=
params
.
ParsePaging
(
request
.
QueryParameter
(
params
.
PagingParam
))
namespaceName
:=
request
.
PathParameter
(
"namespace"
)
conditions
,
err
:=
params
.
ParseConditions
(
request
.
QueryParameter
(
params
.
ConditionsParam
))
orderBy
:=
request
.
QueryParameter
(
params
.
OrderByParam
)
reverse
:=
params
.
ParseReverse
(
request
)
if
orderBy
==
""
{
orderBy
=
"create_time"
reverse
=
true
}
if
err
!=
nil
{
api
.
HandleBadRequest
(
response
,
err
)
return
}
if
namespaceName
!=
""
{
namespace
,
err
:=
h
.
namespacesGetter
.
Get
(
api
.
ResourceKindNamespace
,
""
,
namespaceName
)
if
err
!=
nil
{
api
.
HandleInternalError
(
response
,
err
)
return
}
var
runtimeId
string
if
ns
,
ok
:=
namespace
.
(
*
v1
.
Namespace
);
ok
{
runtimeId
=
ns
.
Annotations
[
constants
.
OpenPitrixRuntimeAnnotationKey
]
}
if
runtimeId
==
""
{
response
.
WriteAsJson
(
models
.
PageableResponse
{
Items
:
[]
interface
{}{},
TotalCount
:
0
})
return
}
else
{
conditions
.
Match
[
"runtime_id"
]
=
runtimeId
}
}
result
,
err
:=
h
.
applicationOperator
.
List
(
conditions
,
limit
,
offset
,
orderBy
,
reverse
)
if
err
!=
nil
{
klog
.
Errorln
(
err
)
api
.
HandleInternalError
(
response
,
err
)
return
}
resp
.
WriteAsJson
(
result
)
}
}
pkg/kapis/openpitrix/v1/register.go
浏览文件 @
c40d1542
...
@@ -25,7 +25,8 @@ import (
...
@@ -25,7 +25,8 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
opmodels
"kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/models/openpitrix/application"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
"net/http"
"net/http"
...
@@ -78,7 +79,7 @@ func addWebService(c *restful.Container) error {
...
@@ -78,7 +79,7 @@ func addWebService(c *restful.Container) error {
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/applications/{application}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/applications/{application}"
)
.
To
(
openpitrix
.
DescribeApplication
)
.
To
(
openpitrix
.
DescribeApplication
)
.
Returns
(
http
.
StatusOK
,
ok
,
opmodels
.
Application
{})
.
Returns
(
http
.
StatusOK
,
ok
,
application
.
Application
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Doc
(
"Describe the specified application of the namespace"
)
.
Doc
(
"Describe the specified application of the namespace"
)
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
))
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
))
.
...
@@ -88,7 +89,7 @@ func addWebService(c *restful.Container) error {
...
@@ -88,7 +89,7 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
CreateApplication
)
.
To
(
openpitrix
.
CreateApplication
)
.
Doc
(
"Deploy a new application"
)
.
Doc
(
"Deploy a new application"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Reads
(
opmodel
s
.
CreateClusterRequest
{})
.
Reads
(
type
s
.
CreateClusterRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
)))
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
)))
...
@@ -97,7 +98,7 @@ func addWebService(c *restful.Container) error {
...
@@ -97,7 +98,7 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
ModifyApplication
)
.
To
(
openpitrix
.
ModifyApplication
)
.
Doc
(
"Modify application"
)
.
Doc
(
"Modify application"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NamespaceResourcesTag
})
.
Reads
(
opmodel
s
.
ModifyClusterAttributesRequest
{})
.
Reads
(
type
s
.
ModifyClusterAttributesRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
))
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"the name of the project"
))
.
Param
(
webservice
.
PathParameter
(
"application"
,
"the id of the application cluster"
)))
Param
(
webservice
.
PathParameter
(
"application"
,
"the id of the application cluster"
)))
...
@@ -114,9 +115,9 @@ func addWebService(c *restful.Container) error {
...
@@ -114,9 +115,9 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
CreateAppVersion
)
.
To
(
openpitrix
.
CreateAppVersion
)
.
Doc
(
"Create a new app template version"
)
.
Doc
(
"Create a new app template version"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
CreateAppVersionRequest
{})
.
Reads
(
type
s
.
CreateAppVersionRequest
{})
.
Param
(
webservice
.
QueryParameter
(
"validate"
,
"Validate format of package(pack by op tool)"
))
.
Param
(
webservice
.
QueryParameter
(
"validate"
,
"Validate format of package(pack by op tool)"
))
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
CreateAppVersionResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
CreateAppVersionResponse
{})
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
DELETE
(
"/apps/{app}/versions/{version}"
)
.
webservice
.
Route
(
webservice
.
DELETE
(
"/apps/{app}/versions/{version}"
)
.
To
(
openpitrix
.
DeleteAppVersion
)
.
To
(
openpitrix
.
DeleteAppVersion
)
.
...
@@ -130,7 +131,7 @@ func addWebService(c *restful.Container) error {
...
@@ -130,7 +131,7 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
ModifyAppVersion
)
.
To
(
openpitrix
.
ModifyAppVersion
)
.
Doc
(
"Patch the specified app template version"
)
.
Doc
(
"Patch the specified app template version"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
ModifyAppVersionRequest
{})
.
Reads
(
type
s
.
ModifyAppVersionRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
...
@@ -138,7 +139,7 @@ func addWebService(c *restful.Container) error {
...
@@ -138,7 +139,7 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
DescribeAppVersion
)
.
To
(
openpitrix
.
DescribeAppVersion
)
.
Doc
(
"Describe the specified app template version"
)
.
Doc
(
"Describe the specified app template version"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
AppVersion
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
AppVersion
{})
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions"
)
.
...
@@ -158,13 +159,13 @@ func addWebService(c *restful.Container) error {
...
@@ -158,13 +159,13 @@ func addWebService(c *restful.Container) error {
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/audits"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/audits"
)
.
To
(
openpitrix
.
ListAppVersionAudits
)
.
To
(
openpitrix
.
ListAppVersionAudits
)
.
Doc
(
"List audits information of version-specific app template"
)
.
Doc
(
"List audits information of version-specific app template"
)
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
AppVersionAudit
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
AppVersionAudit
{})
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/package"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/package"
)
.
To
(
openpitrix
.
GetAppVersionPackage
)
.
To
(
openpitrix
.
GetAppVersionPackage
)
.
Doc
(
"Get packages of version-specific app"
)
.
Doc
(
"Get packages of version-specific app"
)
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
GetAppVersionPackageResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
GetAppVersionPackageResponse
{})
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
POST
(
"/apps/{app}/versions/{version}/action"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/apps/{app}/versions/{version}/action"
)
.
...
@@ -176,7 +177,7 @@ func addWebService(c *restful.Container) error {
...
@@ -176,7 +177,7 @@ func addWebService(c *restful.Container) error {
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/files"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/versions/{version}/files"
)
.
To
(
openpitrix
.
GetAppVersionFiles
)
.
To
(
openpitrix
.
GetAppVersionFiles
)
.
Doc
(
"Get app template package files"
)
.
Doc
(
"Get app template package files"
)
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
GetAppVersionPackageFilesResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
GetAppVersionPackageFilesResponse
{})
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"version"
,
"app template version id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/reviews"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/reviews"
)
.
...
@@ -189,18 +190,18 @@ func addWebService(c *restful.Container) error {
...
@@ -189,18 +190,18 @@ func addWebService(c *restful.Container) error {
Required
(
false
)
.
Required
(
false
)
.
DataFormat
(
"limit=%d,page=%d"
)
.
DataFormat
(
"limit=%d,page=%d"
)
.
DefaultValue
(
"limit=10,page=1"
))
.
DefaultValue
(
"limit=10,page=1"
))
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
AppVersionReview
{}))
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
AppVersionReview
{}))
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/audits"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}/audits"
)
.
To
(
openpitrix
.
ListAppVersionAudits
)
.
To
(
openpitrix
.
ListAppVersionAudits
)
.
Doc
(
"List audits information of the specific app template"
)
.
Doc
(
"List audits information of the specific app template"
)
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
))
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
))
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
AppVersionAudit
{}))
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
AppVersionAudit
{}))
webservice
.
Route
(
webservice
.
POST
(
"/apps"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/apps"
)
.
To
(
openpitrix
.
CreateApp
)
.
To
(
openpitrix
.
CreateApp
)
.
Doc
(
"Create a new app template"
)
.
Doc
(
"Create a new app template"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
CreateAppResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
CreateAppResponse
{})
.
Reads
(
opmodel
s
.
CreateAppRequest
{})
.
Reads
(
type
s
.
CreateAppRequest
{})
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
DELETE
(
"/apps/{app}"
)
.
webservice
.
Route
(
webservice
.
DELETE
(
"/apps/{app}"
)
.
To
(
openpitrix
.
DeleteApp
)
.
To
(
openpitrix
.
DeleteApp
)
.
...
@@ -213,14 +214,14 @@ func addWebService(c *restful.Container) error {
...
@@ -213,14 +214,14 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
ModifyApp
)
.
To
(
openpitrix
.
ModifyApp
)
.
Doc
(
"Patch the specified app template"
)
.
Doc
(
"Patch the specified app template"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
ModifyAppVersionRequest
{})
.
Reads
(
type
s
.
ModifyAppVersionRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/apps/{app}"
)
.
To
(
openpitrix
.
DescribeApp
)
.
To
(
openpitrix
.
DescribeApp
)
.
Doc
(
"Describe the specified app template"
)
.
Doc
(
"Describe the specified app template"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
AppVersion
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
AppVersion
{})
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
POST
(
"/apps/{app}/action"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/apps/{app}/action"
)
.
To
(
openpitrix
.
DoAppAction
)
.
To
(
openpitrix
.
DoAppAction
)
.
...
@@ -245,8 +246,8 @@ func addWebService(c *restful.Container) error {
...
@@ -245,8 +246,8 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
CreateCategory
)
.
To
(
openpitrix
.
CreateCategory
)
.
Doc
(
"Create app template category"
)
.
Doc
(
"Create app template category"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
CreateCategoryRequest
{})
.
Reads
(
type
s
.
CreateCategoryRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
CreateCategoryResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
CreateCategoryResponse
{})
.
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
Param
(
webservice
.
PathParameter
(
"app"
,
"app template id"
)))
webservice
.
Route
(
webservice
.
DELETE
(
"/categories/{category}"
)
.
webservice
.
Route
(
webservice
.
DELETE
(
"/categories/{category}"
)
.
To
(
openpitrix
.
DeleteCategory
)
.
To
(
openpitrix
.
DeleteCategory
)
.
...
@@ -259,14 +260,14 @@ func addWebService(c *restful.Container) error {
...
@@ -259,14 +260,14 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
ModifyCategory
)
.
To
(
openpitrix
.
ModifyCategory
)
.
Doc
(
"Patch the specified category"
)
.
Doc
(
"Patch the specified category"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
ModifyCategoryRequest
{})
.
Reads
(
type
s
.
ModifyCategoryRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"category"
,
"category id"
)))
Param
(
webservice
.
PathParameter
(
"category"
,
"category id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/categories/{category}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/categories/{category}"
)
.
To
(
openpitrix
.
DescribeCategory
)
.
To
(
openpitrix
.
DescribeCategory
)
.
Doc
(
"Describe the specified category"
)
.
Doc
(
"Describe the specified category"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
Category
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
Category
{})
.
Param
(
webservice
.
PathParameter
(
"category"
,
"category id"
)))
Param
(
webservice
.
PathParameter
(
"category"
,
"category id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/categories"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/categories"
)
.
To
(
openpitrix
.
ListCategories
)
.
To
(
openpitrix
.
ListCategories
)
.
...
@@ -286,15 +287,15 @@ func addWebService(c *restful.Container) error {
...
@@ -286,15 +287,15 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
DescribeAttachment
)
.
To
(
openpitrix
.
DescribeAttachment
)
.
Doc
(
"Get attachment by attachment id"
)
.
Doc
(
"Get attachment by attachment id"
)
.
Param
(
webservice
.
PathParameter
(
"attachment"
,
"attachment id"
))
.
Param
(
webservice
.
PathParameter
(
"attachment"
,
"attachment id"
))
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
Attachment
{}))
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
Attachment
{}))
webservice
.
Route
(
webservice
.
POST
(
"/repos"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/repos"
)
.
To
(
openpitrix
.
CreateRepo
)
.
To
(
openpitrix
.
CreateRepo
)
.
Doc
(
"Create repository, repository used to store package of app"
)
.
Doc
(
"Create repository, repository used to store package of app"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Param
(
webservice
.
QueryParameter
(
"validate"
,
"Validate repository"
))
.
Param
(
webservice
.
QueryParameter
(
"validate"
,
"Validate repository"
))
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
CreateRepoResponse
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
CreateRepoResponse
{})
.
Reads
(
opmodel
s
.
CreateRepoRequest
{}))
Reads
(
type
s
.
CreateRepoRequest
{}))
webservice
.
Route
(
webservice
.
DELETE
(
"/repos/{repo}"
)
.
webservice
.
Route
(
webservice
.
DELETE
(
"/repos/{repo}"
)
.
To
(
openpitrix
.
DeleteRepo
)
.
To
(
openpitrix
.
DeleteRepo
)
.
Doc
(
"Delete the specified repository"
)
.
Doc
(
"Delete the specified repository"
)
.
...
@@ -306,14 +307,14 @@ func addWebService(c *restful.Container) error {
...
@@ -306,14 +307,14 @@ func addWebService(c *restful.Container) error {
To
(
openpitrix
.
ModifyRepo
)
.
To
(
openpitrix
.
ModifyRepo
)
.
Doc
(
"Patch the specified repository"
)
.
Doc
(
"Patch the specified repository"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Reads
(
opmodel
s
.
ModifyRepoRequest
{})
.
Reads
(
type
s
.
ModifyRepoRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/repos/{repo}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/repos/{repo}"
)
.
To
(
openpitrix
.
DescribeRepo
)
.
To
(
openpitrix
.
DescribeRepo
)
.
Doc
(
"Describe the specified repository"
)
.
Doc
(
"Describe the specified repository"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
OpenpitrixTag
})
.
Returns
(
http
.
StatusOK
,
ok
,
opmodel
s
.
Repo
{})
.
Returns
(
http
.
StatusOK
,
ok
,
type
s
.
Repo
{})
.
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/repos"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/repos"
)
.
To
(
openpitrix
.
ListRepos
)
.
To
(
openpitrix
.
ListRepos
)
.
...
@@ -331,7 +332,7 @@ func addWebService(c *restful.Container) error {
...
@@ -331,7 +332,7 @@ func addWebService(c *restful.Container) error {
webservice
.
Route
(
webservice
.
POST
(
"/repos/{repo}/action"
)
.
webservice
.
Route
(
webservice
.
POST
(
"/repos/{repo}/action"
)
.
To
(
openpitrix
.
DoRepoAction
)
.
To
(
openpitrix
.
DoRepoAction
)
.
Doc
(
"Start index repository event"
)
.
Doc
(
"Start index repository event"
)
.
Reads
(
opmodel
s
.
RepoActionRequest
{})
.
Reads
(
type
s
.
RepoActionRequest
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Returns
(
http
.
StatusOK
,
ok
,
errors
.
Error
{})
.
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
Param
(
webservice
.
PathParameter
(
"repo"
,
"repo id"
)))
webservice
.
Route
(
webservice
.
GET
(
"/repos/{repo}/events"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/repos/{repo}/events"
)
.
...
...
pkg/kapis/resources/v1alpha3/handler.go
浏览文件 @
c40d1542
...
@@ -17,10 +17,10 @@ type Handler struct {
...
@@ -17,10 +17,10 @@ type Handler struct {
}
}
func
New
(
client
k8s
.
Client
)
*
Handler
{
func
New
(
client
k8s
.
Client
)
*
Handler
{
factory
:=
informers
.
NewInformerFactories
(
client
.
Kubernetes
(),
nil
,
nil
,
nil
)
factory
:=
informers
.
NewInformerFactories
(
client
.
Kubernetes
(),
client
.
KubeSphere
(),
client
.
S2i
(),
client
.
Application
()
)
return
&
Handler
{
return
&
Handler
{
namespacedResourceGetter
:
resource
.
New
(
factory
.
KubernetesSharedInformerFactory
()
),
namespacedResourceGetter
:
resource
.
New
(
factory
),
componentsGetter
:
components
.
NewComponentsGetter
(
factory
.
KubernetesSharedInformerFactory
()),
componentsGetter
:
components
.
NewComponentsGetter
(
factory
.
KubernetesSharedInformerFactory
()),
}
}
}
}
...
...
pkg/kapis/servicemesh/metrics/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/kapis/tenant/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
pkg/kapis/terminal/install/install.go
浏览文件 @
c40d1542
...
@@ -29,5 +29,5 @@ func init() {
...
@@ -29,5 +29,5 @@ func init() {
}
}
func
Install
(
c
*
restful
.
Container
)
{
func
Install
(
c
*
restful
.
Container
)
{
urlruntime
.
Must
(
v1alpha2
.
AddToContainer
(
c
))
urlruntime
.
Must
(
v1alpha2
.
AddToContainer
(
c
,
nil
,
nil
))
}
}
pkg/kapis/terminal/v1alpha2/handler.go
0 → 100644
浏览文件 @
c40d1542
package
v1alpha2
import
(
"github.com/emicklei/go-restful"
"github.com/gorilla/websocket"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models/terminal"
"net/http"
)
var
upgrader
=
websocket
.
Upgrader
{
ReadBufferSize
:
1024
,
WriteBufferSize
:
1024
,
// Allow connections from any Origin
CheckOrigin
:
func
(
r
*
http
.
Request
)
bool
{
return
true
},
}
type
terminalHandler
struct
{
terminaler
terminal
.
Interface
}
func
newTerminalHandler
(
client
kubernetes
.
Interface
,
config
*
rest
.
Config
)
*
terminalHandler
{
return
&
terminalHandler
{
terminaler
:
terminal
.
NewTerminaler
(
client
,
config
),
}
}
func
(
t
*
terminalHandler
)
handleTerminalSession
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
namespace
:=
request
.
PathParameter
(
"namespace"
)
podName
:=
request
.
PathParameter
(
"pod"
)
containerName
:=
request
.
QueryParameter
(
"container"
)
shell
:=
request
.
QueryParameter
(
"shell"
)
conn
,
err
:=
upgrader
.
Upgrade
(
response
.
ResponseWriter
,
request
.
Request
,
nil
)
if
err
!=
nil
{
klog
.
Warning
(
err
)
return
}
t
.
terminaler
.
HandleSession
(
shell
,
namespace
,
podName
,
containerName
,
conn
)
}
\ No newline at end of file
pkg/kapis/terminal/v1alpha2/register.go
浏览文件 @
c40d1542
...
@@ -21,30 +21,29 @@ import (
...
@@ -21,30 +21,29 @@ import (
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-openapi"
"github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/terminal"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
)
)
const
GroupName
=
"terminal.kubesphere.io"
const
(
GroupName
=
"terminal.kubesphere.io"
tag
=
"Terminal"
)
var
GroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1alpha2"
}
var
GroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1alpha2"
}
var
(
func
AddToContainer
(
c
*
restful
.
Container
,
client
kubernetes
.
Interface
,
config
*
rest
.
Config
)
error
{
WebServiceBuilder
=
runtime
.
NewContainerBuilder
(
addWebService
)
AddToContainer
=
WebServiceBuilder
.
AddToContainer
)
func
addWebService
(
c
*
restful
.
Container
)
error
{
webservice
:=
runtime
.
NewWebService
(
GroupVersion
)
webservice
:=
runtime
.
NewWebService
(
GroupVersion
)
tags
:=
[]
string
{
"Terminal"
}
handler
:=
newTerminalHandler
(
client
,
config
)
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod}"
)
.
To
(
terminal
.
H
andleTerminalSession
)
.
To
(
handler
.
h
andleTerminalSession
)
.
Doc
(
"create terminal session"
)
.
Doc
(
"create terminal session"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
tags
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
tag
}
)
.
Writes
(
models
.
PodInfo
{}))
Writes
(
models
.
PodInfo
{}))
c
.
Add
(
webservice
)
c
.
Add
(
webservice
)
...
...
pkg/models/log/logcrd.go
浏览文件 @
c40d1542
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api/logging/v1alpha2"
"kubesphere.io/kubesphere/pkg/api
s
/logging/v1alpha2"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/informers"
"net/http"
"net/http"
"strings"
"strings"
...
@@ -52,8 +52,8 @@ func createCRDClientSet() (*rest.RESTClient, *runtime.Scheme, error) {
...
@@ -52,8 +52,8 @@ func createCRDClientSet() (*rest.RESTClient, *runtime.Scheme, error) {
return
fb
.
NewFluentbitCRDClient
(
config
)
return
fb
.
NewFluentbitCRDClient
(
config
)
}
}
func
FluentbitOutputsQuery
()
*
FluentbitOutputsResult
{
func
FluentbitOutputsQuery
()
*
v1alpha2
.
FluentbitOutputsResult
{
var
result
FluentbitOutputsResult
var
result
v1alpha2
.
FluentbitOutputsResult
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -68,11 +68,11 @@ func FluentbitOutputsQuery() *FluentbitOutputsResult {
...
@@ -68,11 +68,11 @@ func FluentbitOutputsQuery() *FluentbitOutputsResult {
return
&
result
return
&
result
}
}
func
FluentbitOutputInsert
(
output
fb
.
OutputPlugin
)
*
FluentbitOutputsResult
{
func
FluentbitOutputInsert
(
output
v1alpha2
.
OutputPlugin
)
*
v1alpha2
.
FluentbitOutputsResult
{
var
result
FluentbitOutputsResult
var
result
v1alpha2
.
FluentbitOutputsResult
// 1. Update ConfigMap
// 1. Update ConfigMap
var
outputs
[]
fb
.
OutputPlugin
var
outputs
[]
v1alpha2
.
OutputPlugin
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
if
err
!=
nil
{
if
err
!=
nil
{
// If the ConfigMap doesn't exist, a new one will be created later
// If the ConfigMap doesn't exist, a new one will be created later
...
@@ -105,11 +105,11 @@ func FluentbitOutputInsert(output fb.OutputPlugin) *FluentbitOutputsResult {
...
@@ -105,11 +105,11 @@ func FluentbitOutputInsert(output fb.OutputPlugin) *FluentbitOutputsResult {
return
&
result
return
&
result
}
}
func
FluentbitOutputUpdate
(
output
fb
.
OutputPlugin
,
id
string
)
*
FluentbitOutputsResult
{
func
FluentbitOutputUpdate
(
output
v1alpha2
.
OutputPlugin
,
id
string
)
*
v1alpha2
.
FluentbitOutputsResult
{
var
result
FluentbitOutputsResult
var
result
v1alpha2
.
FluentbitOutputsResult
// 1. Update ConfigMap
// 1. Update ConfigMap
var
outputs
[]
fb
.
OutputPlugin
var
outputs
[]
v1alpha2
.
OutputPlugin
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
outputs
,
err
:=
GetFluentbitOutputFromConfigMap
()
if
err
!=
nil
{
if
err
!=
nil
{
// If the ConfigMap doesn't exist, a new one will be created later
// If the ConfigMap doesn't exist, a new one will be created later
...
@@ -152,8 +152,8 @@ func FluentbitOutputUpdate(output fb.OutputPlugin, id string) *FluentbitOutputsR
...
@@ -152,8 +152,8 @@ func FluentbitOutputUpdate(output fb.OutputPlugin, id string) *FluentbitOutputsR
return
&
result
return
&
result
}
}
func
FluentbitOutputDelete
(
id
string
)
*
FluentbitOutputsResult
{
func
FluentbitOutputDelete
(
id
string
)
*
v1alpha2
.
FluentbitOutputsResult
{
var
result
FluentbitOutputsResult
var
result
v1alpha2
.
FluentbitOutputsResult
// 1. Update ConfigMap
// 1. Update ConfigMap
// If the ConfigMap doesn't exist, a new one will be created
// If the ConfigMap doesn't exist, a new one will be created
...
@@ -194,7 +194,7 @@ func FluentbitOutputDelete(id string) *FluentbitOutputsResult {
...
@@ -194,7 +194,7 @@ func FluentbitOutputDelete(id string) *FluentbitOutputsResult {
return
&
result
return
&
result
}
}
func
GetFluentbitOutputFromConfigMap
()
([]
fb
.
OutputPlugin
,
error
)
{
func
GetFluentbitOutputFromConfigMap
()
([]
v1alpha2
.
OutputPlugin
,
error
)
{
configMap
,
err
:=
informers
.
SharedInformerFactory
()
.
Core
()
.
V1
()
.
ConfigMaps
()
.
Lister
()
.
ConfigMaps
(
LoggingNamespace
)
.
Get
(
ConfigMapName
)
configMap
,
err
:=
informers
.
SharedInformerFactory
()
.
Core
()
.
V1
()
.
ConfigMaps
()
.
Lister
()
.
ConfigMaps
(
LoggingNamespace
)
.
Get
(
ConfigMapName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -265,22 +265,22 @@ func updateFluentbitOutputConfigMap(outputs []fb.OutputPlugin) error {
...
@@ -265,22 +265,22 @@ func updateFluentbitOutputConfigMap(outputs []fb.OutputPlugin) error {
return
nil
return
nil
}
}
func
syncFluentbitCRDOutputWithConfigMap
(
outputs
[]
fb
.
OutputPlugin
)
error
{
func
syncFluentbitCRDOutputWithConfigMap
(
outputs
[]
v1alpha2
.
OutputPlugin
)
error
{
var
enabledOutputs
[]
fb
.
Plugin
var
enabledOutputs
[]
v1alpha2
.
Plugin
for
_
,
output
:=
range
outputs
{
for
_
,
output
:=
range
outputs
{
if
output
.
Enable
{
if
output
.
Enable
{
enabledOutputs
=
append
(
enabledOutputs
,
fb
.
Plugin
{
Type
:
output
.
Type
,
Name
:
output
.
Name
,
Parameters
:
output
.
Parameters
})
enabledOutputs
=
append
(
enabledOutputs
,
v1alpha2
.
Plugin
{
Type
:
output
.
Type
,
Name
:
output
.
Name
,
Parameters
:
output
.
Parameters
})
}
}
}
}
// Empty output is not allowed, must specify a null-type output
// Empty output is not allowed, must specify a null-type output
if
len
(
enabledOutputs
)
==
0
{
if
len
(
enabledOutputs
)
==
0
{
enabledOutputs
=
[]
fb
.
Plugin
{
enabledOutputs
=
[]
v1alpha2
.
Plugin
{
{
{
Type
:
"fluentbit_output"
,
Type
:
"fluentbit_output"
,
Name
:
"fluentbit-output-null"
,
Name
:
"fluentbit-output-null"
,
Parameters
:
[]
fb
.
Parameter
{
Parameters
:
[]
v1alpha2
.
Parameter
{
{
{
Name
:
"Name"
,
Name
:
"Name"
,
Value
:
"null"
,
Value
:
"null"
,
...
@@ -301,7 +301,7 @@ func syncFluentbitCRDOutputWithConfigMap(outputs []fb.OutputPlugin) error {
...
@@ -301,7 +301,7 @@ func syncFluentbitCRDOutputWithConfigMap(outputs []fb.OutputPlugin) error {
}
}
// Create a CRD client interface
// Create a CRD client interface
crdclient
:=
fb
.
CrdClient
(
crdcs
,
scheme
,
LoggingNamespace
)
crdclient
:=
v1alpha2
.
CrdClient
(
crdcs
,
scheme
,
LoggingNamespace
)
fluentbit
,
err
:=
crdclient
.
Get
(
"fluent-bit"
)
fluentbit
,
err
:=
crdclient
.
Get
(
"fluent-bit"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -320,7 +320,7 @@ func syncFluentbitCRDOutputWithConfigMap(outputs []fb.OutputPlugin) error {
...
@@ -320,7 +320,7 @@ func syncFluentbitCRDOutputWithConfigMap(outputs []fb.OutputPlugin) error {
}
}
// Parse es host, port and index
// Parse es host, port and index
func
ParseEsOutputParams
(
params
[]
fb
.
Parameter
)
*
v1alpha2
.
Config
{
func
ParseEsOutputParams
(
params
[]
v1alpha2
.
Parameter
)
*
v1alpha2
.
Config
{
var
(
var
(
isEsFound
bool
isEsFound
bool
...
...
pkg/models/log/types.go
浏览文件 @
c40d1542
...
@@ -17,9 +17,3 @@
...
@@ -17,9 +17,3 @@
*/
*/
package
log
package
log
type
FluentbitOutputsResult
struct
{
Status
int
`json:"status" description:"response status"`
Error
string
`json:"error,omitempty" description:"debug information"`
Outputs
[]
fb
.
OutputPlugin
`json:"outputs,omitempty" description:"array of fluent bit output plugins"`
}
pkg/models/openpitrix/apps.go
→
pkg/models/openpitrix/app
/app
s.go
浏览文件 @
c40d1542
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
* /
* /
*/
*/
package
openpitrix
package
app
import
(
import
(
"github.com/go-openapi/strfmt"
"github.com/go-openapi/strfmt"
...
@@ -25,6 +25,8 @@ import (
...
@@ -25,6 +25,8 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
...
@@ -83,13 +85,13 @@ func ListApps(conditions *params.Conditions, orderBy string, reverse bool, limit
...
@@ -83,13 +85,13 @@ func ListApps(conditions *params.Conditions, orderBy string, reverse bool, limit
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
AppSet
{
for
_
,
item
:=
range
resp
.
AppSet
{
items
=
append
(
items
,
c
onvertApp
(
item
))
items
=
append
(
items
,
utils
.
C
onvertApp
(
item
))
}
}
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
}
}
func
DescribeApp
(
id
string
)
(
*
App
,
error
)
{
func
DescribeApp
(
id
string
)
(
*
types
.
App
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -104,10 +106,10 @@ func DescribeApp(id string) (*App, error) {
...
@@ -104,10 +106,10 @@ func DescribeApp(id string) (*App, error) {
return
nil
,
err
return
nil
,
err
}
}
var
app
*
App
var
app
*
types
.
App
if
len
(
resp
.
AppSet
)
>
0
{
if
len
(
resp
.
AppSet
)
>
0
{
app
=
c
onvertApp
(
resp
.
AppSet
[
0
])
app
=
utils
.
C
onvertApp
(
resp
.
AppSet
[
0
])
return
app
,
nil
return
app
,
nil
}
else
{
}
else
{
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
...
@@ -132,7 +134,7 @@ func DeleteApp(id string) error {
...
@@ -132,7 +134,7 @@ func DeleteApp(id string) error {
return
nil
return
nil
}
}
func
CreateApp
(
request
*
CreateAppRequest
)
(
*
CreateAppResponse
,
error
)
{
func
CreateApp
(
request
*
types
.
CreateAppRequest
)
(
*
types
.
CreateAppResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -157,13 +159,13 @@ func CreateApp(request *CreateAppRequest) (*CreateAppResponse, error) {
...
@@ -157,13 +159,13 @@ func CreateApp(request *CreateAppRequest) (*CreateAppResponse, error) {
klog
.
Error
(
err
)
klog
.
Error
(
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
CreateAppResponse
{
return
&
types
.
CreateAppResponse
{
AppID
:
resp
.
GetAppId
()
.
GetValue
(),
AppID
:
resp
.
GetAppId
()
.
GetValue
(),
VersionID
:
resp
.
GetVersionId
()
.
GetValue
(),
VersionID
:
resp
.
GetVersionId
()
.
GetValue
(),
},
nil
},
nil
}
}
func
PatchApp
(
appId
string
,
request
*
ModifyAppRequest
)
error
{
func
PatchApp
(
appId
string
,
request
*
types
.
ModifyAppRequest
)
error
{
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -237,7 +239,7 @@ func PatchApp(appId string, request *ModifyAppRequest) error {
...
@@ -237,7 +239,7 @@ func PatchApp(appId string, request *ModifyAppRequest) error {
return
nil
return
nil
}
}
func
CreateAppVersion
(
request
*
CreateAppVersionRequest
)
(
*
CreateAppVersionResponse
,
error
)
{
func
CreateAppVersion
(
request
*
types
.
CreateAppVersionRequest
)
(
*
types
.
CreateAppVersionResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -259,12 +261,12 @@ func CreateAppVersion(request *CreateAppVersionRequest) (*CreateAppVersionRespon
...
@@ -259,12 +261,12 @@ func CreateAppVersion(request *CreateAppVersionRequest) (*CreateAppVersionRespon
klog
.
Error
(
err
)
klog
.
Error
(
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
CreateAppVersionResponse
{
return
&
types
.
CreateAppVersionResponse
{
VersionId
:
resp
.
GetVersionId
()
.
GetValue
(),
VersionId
:
resp
.
GetVersionId
()
.
GetValue
(),
},
nil
},
nil
}
}
func
ValidatePackage
(
request
*
ValidatePackageRequest
)
(
*
ValidatePackageResponse
,
error
)
{
func
ValidatePackage
(
request
*
types
.
ValidatePackageRequest
)
(
*
types
.
ValidatePackageResponse
,
error
)
{
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -288,7 +290,7 @@ func ValidatePackage(request *ValidatePackageRequest) (*ValidatePackageResponse,
...
@@ -288,7 +290,7 @@ func ValidatePackage(request *ValidatePackageRequest) (*ValidatePackageResponse,
return
nil
,
err
return
nil
,
err
}
}
result
:=
&
ValidatePackageResponse
{}
result
:=
&
types
.
ValidatePackageResponse
{}
if
resp
.
Error
!=
nil
{
if
resp
.
Error
!=
nil
{
result
.
Error
=
resp
.
Error
.
Value
result
.
Error
=
resp
.
Error
.
Value
...
@@ -330,7 +332,7 @@ func DeleteAppVersion(id string) error {
...
@@ -330,7 +332,7 @@ func DeleteAppVersion(id string) error {
return
nil
return
nil
}
}
func
PatchAppVersion
(
id
string
,
request
*
ModifyAppVersionRequest
)
error
{
func
PatchAppVersion
(
id
string
,
request
*
types
.
ModifyAppVersionRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -361,7 +363,7 @@ func PatchAppVersion(id string, request *ModifyAppVersionRequest) error {
...
@@ -361,7 +363,7 @@ func PatchAppVersion(id string, request *ModifyAppVersionRequest) error {
return
nil
return
nil
}
}
func
DescribeAppVersion
(
id
string
)
(
*
AppVersion
,
error
)
{
func
DescribeAppVersion
(
id
string
)
(
*
types
.
AppVersion
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -376,10 +378,10 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
...
@@ -376,10 +378,10 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
return
nil
,
err
return
nil
,
err
}
}
var
app
*
AppVersion
var
app
*
types
.
AppVersion
if
len
(
resp
.
AppVersionSet
)
>
0
{
if
len
(
resp
.
AppVersionSet
)
>
0
{
app
=
c
onvertAppVersion
(
resp
.
AppVersionSet
[
0
])
app
=
utils
.
C
onvertAppVersion
(
resp
.
AppVersionSet
[
0
])
return
app
,
nil
return
app
,
nil
}
else
{
}
else
{
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
...
@@ -388,7 +390,7 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
...
@@ -388,7 +390,7 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
}
}
}
}
func
GetAppVersionPackage
(
appId
,
versionId
string
)
(
*
GetAppVersionPackageResponse
,
error
)
{
func
GetAppVersionPackage
(
appId
,
versionId
string
)
(
*
types
.
GetAppVersionPackageResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -402,7 +404,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
...
@@ -402,7 +404,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
return
nil
,
err
return
nil
,
err
}
}
app
:=
&
GetAppVersionPackageResponse
{
app
:=
&
types
.
GetAppVersionPackageResponse
{
AppId
:
appId
,
AppId
:
appId
,
VersionId
:
versionId
,
VersionId
:
versionId
,
}
}
...
@@ -414,7 +416,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
...
@@ -414,7 +416,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
return
app
,
nil
return
app
,
nil
}
}
func
DoAppAction
(
appId
string
,
request
*
ActionRequest
)
error
{
func
DoAppAction
(
appId
string
,
request
*
types
.
ActionRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -479,7 +481,7 @@ func DoAppAction(appId string, request *ActionRequest) error {
...
@@ -479,7 +481,7 @@ func DoAppAction(appId string, request *ActionRequest) error {
return
nil
return
nil
}
}
func
DoAppVersionAction
(
versionId
string
,
request
*
ActionRequest
)
error
{
func
DoAppVersionAction
(
versionId
string
,
request
*
types
.
ActionRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -529,7 +531,7 @@ func DoAppVersionAction(versionId string, request *ActionRequest) error {
...
@@ -529,7 +531,7 @@ func DoAppVersionAction(versionId string, request *ActionRequest) error {
return
nil
return
nil
}
}
func
GetAppVersionFiles
(
versionId
string
,
request
*
GetAppVersionFilesRequest
)
(
*
GetAppVersionPackageFilesResponse
,
error
)
{
func
GetAppVersionFiles
(
versionId
string
,
request
*
types
.
GetAppVersionFilesRequest
)
(
*
types
.
GetAppVersionPackageFilesResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -548,7 +550,7 @@ func GetAppVersionFiles(versionId string, request *GetAppVersionFilesRequest) (*
...
@@ -548,7 +550,7 @@ func GetAppVersionFiles(versionId string, request *GetAppVersionFilesRequest) (*
return
nil
,
err
return
nil
,
err
}
}
version
:=
&
GetAppVersionPackageFilesResponse
{
version
:=
&
types
.
GetAppVersionPackageFilesResponse
{
VersionId
:
versionId
,
VersionId
:
versionId
,
}
}
...
@@ -600,7 +602,7 @@ func ListAppVersionAudits(conditions *params.Conditions, orderBy string, reverse
...
@@ -600,7 +602,7 @@ func ListAppVersionAudits(conditions *params.Conditions, orderBy string, reverse
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
AppVersionAuditSet
{
for
_
,
item
:=
range
resp
.
AppVersionAuditSet
{
appVersion
:=
c
onvertAppVersionAudit
(
item
)
appVersion
:=
utils
.
C
onvertAppVersionAudit
(
item
)
items
=
append
(
items
,
appVersion
)
items
=
append
(
items
,
appVersion
)
}
}
...
@@ -640,7 +642,7 @@ func ListAppVersionReviews(conditions *params.Conditions, orderBy string, revers
...
@@ -640,7 +642,7 @@ func ListAppVersionReviews(conditions *params.Conditions, orderBy string, revers
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
AppVersionReviewSet
{
for
_
,
item
:=
range
resp
.
AppVersionReviewSet
{
appVersion
:=
c
onvertAppVersionReview
(
item
)
appVersion
:=
utils
.
C
onvertAppVersionReview
(
item
)
items
=
append
(
items
,
appVersion
)
items
=
append
(
items
,
appVersion
)
}
}
...
@@ -682,7 +684,7 @@ func ListAppVersions(conditions *params.Conditions, orderBy string, reverse bool
...
@@ -682,7 +684,7 @@ func ListAppVersions(conditions *params.Conditions, orderBy string, reverse bool
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
AppVersionSet
{
for
_
,
item
:=
range
resp
.
AppVersionSet
{
appVersion
:=
c
onvertAppVersion
(
item
)
appVersion
:=
utils
.
C
onvertAppVersion
(
item
)
items
=
append
(
items
,
appVersion
)
items
=
append
(
items
,
appVersion
)
}
}
...
...
pkg/models/openpitrix/applications.go
→
pkg/models/openpitrix/application
/application
s.go
浏览文件 @
c40d1542
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
limitations under the License.
limitations under the License.
*/
*/
package
openpitrix
package
application
import
(
import
(
"fmt"
"fmt"
...
@@ -32,6 +32,8 @@ import (
...
@@ -32,6 +32,8 @@ import (
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
...
@@ -42,8 +44,8 @@ import (
...
@@ -42,8 +44,8 @@ import (
type
Interface
interface
{
type
Interface
interface
{
List
(
conditions
*
params
.
Conditions
,
limit
,
offset
int
,
orderBy
string
,
reverse
bool
)
(
*
models
.
PageableResponse
,
error
)
List
(
conditions
*
params
.
Conditions
,
limit
,
offset
int
,
orderBy
string
,
reverse
bool
)
(
*
models
.
PageableResponse
,
error
)
Get
(
namespace
,
clusterID
string
)
(
*
Application
,
error
)
Get
(
namespace
,
clusterID
string
)
(
*
Application
,
error
)
Create
(
namespace
string
,
request
CreateClusterRequest
)
error
Create
(
namespace
string
,
request
types
.
CreateClusterRequest
)
error
Patch
(
request
ModifyClusterAttributesRequest
)
error
Patch
(
request
types
.
ModifyClusterAttributesRequest
)
error
Delete
(
id
string
)
error
Delete
(
id
string
)
error
}
}
...
@@ -61,9 +63,9 @@ func NewApplicaitonOperator(informers informers.SharedInformerFactory, client pb
...
@@ -61,9 +63,9 @@ func NewApplicaitonOperator(informers informers.SharedInformerFactory, client pb
type
Application
struct
{
type
Application
struct
{
Name
string
`json:"name" description:"application name"`
Name
string
`json:"name" description:"application name"`
Cluster
*
Cluster
`json:"cluster,omitempty" description:"application cluster info"`
Cluster
*
types
.
Cluster
`json:"cluster,omitempty" description:"application cluster info"`
Version
*
AppVersion
`json:"version,omitempty" description:"application template version info"`
Version
*
types
.
AppVersion
`json:"version,omitempty" description:"application template version info"`
App
*
App
`json:"app,omitempty" description:"application template info"`
App
*
types
.
App
`json:"app,omitempty" description:"application template info"`
WorkLoads
*
workLoads
`json:"workloads,omitempty" description:"application workloads"`
WorkLoads
*
workLoads
`json:"workloads,omitempty" description:"application workloads"`
Services
[]
v1
.
Service
`json:"services,omitempty" description:"application services"`
Services
[]
v1
.
Service
`json:"services,omitempty" description:"application services"`
Ingresses
[]
v1beta1
.
Ingress
`json:"ingresses,omitempty" description:"application ingresses"`
Ingresses
[]
v1beta1
.
Ingress
`json:"ingresses,omitempty" description:"application ingresses"`
...
@@ -130,14 +132,14 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
...
@@ -130,14 +132,14 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
}
}
var
app
Application
var
app
Application
app
.
Name
=
cluster
.
Name
.
Value
app
.
Name
=
cluster
.
Name
.
Value
app
.
Cluster
=
c
onvertCluster
(
cluster
)
app
.
Cluster
=
utils
.
C
onvertCluster
(
cluster
)
versionInfo
,
err
:=
op
.
App
()
.
DescribeAppVersions
(
openpitrix
.
SystemContext
(),
&
pb
.
DescribeAppVersionsRequest
{
VersionId
:
[]
string
{
cluster
.
GetVersionId
()
.
GetValue
()}})
versionInfo
,
err
:=
op
.
App
()
.
DescribeAppVersions
(
openpitrix
.
SystemContext
(),
&
pb
.
DescribeAppVersionsRequest
{
VersionId
:
[]
string
{
cluster
.
GetVersionId
()
.
GetValue
()}})
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorln
(
err
)
klog
.
Errorln
(
err
)
return
nil
,
err
return
nil
,
err
}
}
if
len
(
versionInfo
.
AppVersionSet
)
>
0
{
if
len
(
versionInfo
.
AppVersionSet
)
>
0
{
app
.
Version
=
c
onvertAppVersion
(
versionInfo
.
AppVersionSet
[
0
])
app
.
Version
=
utils
.
C
onvertAppVersion
(
versionInfo
.
AppVersionSet
[
0
])
}
}
appInfo
,
err
:=
op
.
App
()
.
DescribeApps
(
openpitrix
.
SystemContext
(),
&
pb
.
DescribeAppsRequest
{
AppId
:
[]
string
{
cluster
.
GetAppId
()
.
GetValue
()},
Limit
:
1
})
appInfo
,
err
:=
op
.
App
()
.
DescribeApps
(
openpitrix
.
SystemContext
(),
&
pb
.
DescribeAppsRequest
{
AppId
:
[]
string
{
cluster
.
GetAppId
()
.
GetValue
()},
Limit
:
1
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -145,7 +147,7 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
...
@@ -145,7 +147,7 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
return
nil
,
err
return
nil
,
err
}
}
if
len
(
appInfo
.
AppSet
)
>
0
{
if
len
(
appInfo
.
AppSet
)
>
0
{
app
.
App
=
c
onvertApp
(
appInfo
.
GetAppSet
()[
0
])
app
.
App
=
utils
.
C
onvertApp
(
appInfo
.
GetAppSet
()[
0
])
}
}
return
&
app
,
nil
return
&
app
,
nil
}
}
...
@@ -350,7 +352,7 @@ func (c *applicationOperator) getIng(namespace string, services []v1.Service) []
...
@@ -350,7 +352,7 @@ func (c *applicationOperator) getIng(namespace string, services []v1.Service) []
return
ings
return
ings
}
}
func
(
c
*
applicationOperator
)
Create
(
namespace
string
,
request
CreateClusterRequest
)
error
{
func
(
c
*
applicationOperator
)
Create
(
namespace
string
,
request
types
.
CreateClusterRequest
)
error
{
ns
,
err
:=
c
.
informers
.
Core
()
.
V1
()
.
Namespaces
()
.
Lister
()
.
Get
(
namespace
)
ns
,
err
:=
c
.
informers
.
Core
()
.
V1
()
.
Namespaces
()
.
Lister
()
.
Get
(
namespace
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -385,7 +387,7 @@ func (c *applicationOperator) Create(namespace string, request CreateClusterRequ
...
@@ -385,7 +387,7 @@ func (c *applicationOperator) Create(namespace string, request CreateClusterRequ
return
nil
return
nil
}
}
func
(
c
*
applicationOperator
)
Patch
(
request
ModifyClusterAttributesRequest
)
error
{
func
(
c
*
applicationOperator
)
Patch
(
request
types
.
ModifyClusterAttributesRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/models/openpitrix/attachments.go
→
pkg/models/openpitrix/attachment
/attachment
s.go
浏览文件 @
c40d1542
...
@@ -16,18 +16,20 @@
...
@@ -16,18 +16,20 @@
* /
* /
*/
*/
package
openpitrix
package
attachment
import
(
import
(
"google.golang.org/grpc/codes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"openpitrix.io/openpitrix/pkg/pb"
"openpitrix.io/openpitrix/pkg/pb"
)
)
func
DescribeAttachment
(
id
string
)
(
*
Attachment
,
error
)
{
func
DescribeAttachment
(
id
string
)
(
*
types
.
Attachment
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -41,7 +43,7 @@ func DescribeAttachment(id string) (*Attachment, error) {
...
@@ -41,7 +43,7 @@ func DescribeAttachment(id string) (*Attachment, error) {
return
nil
,
err
return
nil
,
err
}
}
if
len
(
resp
.
Attachments
)
>
0
{
if
len
(
resp
.
Attachments
)
>
0
{
return
c
onvertAttachment
(
resp
.
Attachments
[
id
]),
nil
return
utils
.
C
onvertAttachment
(
resp
.
Attachments
[
id
]),
nil
}
else
{
}
else
{
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
...
pkg/models/openpitrix/categories.go
→
pkg/models/openpitrix/categor
y/categor
ies.go
浏览文件 @
c40d1542
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
* /
* /
*/
*/
package
openpitrix
package
category
import
(
import
(
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/golang/protobuf/ptypes/wrappers"
...
@@ -24,13 +24,15 @@ import (
...
@@ -24,13 +24,15 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"openpitrix.io/openpitrix/pkg/pb"
"openpitrix.io/openpitrix/pkg/pb"
)
)
func
CreateCategory
(
request
*
CreateCategoryRequest
)
(
*
CreateCategoryResponse
,
error
)
{
func
CreateCategory
(
request
*
types
.
CreateCategoryRequest
)
(
*
types
.
CreateCategoryResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -50,7 +52,7 @@ func CreateCategory(request *CreateCategoryRequest) (*CreateCategoryResponse, er
...
@@ -50,7 +52,7 @@ func CreateCategory(request *CreateCategoryRequest) (*CreateCategoryResponse, er
klog
.
Error
(
err
)
klog
.
Error
(
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
CreateCategoryResponse
{
return
&
types
.
CreateCategoryResponse
{
CategoryId
:
resp
.
GetCategoryId
()
.
GetValue
(),
CategoryId
:
resp
.
GetCategoryId
()
.
GetValue
(),
},
nil
},
nil
}
}
...
@@ -71,7 +73,7 @@ func DeleteCategory(id string) error {
...
@@ -71,7 +73,7 @@ func DeleteCategory(id string) error {
return
nil
return
nil
}
}
func
PatchCategory
(
id
string
,
request
*
ModifyCategoryRequest
)
error
{
func
PatchCategory
(
id
string
,
request
*
types
.
ModifyCategoryRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -101,7 +103,7 @@ func PatchCategory(id string, request *ModifyCategoryRequest) error {
...
@@ -101,7 +103,7 @@ func PatchCategory(id string, request *ModifyCategoryRequest) error {
return
nil
return
nil
}
}
func
DescribeCategory
(
id
string
)
(
*
Category
,
error
)
{
func
DescribeCategory
(
id
string
)
(
*
types
.
Category
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -116,10 +118,10 @@ func DescribeCategory(id string) (*Category, error) {
...
@@ -116,10 +118,10 @@ func DescribeCategory(id string) (*Category, error) {
return
nil
,
err
return
nil
,
err
}
}
var
category
*
Category
var
category
*
types
.
Category
if
len
(
resp
.
CategorySet
)
>
0
{
if
len
(
resp
.
CategorySet
)
>
0
{
category
=
c
onvertCategory
(
resp
.
CategorySet
[
0
])
category
=
utils
.
C
onvertCategory
(
resp
.
CategorySet
[
0
])
return
category
,
nil
return
category
,
nil
}
else
{
}
else
{
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
...
@@ -156,7 +158,7 @@ func ListCategories(conditions *params.Conditions, orderBy string, reverse bool,
...
@@ -156,7 +158,7 @@ func ListCategories(conditions *params.Conditions, orderBy string, reverse bool,
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
CategorySet
{
for
_
,
item
:=
range
resp
.
CategorySet
{
items
=
append
(
items
,
c
onvertCategory
(
item
))
items
=
append
(
items
,
utils
.
C
onvertCategory
(
item
))
}
}
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
...
...
pkg/models/openpitrix/repos.go
→
pkg/models/openpitrix/repo
/repo
s.go
浏览文件 @
c40d1542
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
* /
* /
*/
*/
package
openpitrix
package
repo
import
(
import
(
"fmt"
"fmt"
...
@@ -25,6 +25,8 @@ import (
...
@@ -25,6 +25,8 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
"kubesphere.io/kubesphere/pkg/server/params"
"kubesphere.io/kubesphere/pkg/server/params"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
cs
"kubesphere.io/kubesphere/pkg/simple/client"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
...
@@ -32,7 +34,7 @@ import (
...
@@ -32,7 +34,7 @@ import (
"strings"
"strings"
)
)
func
CreateRepo
(
request
*
CreateRepoRequest
)
(
*
CreateRepoResponse
,
error
)
{
func
CreateRepo
(
request
*
types
.
CreateRepoRequest
)
(
*
types
.
CreateRepoResponse
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -61,7 +63,7 @@ func CreateRepo(request *CreateRepoRequest) (*CreateRepoResponse, error) {
...
@@ -61,7 +63,7 @@ func CreateRepo(request *CreateRepoRequest) (*CreateRepoResponse, error) {
klog
.
Error
(
err
)
klog
.
Error
(
err
)
return
nil
,
err
return
nil
,
err
}
}
return
&
CreateRepoResponse
{
return
&
types
.
CreateRepoResponse
{
RepoID
:
resp
.
GetRepoId
()
.
GetValue
(),
RepoID
:
resp
.
GetRepoId
()
.
GetValue
(),
},
nil
},
nil
}
}
...
@@ -82,7 +84,7 @@ func DeleteRepo(id string) error {
...
@@ -82,7 +84,7 @@ func DeleteRepo(id string) error {
return
nil
return
nil
}
}
func
PatchRepo
(
id
string
,
request
*
ModifyRepoRequest
)
error
{
func
PatchRepo
(
id
string
,
request
*
types
.
ModifyRepoRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -132,7 +134,7 @@ func PatchRepo(id string, request *ModifyRepoRequest) error {
...
@@ -132,7 +134,7 @@ func PatchRepo(id string, request *ModifyRepoRequest) error {
return
nil
return
nil
}
}
func
DescribeRepo
(
id
string
)
(
*
Repo
,
error
)
{
func
DescribeRepo
(
id
string
)
(
*
types
.
Repo
,
error
)
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -147,10 +149,10 @@ func DescribeRepo(id string) (*Repo, error) {
...
@@ -147,10 +149,10 @@ func DescribeRepo(id string) (*Repo, error) {
return
nil
,
err
return
nil
,
err
}
}
var
repo
*
Repo
var
repo
*
types
.
Repo
if
len
(
resp
.
RepoSet
)
>
0
{
if
len
(
resp
.
RepoSet
)
>
0
{
repo
=
c
onvertRepo
(
resp
.
RepoSet
[
0
])
repo
=
utils
.
C
onvertRepo
(
resp
.
RepoSet
[
0
])
return
repo
,
nil
return
repo
,
nil
}
else
{
}
else
{
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
err
:=
status
.
New
(
codes
.
NotFound
,
"resource not found"
)
.
Err
()
...
@@ -202,13 +204,13 @@ func ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limi
...
@@ -202,13 +204,13 @@ func ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limi
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
RepoSet
{
for
_
,
item
:=
range
resp
.
RepoSet
{
items
=
append
(
items
,
c
onvertRepo
(
item
))
items
=
append
(
items
,
utils
.
C
onvertRepo
(
item
))
}
}
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
}
}
func
ValidateRepo
(
request
*
ValidateRepoRequest
)
(
*
ValidateRepoResponse
,
error
)
{
func
ValidateRepo
(
request
*
types
.
ValidateRepoRequest
)
(
*
types
.
ValidateRepoResponse
,
error
)
{
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
client
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -227,13 +229,13 @@ func ValidateRepo(request *ValidateRepoRequest) (*ValidateRepoResponse, error) {
...
@@ -227,13 +229,13 @@ func ValidateRepo(request *ValidateRepoRequest) (*ValidateRepoResponse, error) {
return
nil
,
err
return
nil
,
err
}
}
return
&
ValidateRepoResponse
{
return
&
types
.
ValidateRepoResponse
{
ErrorCode
:
int64
(
resp
.
ErrorCode
),
ErrorCode
:
int64
(
resp
.
ErrorCode
),
Ok
:
resp
.
Ok
.
Value
,
Ok
:
resp
.
Ok
.
Value
,
},
nil
},
nil
}
}
func
DoRepoAction
(
repoId
string
,
request
*
RepoActionRequest
)
error
{
func
DoRepoAction
(
repoId
string
,
request
*
types
.
RepoActionRequest
)
error
{
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
op
,
err
:=
cs
.
ClientSets
()
.
OpenPitrix
()
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
err
)
klog
.
Error
(
err
)
...
@@ -289,7 +291,7 @@ func ListRepoEvents(repoId string, conditions *params.Conditions, limit, offset
...
@@ -289,7 +291,7 @@ func ListRepoEvents(repoId string, conditions *params.Conditions, limit, offset
items
:=
make
([]
interface
{},
0
)
items
:=
make
([]
interface
{},
0
)
for
_
,
item
:=
range
resp
.
RepoEventSet
{
for
_
,
item
:=
range
resp
.
RepoEventSet
{
items
=
append
(
items
,
c
onvertRepoEvent
(
item
))
items
=
append
(
items
,
utils
.
C
onvertRepoEvent
(
item
))
}
}
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
return
&
models
.
PageableResponse
{
Items
:
items
,
TotalCount
:
int
(
resp
.
TotalCount
)},
nil
...
...
pkg/models/openpitrix/types.go
→
pkg/models/openpitrix/types
/types
.go
浏览文件 @
c40d1542
package
openpitrix
package
types
import
(
import
(
"github.com/go-openapi/strfmt"
"github.com/go-openapi/strfmt"
...
...
pkg/models/openpitrix/convert.go
→
pkg/models/openpitrix/
utils/
convert.go
浏览文件 @
c40d1542
...
@@ -16,28 +16,29 @@
...
@@ -16,28 +16,29 @@
* /
* /
*/
*/
package
openpitrix
package
utils
import
(
import
(
"github.com/go-openapi/strfmt"
"github.com/go-openapi/strfmt"
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
"openpitrix.io/openpitrix/pkg/pb"
"openpitrix.io/openpitrix/pkg/pb"
"time"
"time"
)
)
func
convertApp
(
in
*
pb
.
App
)
*
App
{
func
ConvertApp
(
in
*
pb
.
App
)
*
types
.
App
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
categorySet
:=
make
(
AppCategorySet
,
0
)
categorySet
:=
make
(
types
.
AppCategorySet
,
0
)
for
_
,
item
:=
range
in
.
CategorySet
{
for
_
,
item
:=
range
in
.
CategorySet
{
category
:=
c
onvertResourceCategory
(
item
)
category
:=
C
onvertResourceCategory
(
item
)
categorySet
=
append
(
categorySet
,
category
)
categorySet
=
append
(
categorySet
,
category
)
}
}
out
:=
App
{
out
:=
types
.
App
{
CategorySet
:
categorySet
,
CategorySet
:
categorySet
,
}
}
...
@@ -92,7 +93,7 @@ func convertApp(in *pb.App) *App {
...
@@ -92,7 +93,7 @@ func convertApp(in *pb.App) *App {
out
.
Keywords
=
in
.
Keywords
.
Value
out
.
Keywords
=
in
.
Keywords
.
Value
}
}
if
in
.
LatestAppVersion
!=
nil
{
if
in
.
LatestAppVersion
!=
nil
{
out
.
LatestAppVersion
=
c
onvertAppVersion
(
in
.
LatestAppVersion
)
out
.
LatestAppVersion
=
C
onvertAppVersion
(
in
.
LatestAppVersion
)
}
}
if
in
.
Name
!=
nil
{
if
in
.
Name
!=
nil
{
out
.
Name
=
in
.
Name
.
Value
out
.
Name
=
in
.
Name
.
Value
...
@@ -130,11 +131,11 @@ func convertApp(in *pb.App) *App {
...
@@ -130,11 +131,11 @@ func convertApp(in *pb.App) *App {
return
&
out
return
&
out
}
}
func
convertAppVersion
(
in
*
pb
.
AppVersion
)
*
AppVersion
{
func
ConvertAppVersion
(
in
*
pb
.
AppVersion
)
*
types
.
AppVersion
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
AppVersion
{}
out
:=
types
.
AppVersion
{}
if
in
.
AppId
!=
nil
{
if
in
.
AppId
!=
nil
{
out
.
AppId
=
in
.
AppId
.
Value
out
.
AppId
=
in
.
AppId
.
Value
}
}
...
@@ -209,11 +210,11 @@ func convertAppVersion(in *pb.AppVersion) *AppVersion {
...
@@ -209,11 +210,11 @@ func convertAppVersion(in *pb.AppVersion) *AppVersion {
}
}
func
convertResourceCategory
(
in
*
pb
.
ResourceCategory
)
*
ResourceCategory
{
func
ConvertResourceCategory
(
in
*
pb
.
ResourceCategory
)
*
types
.
ResourceCategory
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
ResourceCategory
{}
out
:=
types
.
ResourceCategory
{}
if
in
.
CategoryId
!=
nil
{
if
in
.
CategoryId
!=
nil
{
out
.
CategoryId
=
in
.
CategoryId
.
Value
out
.
CategoryId
=
in
.
CategoryId
.
Value
...
@@ -239,11 +240,11 @@ func convertResourceCategory(in *pb.ResourceCategory) *ResourceCategory {
...
@@ -239,11 +240,11 @@ func convertResourceCategory(in *pb.ResourceCategory) *ResourceCategory {
return
&
out
return
&
out
}
}
func
convertCategory
(
in
*
pb
.
Category
)
*
Category
{
func
ConvertCategory
(
in
*
pb
.
Category
)
*
types
.
Category
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
Category
{}
out
:=
types
.
Category
{}
if
in
.
CategoryId
!=
nil
{
if
in
.
CategoryId
!=
nil
{
out
.
CategoryID
=
in
.
CategoryId
.
Value
out
.
CategoryID
=
in
.
CategoryId
.
Value
...
@@ -275,11 +276,11 @@ func convertCategory(in *pb.Category) *Category {
...
@@ -275,11 +276,11 @@ func convertCategory(in *pb.Category) *Category {
return
&
out
return
&
out
}
}
func
convertAttachment
(
in
*
pb
.
Attachment
)
*
Attachment
{
func
ConvertAttachment
(
in
*
pb
.
Attachment
)
*
types
.
Attachment
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
Attachment
{}
out
:=
types
.
Attachment
{}
out
.
AttachmentID
=
in
.
AttachmentId
out
.
AttachmentID
=
in
.
AttachmentId
...
@@ -297,11 +298,11 @@ func convertAttachment(in *pb.Attachment) *Attachment {
...
@@ -297,11 +298,11 @@ func convertAttachment(in *pb.Attachment) *Attachment {
return
&
out
return
&
out
}
}
func
convertRepo
(
in
*
pb
.
Repo
)
*
Repo
{
func
ConvertRepo
(
in
*
pb
.
Repo
)
*
types
.
Repo
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
Repo
{}
out
:=
types
.
Repo
{}
if
in
.
RepoId
!=
nil
{
if
in
.
RepoId
!=
nil
{
out
.
RepoId
=
in
.
RepoId
.
Value
out
.
RepoId
=
in
.
RepoId
.
Value
...
@@ -316,10 +317,10 @@ func convertRepo(in *pb.Repo) *Repo {
...
@@ -316,10 +317,10 @@ func convertRepo(in *pb.Repo) *Repo {
out
.
Credential
=
in
.
Credential
.
Value
out
.
Credential
=
in
.
Credential
.
Value
}
}
categorySet
:=
make
(
RepoCategorySet
,
0
)
categorySet
:=
make
(
types
.
RepoCategorySet
,
0
)
for
_
,
item
:=
range
in
.
CategorySet
{
for
_
,
item
:=
range
in
.
CategorySet
{
category
:=
c
onvertResourceCategory
(
item
)
category
:=
C
onvertResourceCategory
(
item
)
categorySet
=
append
(
categorySet
,
category
)
categorySet
=
append
(
categorySet
,
category
)
}
}
...
@@ -338,10 +339,10 @@ func convertRepo(in *pb.Repo) *Repo {
...
@@ -338,10 +339,10 @@ func convertRepo(in *pb.Repo) *Repo {
out
.
Description
=
in
.
Description
.
Value
out
.
Description
=
in
.
Description
.
Value
}
}
labelSet
:=
make
(
RepoLabels
,
0
)
labelSet
:=
make
(
types
.
RepoLabels
,
0
)
for
_
,
item
:=
range
in
.
Labels
{
for
_
,
item
:=
range
in
.
Labels
{
label
:=
c
onvertRepoLabel
(
item
)
label
:=
C
onvertRepoLabel
(
item
)
labelSet
=
append
(
labelSet
,
label
)
labelSet
=
append
(
labelSet
,
label
)
}
}
...
@@ -357,10 +358,10 @@ func convertRepo(in *pb.Repo) *Repo {
...
@@ -357,10 +358,10 @@ func convertRepo(in *pb.Repo) *Repo {
out
.
RepoId
=
in
.
RepoId
.
Value
out
.
RepoId
=
in
.
RepoId
.
Value
}
}
selectorSet
:=
make
(
RepoSelectors
,
0
)
selectorSet
:=
make
(
types
.
RepoSelectors
,
0
)
for
_
,
item
:=
range
in
.
Selectors
{
for
_
,
item
:=
range
in
.
Selectors
{
selector
:=
c
onvertRepoSelector
(
item
)
selector
:=
C
onvertRepoSelector
(
item
)
selectorSet
=
append
(
selectorSet
,
selector
)
selectorSet
=
append
(
selectorSet
,
selector
)
}
}
...
@@ -384,11 +385,11 @@ func convertRepo(in *pb.Repo) *Repo {
...
@@ -384,11 +385,11 @@ func convertRepo(in *pb.Repo) *Repo {
return
&
out
return
&
out
}
}
func
convertRepoLabel
(
in
*
pb
.
RepoLabel
)
*
RepoLabel
{
func
ConvertRepoLabel
(
in
*
pb
.
RepoLabel
)
*
types
.
RepoLabel
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
RepoLabel
{}
out
:=
types
.
RepoLabel
{}
if
in
.
CreateTime
!=
nil
{
if
in
.
CreateTime
!=
nil
{
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
out
.
CreateTime
=
&
date
out
.
CreateTime
=
&
date
...
@@ -402,11 +403,11 @@ func convertRepoLabel(in *pb.RepoLabel) *RepoLabel {
...
@@ -402,11 +403,11 @@ func convertRepoLabel(in *pb.RepoLabel) *RepoLabel {
return
&
out
return
&
out
}
}
func
convertRepoSelector
(
in
*
pb
.
RepoSelector
)
*
RepoSelector
{
func
ConvertRepoSelector
(
in
*
pb
.
RepoSelector
)
*
types
.
RepoSelector
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
RepoSelector
{}
out
:=
types
.
RepoSelector
{}
if
in
.
CreateTime
!=
nil
{
if
in
.
CreateTime
!=
nil
{
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
out
.
CreateTime
=
&
date
out
.
CreateTime
=
&
date
...
@@ -420,11 +421,11 @@ func convertRepoSelector(in *pb.RepoSelector) *RepoSelector {
...
@@ -420,11 +421,11 @@ func convertRepoSelector(in *pb.RepoSelector) *RepoSelector {
return
&
out
return
&
out
}
}
func
convertAppVersionAudit
(
in
*
pb
.
AppVersionAudit
)
*
AppVersionAudit
{
func
ConvertAppVersionAudit
(
in
*
pb
.
AppVersionAudit
)
*
types
.
AppVersionAudit
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
AppVersionAudit
{}
out
:=
types
.
AppVersionAudit
{}
if
in
.
AppId
!=
nil
{
if
in
.
AppId
!=
nil
{
out
.
AppId
=
in
.
AppId
.
Value
out
.
AppId
=
in
.
AppId
.
Value
}
}
...
@@ -462,11 +463,11 @@ func convertAppVersionAudit(in *pb.AppVersionAudit) *AppVersionAudit {
...
@@ -462,11 +463,11 @@ func convertAppVersionAudit(in *pb.AppVersionAudit) *AppVersionAudit {
return
&
out
return
&
out
}
}
func
convertAppVersionReview
(
in
*
pb
.
AppVersionReview
)
*
AppVersionReview
{
func
ConvertAppVersionReview
(
in
*
pb
.
AppVersionReview
)
*
types
.
AppVersionReview
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
AppVersionReview
{}
out
:=
types
.
AppVersionReview
{}
if
in
.
AppId
!=
nil
{
if
in
.
AppId
!=
nil
{
out
.
AppId
=
in
.
AppId
.
Value
out
.
AppId
=
in
.
AppId
.
Value
}
}
...
@@ -474,9 +475,9 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
...
@@ -474,9 +475,9 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
out
.
AppName
=
in
.
AppName
.
Value
out
.
AppName
=
in
.
AppName
.
Value
}
}
if
in
.
Phase
!=
nil
{
if
in
.
Phase
!=
nil
{
out
.
Phase
=
make
(
AppVersionReviewPhaseOAIGen
)
out
.
Phase
=
make
(
types
.
AppVersionReviewPhaseOAIGen
)
for
k
,
v
:=
range
in
.
Phase
{
for
k
,
v
:=
range
in
.
Phase
{
out
.
Phase
[
k
]
=
*
c
onvertAppVersionReviewPhase
(
v
)
out
.
Phase
[
k
]
=
*
C
onvertAppVersionReviewPhase
(
v
)
}
}
}
}
if
in
.
ReviewId
!=
nil
{
if
in
.
ReviewId
!=
nil
{
...
@@ -503,11 +504,11 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
...
@@ -503,11 +504,11 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
return
&
out
return
&
out
}
}
func
convertAppVersionReviewPhase
(
in
*
pb
.
AppVersionReviewPhase
)
*
AppVersionReviewPhase
{
func
ConvertAppVersionReviewPhase
(
in
*
pb
.
AppVersionReviewPhase
)
*
types
.
AppVersionReviewPhase
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
AppVersionReviewPhase
{}
out
:=
types
.
AppVersionReviewPhase
{}
if
in
.
Message
!=
nil
{
if
in
.
Message
!=
nil
{
out
.
Message
=
in
.
Message
.
Value
out
.
Message
=
in
.
Message
.
Value
}
}
...
@@ -531,11 +532,11 @@ func convertAppVersionReviewPhase(in *pb.AppVersionReviewPhase) *AppVersionRevie
...
@@ -531,11 +532,11 @@ func convertAppVersionReviewPhase(in *pb.AppVersionReviewPhase) *AppVersionRevie
return
&
out
return
&
out
}
}
func
convertRepoEvent
(
in
*
pb
.
RepoEvent
)
*
RepoEvent
{
func
ConvertRepoEvent
(
in
*
pb
.
RepoEvent
)
*
types
.
RepoEvent
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
RepoEvent
{}
out
:=
types
.
RepoEvent
{}
if
in
.
CreateTime
!=
nil
{
if
in
.
CreateTime
!=
nil
{
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
date
:=
strfmt
.
DateTime
(
time
.
Unix
(
in
.
CreateTime
.
Seconds
,
0
))
out
.
CreateTime
=
&
date
out
.
CreateTime
=
&
date
...
@@ -563,11 +564,11 @@ func convertRepoEvent(in *pb.RepoEvent) *RepoEvent {
...
@@ -563,11 +564,11 @@ func convertRepoEvent(in *pb.RepoEvent) *RepoEvent {
return
&
out
return
&
out
}
}
func
convertCluster
(
in
*
pb
.
Cluster
)
*
Cluster
{
func
ConvertCluster
(
in
*
pb
.
Cluster
)
*
types
.
Cluster
{
if
in
==
nil
{
if
in
==
nil
{
return
nil
return
nil
}
}
out
:=
Cluster
{}
out
:=
types
.
Cluster
{}
if
in
.
AdditionalInfo
!=
nil
{
if
in
.
AdditionalInfo
!=
nil
{
out
.
AdditionalInfo
=
in
.
AdditionalInfo
.
Value
out
.
AdditionalInfo
=
in
.
AdditionalInfo
.
Value
}
}
...
...
pkg/models/resources/v1alpha2/application/appplications.go
浏览文件 @
c40d1542
...
@@ -132,9 +132,7 @@ func (s *appSearcher) Search(namespace string, conditions *params.Conditions, or
...
@@ -132,9 +132,7 @@ func (s *appSearcher) Search(namespace string, conditions *params.Conditions, or
}
}
sort
.
Slice
(
result
,
func
(
i
,
j
int
)
bool
{
sort
.
Slice
(
result
,
func
(
i
,
j
int
)
bool
{
if
reverse
{
if
reverse
{
tmp
:=
i
i
,
j
=
j
,
i
i
=
j
j
=
tmp
}
}
return
s
.
compare
(
result
[
i
],
result
[
j
],
orderBy
)
return
s
.
compare
(
result
[
i
],
result
[
j
],
orderBy
)
})
})
...
...
pkg/models/resources/v1alpha3/deployment/deployments.go
浏览文件 @
c40d1542
...
@@ -18,7 +18,9 @@
...
@@ -18,7 +18,9 @@
package
deployment
package
deployment
import
(
import
(
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/informers"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"strings"
"strings"
...
@@ -46,26 +48,26 @@ func New(sharedInformers informers.SharedInformerFactory) v1alpha3.Interface {
...
@@ -46,26 +48,26 @@ func New(sharedInformers informers.SharedInformerFactory) v1alpha3.Interface {
return
&
deploymentsGetter
{
sharedInformers
:
sharedInformers
}
return
&
deploymentsGetter
{
sharedInformers
:
sharedInformers
}
}
}
func
(
d
*
deploymentsGetter
)
Get
(
namespace
,
name
string
)
(
interface
{}
,
error
)
{
func
(
d
*
deploymentsGetter
)
Get
(
namespace
,
name
string
)
(
runtime
.
Object
,
error
)
{
return
d
.
sharedInformers
.
Apps
()
.
V1
()
.
Deployments
()
.
Lister
()
.
Deployments
(
namespace
)
.
Get
(
name
)
return
d
.
sharedInformers
.
Apps
()
.
V1
()
.
Deployments
()
.
Lister
()
.
Deployments
(
namespace
)
.
Get
(
name
)
}
}
func
(
d
*
deploymentsGetter
)
List
(
namespace
string
)
([]
interface
{}
,
error
)
{
func
(
d
*
deploymentsGetter
)
List
(
namespace
string
,
query
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
{
// first retrieves all deployments within given namespace
// first retrieves all deployments within given namespace
all
,
err
:=
d
.
sharedInformers
.
Apps
()
.
V1
()
.
Deployments
()
.
Lister
()
.
Deployments
(
namespace
)
.
List
(
labels
.
Everything
())
all
,
err
:=
d
.
sharedInformers
.
Apps
()
.
V1
()
.
Deployments
()
.
Lister
()
.
Deployments
(
namespace
)
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
result
[]
interface
{}
var
result
[]
runtime
.
Object
for
_
,
deploy
:=
range
all
{
for
_
,
deploy
:=
range
all
{
result
=
append
(
result
,
deploy
)
result
=
append
(
result
,
deploy
)
}
}
return
result
,
nil
return
v1alpha3
.
DefaultList
(
result
,
query
,
d
.
compare
,
d
.
filter
)
,
nil
}
}
func
(
d
*
deploymentsGetter
)
Compare
(
left
interface
{},
right
interface
{}
,
field
query
.
Field
)
bool
{
func
(
d
*
deploymentsGetter
)
compare
(
left
runtime
.
Object
,
right
runtime
.
Object
,
field
query
.
Field
)
bool
{
leftDeployment
,
ok
:=
left
.
(
*
v1
.
Deployment
)
leftDeployment
,
ok
:=
left
.
(
*
v1
.
Deployment
)
if
!
ok
{
if
!
ok
{
...
@@ -89,7 +91,7 @@ func (d *deploymentsGetter) Compare(left interface{}, right interface{}, field q
...
@@ -89,7 +91,7 @@ func (d *deploymentsGetter) Compare(left interface{}, right interface{}, field q
}
}
}
}
func
(
d
*
deploymentsGetter
)
Filter
(
object
interface
{}
,
filter
query
.
Filter
)
bool
{
func
(
d
*
deploymentsGetter
)
filter
(
object
runtime
.
Object
,
filter
query
.
Filter
)
bool
{
deployment
,
ok
:=
object
.
(
*
v1
.
Deployment
)
deployment
,
ok
:=
object
.
(
*
v1
.
Deployment
)
if
!
ok
{
if
!
ok
{
return
false
return
false
...
...
pkg/models/resources/v1alpha3/deployment/deployments_test.go
浏览文件 @
c40d1542
...
@@ -125,7 +125,6 @@ func TestListDeployments(t *testing.T) {
...
@@ -125,7 +125,6 @@ func TestListDeployments(t *testing.T) {
t
.
Run
(
test
.
description
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
description
,
func
(
t
*
testing
.
T
)
{
objs
:=
deploymentsToRuntimeObjects
(
test
.
deployments
...
)
objs
:=
deploymentsToRuntimeObjects
(
test
.
deployments
...
)
client
:=
fake
.
NewSimpleClientset
(
objs
...
)
client
:=
fake
.
NewSimpleClientset
(
objs
...
)
//client := fake.NewSimpleClientset()
informer
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
informer
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
...
...
pkg/models/resources/v1alpha3/interface.go
浏览文件 @
c40d1542
package
v1alpha3
package
v1alpha3
import
(
import
(
"k8s.io/apimachinery/pkg/runtime"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"sort"
)
)
type
Interface
interface
{
type
Interface
interface
{
// Get retrieves a single object by its namespace and name
// Get retrieves a single object by its namespace and name
Get
(
namespace
,
name
string
)
(
interface
{}
,
error
)
Get
(
namespace
,
name
string
)
(
runtime
.
Object
,
error
)
// List retrieves a collection of objects matches given query
// List retrieves a collection of objects matches given query
List
(
namespace
string
)
([]
interface
{},
error
)
List
(
namespace
string
,
query
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
}
type
CompareFunc
func
(
runtime
.
Object
,
runtime
.
Object
,
query
.
Field
)
bool
type
FilterFunc
func
(
runtime
.
Object
,
query
.
Filter
)
bool
func
DefaultList
(
objects
[]
runtime
.
Object
,
query
*
query
.
Query
,
compareFunc
CompareFunc
,
filterFunc
FilterFunc
)
*
api
.
ListResult
{
// selected matched ones
var
filtered
[]
runtime
.
Object
for
_
,
object
:=
range
objects
{
selected
:=
true
for
_
,
filter
:=
range
query
.
Filters
{
if
!
filterFunc
(
object
,
filter
)
{
selected
=
false
break
}
}
//
if
selected
{
Filter
(
item
interface
{},
filter
query
.
Filter
)
bool
filtered
=
append
(
filtered
,
object
)
}
}
//
start
,
end
:=
query
.
Pagination
.
GetPaginationSettings
(
len
(
filtered
))
Compare
(
left
interface
{},
right
interface
{},
field
query
.
Field
)
bool
if
!
query
.
Pagination
.
IsPageAvailable
(
len
(
filtered
),
start
)
{
return
&
api
.
ListResult
{
Items
:
nil
,
TotalItems
:
0
,
}
}
// sort by sortBy field
sort
.
Slice
(
filtered
,
func
(
i
,
j
int
)
bool
{
if
!
query
.
Ascending
{
return
!
compareFunc
(
filtered
[
i
],
filtered
[
j
],
query
.
SortBy
)
}
return
compareFunc
(
filtered
[
i
],
filtered
[
j
],
query
.
SortBy
)
})
return
&
api
.
ListResult
{
Items
:
objectsToInterfaces
(
filtered
[
start
:
end
]),
TotalItems
:
len
(
filtered
),
}
}
}
func
objectsToInterfaces
(
objs
[]
runtime
.
Object
)
[]
interface
{}
{
var
res
[]
interface
{}
for
_
,
obj
:=
range
objs
{
res
=
append
(
res
,
obj
)
}
return
res
}
\ No newline at end of file
pkg/models/resources/v1alpha3/namespace/namespaces.go
0 → 100644
浏览文件 @
c40d1542
package
namespace
import
(
v1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"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"
"strings"
)
type
namespaceGetter
struct
{
informers
informers
.
SharedInformerFactory
}
func
NewNamespaceGetter
(
informers
informers
.
SharedInformerFactory
)
v1alpha3
.
Interface
{
return
&
namespaceGetter
{
informers
:
informers
}
}
func
(
n
namespaceGetter
)
Get
(
_
,
name
string
)
(
runtime
.
Object
,
error
)
{
return
n
.
informers
.
Core
()
.
V1
()
.
Namespaces
()
.
Lister
()
.
Get
(
name
)
}
func
(
n
namespaceGetter
)
List
(
_
string
,
query
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
{
ns
,
err
:=
n
.
informers
.
Core
()
.
V1
()
.
Namespaces
()
.
Lister
()
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
return
nil
,
err
}
var
result
[]
runtime
.
Object
for
_
,
item
:=
range
ns
{
result
=
append
(
result
,
item
)
}
return
v1alpha3
.
DefaultList
(
result
,
query
,
n
.
compare
,
n
.
filter
),
nil
}
func
(
n
namespaceGetter
)
filter
(
item
runtime
.
Object
,
filter
query
.
Filter
)
bool
{
namespace
,
ok
:=
item
.
(
*
v1
.
Namespace
)
if
!
ok
{
return
false
}
switch
filter
.
Field
{
case
query
.
FieldName
:
return
query
.
ComparableString
(
namespace
.
Name
)
.
Contains
(
filter
.
Value
)
case
query
.
FieldStatus
:
return
query
.
ComparableString
(
namespace
.
Status
.
Phase
)
.
Compare
(
filter
.
Value
)
==
0
default
:
return
false
}
}
func
(
n
namespaceGetter
)
compare
(
left
runtime
.
Object
,
right
runtime
.
Object
,
field
query
.
Field
)
bool
{
leftNs
,
ok
:=
left
.
(
*
v1
.
Namespace
)
if
!
ok
{
return
false
}
rightNs
,
ok
:=
right
.
(
*
v1
.
Namespace
)
if
!
ok
{
return
true
}
switch
field
{
case
query
.
FieldName
:
return
strings
.
Compare
(
leftNs
.
Name
,
rightNs
.
Name
)
>
0
case
query
.
FieldCreationTimeStamp
:
return
leftNs
.
CreationTimestamp
.
After
(
rightNs
.
CreationTimestamp
.
Time
)
default
:
return
false
}
}
\ No newline at end of file
pkg/models/resources/v1alpha3/namespace/namespaces_test.go
0 → 100644
浏览文件 @
c40d1542
package
namespace
pkg/models/resources/v1alpha3/resource/resource.go
浏览文件 @
c40d1542
...
@@ -3,12 +3,11 @@ package resource
...
@@ -3,12 +3,11 @@ package resource
import
(
import
(
"errors"
"errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/informers"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/deployment"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/deployment"
"sort"
)
)
var
ErrResourceNotSupported
=
errors
.
New
(
"resource is not supported"
)
var
ErrResourceNotSupported
=
errors
.
New
(
"resource is not supported"
)
...
@@ -17,10 +16,10 @@ type NamespacedResourceGetter struct {
...
@@ -17,10 +16,10 @@ type NamespacedResourceGetter struct {
getters
map
[
schema
.
GroupVersionResource
]
v1alpha3
.
Interface
getters
map
[
schema
.
GroupVersionResource
]
v1alpha3
.
Interface
}
}
func
New
(
informers
informers
.
Shared
InformerFactory
)
*
NamespacedResourceGetter
{
func
New
(
factory
informers
.
InformerFactory
)
*
NamespacedResourceGetter
{
getters
:=
make
(
map
[
schema
.
GroupVersionResource
]
v1alpha3
.
Interface
)
getters
:=
make
(
map
[
schema
.
GroupVersionResource
]
v1alpha3
.
Interface
)
getters
[
schema
.
GroupVersionResource
{
Group
:
"apps"
,
Version
:
"v1"
,
Resource
:
"deployments"
}]
=
deployment
.
New
(
informers
)
getters
[
schema
.
GroupVersionResource
{
Group
:
"apps"
,
Version
:
"v1"
,
Resource
:
"deployments"
}]
=
deployment
.
New
(
factory
.
KubernetesSharedInformerFactory
()
)
return
&
NamespacedResourceGetter
{
return
&
NamespacedResourceGetter
{
getters
:
getters
,
getters
:
getters
,
...
@@ -54,45 +53,6 @@ func (r *NamespacedResourceGetter) List(resource, namespace string, query *query
...
@@ -54,45 +53,6 @@ func (r *NamespacedResourceGetter) List(resource, namespace string, query *query
return
nil
,
ErrResourceNotSupported
return
nil
,
ErrResourceNotSupported
}
}
all
,
err
:=
getter
.
List
(
namespace
)
return
getter
.
List
(
namespace
,
query
)
if
err
!=
nil
{
return
nil
,
err
}
// selected matched ones
var
filtered
[]
interface
{}
for
_
,
deploy
:=
range
all
{
for
_
,
filter
:=
range
query
.
Filters
{
if
getter
.
Filter
(
deploy
,
filter
)
{
filtered
=
append
(
filtered
,
deploy
)
}
}
}
// sort
sort
.
Slice
(
filtered
,
func
(
i
,
j
int
)
bool
{
if
!
query
.
Ascending
{
return
!
getter
.
Compare
(
filtered
[
i
],
filtered
[
j
],
query
.
SortBy
)
}
return
getter
.
Compare
(
filtered
[
i
],
filtered
[
j
],
query
.
SortBy
)
})
start
,
end
:=
query
.
Pagination
.
GetPaginationSettings
(
len
(
filtered
))
if
query
.
Pagination
.
IsPageAvailable
(
len
(
filtered
),
start
)
{
var
result
[]
interface
{}
for
i
:=
start
;
i
<
end
;
i
++
{
result
=
append
(
result
,
filtered
[
i
])
}
return
&
api
.
ListResult
{
Items
:
result
,
TotalItems
:
len
(
filtered
),
},
nil
}
return
&
api
.
ListResult
{
Items
:
nil
,
TotalItems
:
len
(
filtered
),
},
nil
}
}
pkg/models/terminal/terminal.go
浏览文件 @
c40d1542
...
@@ -24,10 +24,11 @@ import (
...
@@ -24,10 +24,11 @@ import (
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"io"
"io"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/klog"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/simple/client"
"time"
"time"
)
)
...
@@ -134,15 +135,23 @@ func (t TerminalSession) Close(status uint32, reason string) {
...
@@ -134,15 +135,23 @@ func (t TerminalSession) Close(status uint32, reason string) {
t
.
conn
.
Close
()
t
.
conn
.
Close
()
}
}
// startProcess is called by handleAttach
type
Interface
interface
{
// Executed cmd in the container specified in request and connects it up with the ptyHandler (a sessio
n)
HandleSession
(
shell
,
namespace
,
podName
,
containerName
string
,
conn
*
websocket
.
Con
n
)
func
startProcess
(
namespace
,
podName
,
containerName
string
,
cmd
[]
string
,
ptyHandler
PtyHandler
)
error
{
}
k8sClient
:=
client
.
ClientSets
()
.
K8s
()
.
Kubernetes
()
type
terminaler
struct
{
client
kubernetes
.
Interface
config
*
rest
.
Config
}
cfg
:=
client
.
ClientSets
()
.
K8s
()
.
Config
()
func
NewTerminaler
(
client
kubernetes
.
Interface
,
config
*
rest
.
Config
)
Interface
{
return
&
terminaler
{
client
:
client
,
config
:
config
}
}
req
:=
k8sClient
.
CoreV1
()
.
RESTClient
()
.
Post
()
.
// startProcess is called by handleAttach
// Executed cmd in the container specified in request and connects it up with the ptyHandler (a session)
func
(
t
*
terminaler
)
startProcess
(
namespace
,
podName
,
containerName
string
,
cmd
[]
string
,
ptyHandler
PtyHandler
)
error
{
req
:=
t
.
client
.
CoreV1
()
.
RESTClient
()
.
Post
()
.
Resource
(
"pods"
)
.
Resource
(
"pods"
)
.
Name
(
podName
)
.
Name
(
podName
)
.
Namespace
(
namespace
)
.
Namespace
(
namespace
)
.
...
@@ -156,7 +165,7 @@ func startProcess(namespace, podName, containerName string, cmd []string, ptyHan
...
@@ -156,7 +165,7 @@ func startProcess(namespace, podName, containerName string, cmd []string, ptyHan
TTY
:
true
,
TTY
:
true
,
},
scheme
.
ParameterCodec
)
},
scheme
.
ParameterCodec
)
exec
,
err
:=
remotecommand
.
NewSPDYExecutor
(
cf
g
,
"POST"
,
req
.
URL
())
exec
,
err
:=
remotecommand
.
NewSPDYExecutor
(
t
.
confi
g
,
"POST"
,
req
.
URL
())
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -185,8 +194,7 @@ func isValidShell(validShells []string, shell string) bool {
...
@@ -185,8 +194,7 @@ func isValidShell(validShells []string, shell string) bool {
return
false
return
false
}
}
func
HandleSession
(
shell
,
namespace
,
podName
,
containerName
string
,
conn
*
websocket
.
Conn
)
{
func
(
t
*
terminaler
)
HandleSession
(
shell
,
namespace
,
podName
,
containerName
string
,
conn
*
websocket
.
Conn
)
{
var
err
error
var
err
error
validShells
:=
[]
string
{
"sh"
,
"bash"
}
validShells
:=
[]
string
{
"sh"
,
"bash"
}
...
@@ -194,13 +202,13 @@ func HandleSession(shell, namespace, podName, containerName string, conn *websoc
...
@@ -194,13 +202,13 @@ func HandleSession(shell, namespace, podName, containerName string, conn *websoc
if
isValidShell
(
validShells
,
shell
)
{
if
isValidShell
(
validShells
,
shell
)
{
cmd
:=
[]
string
{
shell
}
cmd
:=
[]
string
{
shell
}
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
)
err
=
t
.
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
)
}
else
{
}
else
{
// No shell given or it was not valid: try some shells until one succeeds or all fail
// No shell given or it was not valid: try some shells until one succeeds or all fail
// FIXME: if the first shell fails then the first keyboard event is lost
// FIXME: if the first shell fails then the first keyboard event is lost
for
_
,
testShell
:=
range
validShells
{
for
_
,
testShell
:=
range
validShells
{
cmd
:=
[]
string
{
testShell
}
cmd
:=
[]
string
{
testShell
}
if
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
);
err
==
nil
{
if
err
=
t
.
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
);
err
==
nil
{
break
break
}
}
}
}
...
...
pkg/simple/client/cache/cache.go
浏览文件 @
c40d1542
...
@@ -20,41 +20,4 @@ type Interface interface {
...
@@ -20,41 +20,4 @@ type Interface interface {
// Expires updates object's expiration time, return err if key doesn't exist
// Expires updates object's expiration time, return err if key doesn't exist
Expire
(
key
string
,
duration
time
.
Duration
)
error
Expire
(
key
string
,
duration
time
.
Duration
)
error
}
}
\ No newline at end of file
type
simpleObject
struct
{
value
string
expire
time
.
Time
}
type
SimpleCache
struct
{
store
map
[
string
]
simpleObject
}
func
NewSimpleCache
()
Interface
{
return
&
SimpleCache
{
store
:
make
(
map
[
string
]
simpleObject
)}
}
func
(
s
*
SimpleCache
)
Keys
(
pattern
string
)
([]
string
,
error
)
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Set
(
key
string
,
value
string
,
duration
time
.
Duration
)
error
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Del
(
key
string
)
error
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Get
(
key
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
s
*
SimpleCache
)
Exists
(
key
string
)
(
bool
,
error
)
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Expire
(
key
string
,
duration
time
.
Duration
)
error
{
panic
(
"implement me"
)
}
pkg/simple/client/cache/simple_cache.go
0 → 100644
浏览文件 @
c40d1542
package
cache
import
"time"
type
simpleObject
struct
{
value
string
expire
time
.
Time
}
type
SimpleCache
struct
{
store
map
[
string
]
simpleObject
}
func
NewSimpleCache
()
Interface
{
return
&
SimpleCache
{
store
:
make
(
map
[
string
]
simpleObject
)}
}
func
(
s
*
SimpleCache
)
Keys
(
pattern
string
)
([]
string
,
error
)
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Set
(
key
string
,
value
string
,
duration
time
.
Duration
)
error
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Del
(
key
string
)
error
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Get
(
key
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
s
*
SimpleCache
)
Exists
(
key
string
)
(
bool
,
error
)
{
panic
(
"implement me"
)
}
func
(
s
*
SimpleCache
)
Expire
(
key
string
,
duration
time
.
Duration
)
error
{
panic
(
"implement me"
)
}
pkg/simple/client/devops/interface.go
浏览文件 @
c40d1542
package
devops
package
devops
type
Job
struct
{
type
Job
struct
{
}
}
type
Interface
interface
{
type
Interface
interface
{
...
...
pkg/simple/client/monitoring/interface.go
0 → 100644
浏览文件 @
c40d1542
package
monitoring
type
ClusterQuery
struct
{
}
type
ClusterMetrics
struct
{
}
type
WorkspaceQuery
struct
{
}
type
WorkspaceMetrics
struct
{
}
type
NamespaceQuery
struct
{
}
type
NamespaceMetrics
struct
{
}
// Interface defines all the abstract behaviors of monitoring
type
Interface
interface
{
// Get
GetClusterMetrics
(
query
ClusterQuery
)
ClusterMetrics
//
GetWorkspaceMetrics
(
query
WorkspaceQuery
)
WorkspaceMetrics
//
GetNamespaceMetrics
(
query
NamespaceQuery
)
NamespaceMetrics
}
pkg/simple/client/monitoring/prometheus.go
0 → 100644
浏览文件 @
c40d1542
package
monitoring
import
(
"net/http"
"time"
)
// prometheus implements monitoring interface backed by Prometheus
type
prometheus
struct
{
options
*
Options
client
*
http
.
Client
}
func
NewPrometheus
(
options
*
Options
)
Interface
{
return
&
prometheus
{
options
:
options
,
client
:
&
http
.
Client
{
Timeout
:
10
*
time
.
Second
},
}
}
func
(
p
prometheus
)
GetClusterMetrics
(
query
ClusterQuery
)
ClusterMetrics
{
panic
(
"implement me"
)
}
func
(
p
prometheus
)
GetWorkspaceMetrics
(
query
WorkspaceQuery
)
WorkspaceMetrics
{
panic
(
"implement me"
)
}
func
(
p
prometheus
)
GetNamespaceMetrics
(
query
NamespaceQuery
)
NamespaceMetrics
{
panic
(
"implement me"
)
}
pkg/simple/client/monitoring/prometheus_options.go
0 → 100644
浏览文件 @
c40d1542
package
monitoring
import
(
"github.com/spf13/pflag"
)
type
Options
struct
{
Endpoint
string
`json:"endpoint,omitempty" yaml:"endpoint"`
SecondaryEndpoint
string
`json:"secondaryEndpoint,omitempty" yaml:"secondaryEndpoint"`
}
func
NewPrometheusOptions
()
*
Options
{
return
&
Options
{
Endpoint
:
""
,
SecondaryEndpoint
:
""
,
}
}
func
(
s
*
Options
)
Validate
()
[]
error
{
var
errs
[]
error
return
errs
}
func
(
s
*
Options
)
ApplyTo
(
options
*
Options
)
{
if
s
.
Endpoint
!=
""
{
options
.
Endpoint
=
s
.
Endpoint
}
if
s
.
SecondaryEndpoint
!=
""
{
options
.
SecondaryEndpoint
=
s
.
SecondaryEndpoint
}
}
func
(
s
*
Options
)
AddFlags
(
fs
*
pflag
.
FlagSet
,
c
*
Options
)
{
fs
.
StringVar
(
&
s
.
Endpoint
,
"prometheus-endpoint"
,
c
.
Endpoint
,
""
+
"Prometheus service endpoint which stores KubeSphere monitoring data, if left "
+
"blank, will use builtin metrics-server as data source."
)
fs
.
StringVar
(
&
s
.
SecondaryEndpoint
,
"prometheus-secondary-endpoint"
,
c
.
SecondaryEndpoint
,
""
+
"Prometheus secondary service endpoint, if left empty and endpoint is set, will use endpoint instead."
)
}
pkg/simple/client/monitoring/
monitoring
.go
→
pkg/simple/client/monitoring/
prometheus_test
.go
浏览文件 @
c40d1542
package
monitoring
package
monitoring
type
Interface
interface
{
}
pkg/simple/client/prometheus/prometheus.go
浏览文件 @
c40d1542
...
@@ -27,8 +27,6 @@ import (
...
@@ -27,8 +27,6 @@ import (
"time"
"time"
)
)
type
Interface
interface
{
}
type
Client
struct
{
type
Client
struct
{
client
*
http
.
Client
client
*
http
.
Client
...
...
pkg/simple/client/s3/s3.go
浏览文件 @
c40d1542
...
@@ -54,32 +54,6 @@ func NewS3Client(options *Options) (Interface, error) {
...
@@ -54,32 +54,6 @@ func NewS3Client(options *Options) (Interface, error) {
return
&
c
,
nil
return
&
c
,
nil
}
}
// NewS3ClientOrDie creates Client and panics if there is an error
func
NewS3ClientOrDie
(
options
*
Options
)
Interface
{
cred
:=
credentials
.
NewStaticCredentials
(
options
.
AccessKeyID
,
options
.
SecretAccessKey
,
options
.
SessionToken
)
config
:=
aws
.
Config
{
Region
:
aws
.
String
(
options
.
Region
),
Endpoint
:
aws
.
String
(
options
.
Endpoint
),
DisableSSL
:
aws
.
Bool
(
options
.
DisableSSL
),
S3ForcePathStyle
:
aws
.
Bool
(
options
.
ForcePathStyle
),
Credentials
:
cred
,
}
s
,
err
:=
session
.
NewSession
(
&
config
)
if
err
!=
nil
{
panic
(
err
)
}
client
:=
s3
.
New
(
s
)
return
&
Client
{
s3Client
:
client
,
s3Session
:
s
,
bucket
:
options
.
Bucket
,
}
}
func
(
s
*
Client
)
Client
()
*
s3
.
S3
{
func
(
s
*
Client
)
Client
()
*
s3
.
S3
{
return
s
.
s3Client
return
s
.
s3Client
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录