update api docs (#490)

* update api docs

Signed-off-by: hongming <talonwan@yunify.com>

* fix: kube-apiserver host in kubeconfig

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-06-21 11:47:29 +08:00
committed by GitHub
parent be61ed065b
commit 24d13e44f7
15 changed files with 98 additions and 87 deletions

View File

@@ -121,10 +121,10 @@ func addWebService(c *restful.Container) error {
Reads(iam.LoginRequest{}). Reads(iam.LoginRequest{}).
Returns(http.StatusOK, ok, models.Token{}). Returns(http.StatusOK, ok, models.Token{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users/{username}"). ws.Route(ws.GET("/users/{user}").
To(iam.DescribeUser). To(iam.DescribeUser).
Doc("Describes the specified user."). Doc("Describe the specified user.").
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, models.User{}). Returns(http.StatusOK, ok, models.User{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.POST("/users"). ws.Route(ws.POST("/users").
@@ -133,23 +133,23 @@ func addWebService(c *restful.Container) error {
Reads(CreateUserRequest{}). Reads(CreateUserRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.DELETE("/users/{username}"). ws.Route(ws.DELETE("/users/{user}").
To(iam.DeleteUser). To(iam.DeleteUser).
Doc("Remove a specified user."). Doc("Remove a specified user.").
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.PUT("/users/{username}"). ws.Route(ws.PUT("/users/{user}").
To(iam.UpdateUser). To(iam.UpdateUser).
Doc("Updates information about the specified user."). Doc("Updates information about the specified user.").
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("user", "username")).
Reads(UserUpdateRequest{}). Reads(UserUpdateRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users/{username}/log"). ws.Route(ws.GET("/users/{user}/logs").
To(iam.UserLoginLog). To(iam.UserLoginLogs).
Doc("This method is used to retrieve the \"login logs\" for the specified user."). Doc("This method is used to retrieve the \"login logs\" for the specified user.").
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, LoginLog{}). Returns(http.StatusOK, ok, LoginLog{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users"). ws.Route(ws.GET("/users").
@@ -160,43 +160,39 @@ func addWebService(c *restful.Container) error {
ws.Route(ws.GET("/groups"). ws.Route(ws.GET("/groups").
To(iam.ListGroups). To(iam.ListGroups).
Doc("List all user groups."). Doc("List all user groups.").
Returns(http.StatusOK, ok, []models.Group{}). Returns(http.StatusOK, ok, []models.Group{}))
Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/groups/{group}").
ws.Route(ws.GET("/groups/{path}").
To(iam.DescribeGroup). To(iam.DescribeGroup).
Doc("Describes the specified user group."). Doc("Describe the specified user group.").
Param(ws.PathParameter("path", "user group path separated by colon.")). Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, models.Group{}). Returns(http.StatusOK, ok, models.Group{}))
Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/groups/{group}/users").
ws.Route(ws.GET("/groups/{path}/users").
To(iam.ListGroupUsers). To(iam.ListGroupUsers).
Doc("List all users in the specified user group."). Doc("List all users in the specified user group.").
Param(ws.PathParameter("path", "user group path separated by colon.")). Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, []models.User{}). Returns(http.StatusOK, ok, []models.User{}))
Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.POST("/groups"). ws.Route(ws.POST("/groups").
To(iam.CreateGroup). To(iam.CreateGroup).
Doc("Create a user group."). Doc("Create a user group.").
Reads(models.Group{}). Reads(models.Group{}).
Returns(http.StatusOK, ok, models.Group{}). Returns(http.StatusOK, ok, models.Group{}))
Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/groups/{group}").
ws.Route(ws.DELETE("/groups/{path}").
To(iam.DeleteGroup). To(iam.DeleteGroup).
Doc("Delete a user group."). Doc("Delete a user group.").
Param(ws.PathParameter("path", "user group path separated by colon.")). Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.PUT("/groups/{path}"). ws.Route(ws.PUT("/groups/{group}").
To(iam.UpdateGroup). To(iam.UpdateGroup).
Doc("Updates information about the user group."). Doc("Updates information about the user group.").
Param(ws.PathParameter("path", "user group path separated by colon.")). Param(ws.PathParameter("group", "user group path separated by colon.")).
Reads(models.Group{}). Reads(models.Group{}).
Returns(http.StatusOK, ok, models.Group{}). Returns(http.StatusOK, ok, models.Group{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users/{username}/roles"). ws.Route(ws.GET("/users/{user}/roles").
To(iam.ListUserRoles). To(iam.ListUserRoles).
Doc("This method is used to retrieve all the roles that are assigned to the user."). Doc("This method is used to retrieve all the roles that are assigned to the user.").
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, iam.RoleList{}). Returns(http.StatusOK, ok, iam.RoleList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/namespaces/{namespace}/roles"). ws.Route(ws.GET("/namespaces/{namespace}/roles").
@@ -267,7 +263,7 @@ func addWebService(c *restful.Container) error {
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}"). ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}").
To(iam.DescribeWorkspaceRole). To(iam.DescribeWorkspaceRole).
Doc("Describes the workspace role."). Doc("Describe the workspace role.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("role", "workspace role name")). Param(ws.PathParameter("role", "workspace role name")).
Returns(http.StatusOK, ok, rbacv1.ClusterRole{}). Returns(http.StatusOK, ok, rbacv1.ClusterRole{}).
@@ -292,18 +288,18 @@ func addWebService(c *restful.Container) error {
Reads(InviteUserRequest{}). Reads(InviteUserRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.DELETE("/workspaces/{workspace}/members/{username}"). ws.Route(ws.DELETE("/workspaces/{workspace}/members/{member}").
To(iam.RemoveUser). To(iam.RemoveUser).
Doc("Remove members from workspace."). Doc("Remove members from workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("member", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}").
To(iam.DescribeWorkspaceUser). To(iam.DescribeWorkspaceUser).
Doc("Describes the specified user."). Doc("Describe the specified user.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "username")). Param(ws.PathParameter("member", "username")).
Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}). Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
c.Add(ws) c.Add(ws)

View File

@@ -19,7 +19,6 @@ package v1alpha2
import ( import (
"github.com/emicklei/go-restful" "github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/operations" "kubesphere.io/kubesphere/pkg/apiserver/operations"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
@@ -38,20 +37,17 @@ var (
func addWebService(c *restful.Container) error { func addWebService(c *restful.Container) error {
tags := []string{"Operations"}
ok := "ok" ok := "ok"
webservice := runtime.NewWebService(GroupVersion) webservice := runtime.NewWebService(GroupVersion)
webservice.Route(webservice.POST("/nodes/{node}/drainage"). webservice.Route(webservice.POST("/nodes/{node}/drainage").
To(operations.DrainNode). To(operations.DrainNode).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Drain node"). Doc("Drain node").
Param(webservice.PathParameter("node", "node name")). Param(webservice.PathParameter("node", "node name")).
Returns(http.StatusOK, ok, errors.Error{})) Returns(http.StatusOK, ok, errors.Error{}))
webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}"). webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}").
To(operations.RerunJob). To(operations.RerunJob).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Job rerun"). Doc("Job rerun").
Param(webservice.PathParameter("job", "job name")). Param(webservice.PathParameter("job", "job name")).
Param(webservice.PathParameter("namespace", "job's namespace")). Param(webservice.PathParameter("namespace", "job's namespace")).

View File

@@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/components" "kubesphere.io/kubesphere/pkg/apiserver/components"
"kubesphere.io/kubesphere/pkg/apiserver/git" "kubesphere.io/kubesphere/pkg/apiserver/git"
"kubesphere.io/kubesphere/pkg/apiserver/operations"
"kubesphere.io/kubesphere/pkg/apiserver/quotas" "kubesphere.io/kubesphere/pkg/apiserver/quotas"
"kubesphere.io/kubesphere/pkg/apiserver/registries" "kubesphere.io/kubesphere/pkg/apiserver/registries"
"kubesphere.io/kubesphere/pkg/apiserver/resources" "kubesphere.io/kubesphere/pkg/apiserver/resources"
@@ -74,6 +75,15 @@ func addWebService(c *restful.Container) error {
DefaultValue("limit=10,page=1")). DefaultValue("limit=10,page=1")).
Returns(http.StatusOK, ok, models.PageableResponse{})) Returns(http.StatusOK, ok, models.PageableResponse{}))
webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}").
To(operations.RerunJob).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Rerun job whether the job is complete or not").
Param(webservice.PathParameter("job", "job name")).
Param(webservice.PathParameter("namespace", "job's namespace")).
Param(webservice.QueryParameter("a", "action")).
Returns(http.StatusOK, ok, errors.Error{}))
tags = []string{"Cluster resources"} tags = []string{"Cluster resources"}
webservice.Route(webservice.GET("/{resources}"). webservice.Route(webservice.GET("/{resources}").
@@ -91,6 +101,15 @@ func addWebService(c *restful.Container) error {
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1"))) DefaultValue("limit=10,page=1")))
webservice.Route(webservice.POST("/nodes/{node}/drainage").
To(operations.DrainNode).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Drain node").
Param(webservice.PathParameter("node", "node name")).
Returns(http.StatusOK, ok, errors.Error{}))
c.Add(webservice)
tags = []string{"Applications"} tags = []string{"Applications"}
webservice.Route(webservice.GET("/applications"). webservice.Route(webservice.GET("/applications").
@@ -124,13 +143,13 @@ func addWebService(c *restful.Container) error {
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1"))) DefaultValue("limit=10,page=1")))
webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{cluster_id}"). webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{application}").
To(resources.DescribeApplication). To(resources.DescribeApplication).
Returns(http.StatusOK, ok, applications.Application{}). Returns(http.StatusOK, ok, applications.Application{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Describe application"). Doc("Describe application").
Param(webservice.PathParameter("namespace", "namespace name")). Param(webservice.PathParameter("namespace", "namespace name")).
Param(webservice.PathParameter("cluster_id", "application id"))) Param(webservice.PathParameter("application", "application id")))
webservice.Route(webservice.POST("/namespaces/{namespace}/applications"). webservice.Route(webservice.POST("/namespaces/{namespace}/applications").
To(resources.DeployApplication). To(resources.DeployApplication).
@@ -140,28 +159,28 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Param(webservice.PathParameter("namespace", "namespace name"))) Param(webservice.PathParameter("namespace", "namespace name")))
webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{cluster_id}"). webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{application}").
To(resources.DeleteApplication). To(resources.DeleteApplication).
Doc("Delete application"). Doc("Delete application").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Param(webservice.PathParameter("namespace", "namespace name")). Param(webservice.PathParameter("namespace", "namespace name")).
Param(webservice.PathParameter("cluster_id", "application id"))) Param(webservice.PathParameter("application", "application id")))
tags = []string{"User resources"} tags = []string{"User resources"}
webservice.Route(webservice.GET("/users/{username}/kubectl"). webservice.Route(webservice.GET("/users/{user}/kubectl").
To(resources.GetKubectl). To(resources.GetKubectl).
Doc("get user's kubectl pod"). Doc("get user's kubectl pod").
Param(webservice.PathParameter("username", "username")). Param(webservice.PathParameter("user", "username")).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, ok, models.PodInfo{})) Returns(http.StatusOK, ok, models.PodInfo{}))
webservice.Route(webservice.GET("/users/{username}/kubeconfig"). webservice.Route(webservice.GET("/users/{user}/kubeconfig").
Produces("text/plain"). Produces("text/plain").
To(resources.GetKubeconfig). To(resources.GetKubeconfig).
Doc("get users' kubeconfig"). Doc("get users' kubeconfig").
Param(webservice.PathParameter("username", "username")). Param(webservice.PathParameter("user", "username")).
Returns(http.StatusOK, ok, ""). Returns(http.StatusOK, ok, "").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
@@ -178,7 +197,7 @@ func addWebService(c *restful.Container) error {
Doc(""). Doc("").
Param(webservice.PathParameter("component", "component name")). Param(webservice.PathParameter("component", "component name")).
Returns(http.StatusOK, ok, models.Component{})) Returns(http.StatusOK, ok, models.Component{}))
webservice.Route(webservice.GET("/health"). webservice.Route(webservice.GET("/componenthealth").
To(components.GetSystemHealthStatus). To(components.GetSystemHealthStatus).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc(""). Doc("").
@@ -202,7 +221,7 @@ func addWebService(c *restful.Container) error {
tags = []string{"Registries"} tags = []string{"Registries"}
webservice.Route(webservice.POST("registries/verify"). webservice.Route(webservice.POST("registry/verify").
To(registries.RegistryVerify). To(registries.RegistryVerify).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("docker registry verify"). Doc("docker registry verify").
@@ -279,17 +298,17 @@ func addWebService(c *restful.Container) error {
tags = []string{"WorkloadStatus"} tags = []string{"WorkloadStatus"}
webservice.Route(webservice.GET("/workloadstatuses"). webservice.Route(webservice.GET("/abnormalworkloads").
Doc("get abnormal workloads' count of whole cluster"). Doc("get abnormal workloads' count of whole cluster").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, ok, status.WorkLoadStatus{}). Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
To(workloadstatuses.GetClusterResourceStatus)) To(workloadstatuses.GetClusterAbnormalWorkloads))
webservice.Route(webservice.GET("/namespaces/{namespace}/workloadstatuses"). webservice.Route(webservice.GET("/namespaces/{namespace}/abnormalworkloads").
Doc("get abnormal workloads' count of specified namespace"). Doc("get abnormal workloads' count of specified namespace").
Param(webservice.PathParameter("namespace", "the name of namespace")). Param(webservice.PathParameter("namespace", "the name of namespace")).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, ok, status.WorkLoadStatus{}). Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
To(workloadstatuses.GetNamespacesResourceStatus)) To(workloadstatuses.GetNamespacedAbnormalWorkloads))
c.Add(webservice) c.Add(webservice)

View File

@@ -87,10 +87,10 @@ func addWebService(c *restful.Container) error {
Doc("List the namespaces for the current user"). Doc("List the namespaces for the current user").
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/namespaces").
To(tenant.ListNamespacesByUsername). To(tenant.ListNamespacesByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "workspace member's username")). Param(ws.PathParameter("member", "workspace member's username")).
Doc("List the namespaces for the workspace member"). Doc("List the namespaces for the workspace member").
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
@@ -120,10 +120,10 @@ func addWebService(c *restful.Container) error {
DataFormat("key=%s,key~%s")). DataFormat("key=%s,key~%s")).
Doc("List devops projects for the current user"). Doc("List devops projects for the current user").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/devops").
To(tenant.ListDevopsProjectsByUsername). To(tenant.ListDevopsProjectsByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "workspace member's username")). Param(ws.PathParameter("member", "workspace member's username")).
Param(ws.QueryParameter(params.PagingParam, "page"). Param(ws.QueryParameter(params.PagingParam, "page").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
@@ -141,14 +141,14 @@ func addWebService(c *restful.Container) error {
Reads(devops.DevOpsProject{}). Reads(devops.DevOpsProject{}).
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{id}"). ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{devops}").
To(tenant.DeleteDevopsProject). To(tenant.DeleteDevopsProject).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("id", "devops project id")). Param(ws.PathParameter("devops", "devops project id")).
Doc("Delete devops project"). Doc("Delete devops project").
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/logging"). ws.Route(ws.GET("/logs").
To(tenant.LogQuery). To(tenant.LogQuery).
Doc("Query cluster-level logs in a multi-tenants environment"). Doc("Query cluster-level logs in a multi-tenants environment").
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).

View File

@@ -116,7 +116,7 @@ func ListNamespaceUsers(req *restful.Request, resp *restful.Response) {
func ListUserRoles(req *restful.Request, resp *restful.Response) { func ListUserRoles(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("username") username := req.PathParameter("user")
roles, err := iam.GetUserRoles("", username) roles, err := iam.GetUserRoles("", username)

View File

@@ -61,7 +61,7 @@ func CreateGroup(req *restful.Request, resp *restful.Response) {
} }
func DeleteGroup(req *restful.Request, resp *restful.Response) { func DeleteGroup(req *restful.Request, resp *restful.Response) {
path := req.PathParameter("path") path := req.PathParameter("group")
if path == "" { if path == "" {
resp.WriteHeaderAndEntity(http.StatusBadRequest, errors.Wrap(fmt.Errorf("group path must not be null"))) resp.WriteHeaderAndEntity(http.StatusBadRequest, errors.Wrap(fmt.Errorf("group path must not be null")))
@@ -84,7 +84,7 @@ func DeleteGroup(req *restful.Request, resp *restful.Response) {
} }
func UpdateGroup(req *restful.Request, resp *restful.Response) { func UpdateGroup(req *restful.Request, resp *restful.Response) {
groupPathInPath := req.PathParameter("path") groupPathInPath := req.PathParameter("group")
var group models.Group var group models.Group
@@ -108,7 +108,7 @@ func UpdateGroup(req *restful.Request, resp *restful.Response) {
func DescribeGroup(req *restful.Request, resp *restful.Response) { func DescribeGroup(req *restful.Request, resp *restful.Response) {
path := req.PathParameter("path") path := req.PathParameter("group")
group, err := iam.DescribeGroup(path) group, err := iam.DescribeGroup(path)
@@ -127,7 +127,7 @@ func DescribeGroup(req *restful.Request, resp *restful.Response) {
func ListGroupUsers(req *restful.Request, resp *restful.Response) { func ListGroupUsers(req *restful.Request, resp *restful.Response) {
path := req.PathParameter("path") path := req.PathParameter("group")
group, err := iam.DescribeGroup(path) group, err := iam.DescribeGroup(path)

View File

@@ -77,7 +77,7 @@ func CreateUser(req *restful.Request, resp *restful.Response) {
} }
func DeleteUser(req *restful.Request, resp *restful.Response) { func DeleteUser(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("username") username := req.PathParameter("user")
operator := req.HeaderParameter(constants.UserNameHeader) operator := req.HeaderParameter(constants.UserNameHeader)
@@ -98,7 +98,7 @@ func DeleteUser(req *restful.Request, resp *restful.Response) {
func UpdateUser(req *restful.Request, resp *restful.Response) { func UpdateUser(req *restful.Request, resp *restful.Response) {
usernameInPath := req.PathParameter("username") usernameInPath := req.PathParameter("user")
usernameInHeader := req.HeaderParameter(constants.UserNameHeader) usernameInHeader := req.HeaderParameter(constants.UserNameHeader)
var user models.User var user models.User
@@ -161,8 +161,8 @@ func isUserManager(username string) (bool, error) {
return false, nil return false, nil
} }
func UserLoginLog(req *restful.Request, resp *restful.Response) { func UserLoginLogs(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("username") username := req.PathParameter("user")
logs, err := iam.LoginLog(username) logs, err := iam.LoginLog(username)
if err != nil { if err != nil {
@@ -187,7 +187,7 @@ func UserLoginLog(req *restful.Request, resp *restful.Response) {
func DescribeUser(req *restful.Request, resp *restful.Response) { func DescribeUser(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("username") username := req.PathParameter("user")
user, err := iam.DescribeUser(username) user, err := iam.DescribeUser(username)

View File

@@ -77,7 +77,7 @@ func DescribeWorkspaceRole(req *restful.Request, resp *restful.Response) {
func DescribeWorkspaceUser(req *restful.Request, resp *restful.Response) { func DescribeWorkspaceUser(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")
username := req.PathParameter("username") username := req.PathParameter("member")
workspaceRole, err := iam.GetUserWorkspaceRole(workspace, username) workspaceRole, err := iam.GetUserWorkspaceRole(workspace, username)
@@ -132,7 +132,7 @@ func InviteUser(req *restful.Request, resp *restful.Response) {
func RemoveUser(req *restful.Request, resp *restful.Response) { func RemoveUser(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")
username := req.PathParameter("username") username := req.PathParameter("member")
err := workspaces.RemoveUser(workspace, username) err := workspaces.RemoveUser(workspace, username)
if err != nil { if err != nil {

View File

@@ -117,7 +117,7 @@ func ListNamespacedApplication(req *restful.Request, resp *restful.Response) {
} }
func DescribeApplication(req *restful.Request, resp *restful.Response) { func DescribeApplication(req *restful.Request, resp *restful.Response) {
clusterId := req.PathParameter("cluster_id") clusterId := req.PathParameter("application")
namespaceName := req.PathParameter("namespace") namespaceName := req.PathParameter("namespace")
app, err := applications.GetApp(clusterId) app, err := applications.GetApp(clusterId)
if err != nil { if err != nil {
@@ -166,7 +166,7 @@ func DeployApplication(req *restful.Request, resp *restful.Response) {
} }
func DeleteApplication(req *restful.Request, resp *restful.Response) { func DeleteApplication(req *restful.Request, resp *restful.Response) {
clusterId := req.PathParameter("cluster_id") clusterId := req.PathParameter("application")
namespaceName := req.PathParameter("namespace") namespaceName := req.PathParameter("namespace")
app, err := applications.GetApp(clusterId) app, err := applications.GetApp(clusterId)
if err != nil { if err != nil {

View File

@@ -29,7 +29,7 @@ import (
func GetKubectl(req *restful.Request, resp *restful.Response) { func GetKubectl(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("username") user := req.PathParameter("user")
kubectlPod, err := kubectl.GetKubectlPod(user) kubectlPod, err := kubectl.GetKubectlPod(user)
@@ -43,7 +43,7 @@ func GetKubectl(req *restful.Request, resp *restful.Response) {
func GetKubeconfig(req *restful.Request, resp *restful.Response) { func GetKubeconfig(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("username") user := req.PathParameter("user")
kubectlConfig, err := kubeconfig.GetKubeConfig(user) kubectlConfig, err := kubeconfig.GetKubeConfig(user)

View File

@@ -107,7 +107,7 @@ func ListNamespacesByUsername(req *restful.Request, resp *restful.Response) {
func ListNamespaces(req *restful.Request, resp *restful.Response) { func ListNamespaces(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")
username := req.PathParameter("username") username := req.PathParameter("member")
// /workspaces/{workspace}/members/{username}/namespaces // /workspaces/{workspace}/members/{username}/namespaces
if username == "" { if username == "" {
// /workspaces/{workspace}/namespaces // /workspaces/{workspace}/namespaces
@@ -218,7 +218,7 @@ func ListDevopsProjectsByUsername(req *restful.Request, resp *restful.Response)
func ListDevopsProjects(req *restful.Request, resp *restful.Response) { func ListDevopsProjects(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")
username := req.PathParameter(constants.UserNameHeader) username := req.PathParameter("member")
if username == "" { if username == "" {
username = req.HeaderParameter(constants.UserNameHeader) username = req.HeaderParameter(constants.UserNameHeader)
} }
@@ -245,7 +245,7 @@ func ListDevopsProjects(req *restful.Request, resp *restful.Response) {
} }
func DeleteDevopsProject(req *restful.Request, resp *restful.Response) { func DeleteDevopsProject(req *restful.Request, resp *restful.Response) {
projectId := req.PathParameter("id") projectId := req.PathParameter("devops")
workspaceName := req.PathParameter("workspace") workspaceName := req.PathParameter("workspace")
username := req.HeaderParameter(constants.UserNameHeader) username := req.HeaderParameter(constants.UserNameHeader)

View File

@@ -26,7 +26,7 @@ import (
"kubesphere.io/kubesphere/pkg/models/status" "kubesphere.io/kubesphere/pkg/models/status"
) )
func GetClusterResourceStatus(req *restful.Request, resp *restful.Response) { func GetClusterAbnormalWorkloads(req *restful.Request, resp *restful.Response) {
res, err := status.GetClusterResourceStatus() res, err := status.GetClusterResourceStatus()
if err != nil { if err != nil {
resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err)) resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err))
@@ -35,7 +35,7 @@ func GetClusterResourceStatus(req *restful.Request, resp *restful.Response) {
resp.WriteAsJson(res) resp.WriteAsJson(res)
} }
func GetNamespacesResourceStatus(req *restful.Request, resp *restful.Response) { func GetNamespacedAbnormalWorkloads(req *restful.Request, resp *restful.Response) {
res, err := status.GetNamespacesResourceStatus(req.PathParameter("namespace")) res, err := status.GetNamespacesResourceStatus(req.PathParameter("namespace"))
if err != nil { if err != nil {
resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err)) resp.WriteHeaderAndEntity(http.StatusInternalServerError, errors.Wrap(err))

View File

@@ -45,8 +45,8 @@ type Application struct {
Version string `json:"version" description:"application version"` Version string `json:"version" description:"application version"`
VersionId string `json:"version_id" description:"application version id"` VersionId string `json:"version_id" description:"application version id"`
Status string `json:"status" description:"application status"` Status string `json:"status" description:"application status"`
UpdateTime time.Time `json:"updateTime" description:"update time"` UpdateTime time.Time `json:"updateTime" description:"the last time this application was updated"`
CreateTime time.Time `json:"createTime" description:"create name"` CreateTime time.Time `json:"createTime" description:"application creation time"`
App string `json:"app" description:"application template name"` App string `json:"app" description:"application template name"`
AppId string `json:"app_id" description:"application template id"` AppId string `json:"app_id" description:"application template id"`
Description string `json:"description,omitempty" description:"application description"` Description string `json:"description,omitempty" description:"application description"`

View File

@@ -217,7 +217,7 @@ func createKubeConfig(username string) (string, error) {
return "", err return "", err
} }
base64ServerCa := base64.StdEncoding.EncodeToString(serverCa) base64ServerCa := base64.StdEncoding.EncodeToString(serverCa)
tmpClusterInfo := clusterInfo{CertificateAuthorityData: base64ServerCa, Server: k8s.KubeConfig.Host} tmpClusterInfo := clusterInfo{CertificateAuthorityData: base64ServerCa, Server: k8s.MasterURL}
tmpCluster := cluster{Cluster: tmpClusterInfo, Name: clusterName} tmpCluster := cluster{Cluster: tmpClusterInfo, Name: clusterName}
tmpKubeConfig.Clusters = append(tmpKubeConfig.Clusters, tmpCluster) tmpKubeConfig.Clusters = append(tmpKubeConfig.Clusters, tmpCluster)

View File

@@ -34,12 +34,12 @@ var (
k8sClient *kubernetes.Clientset k8sClient *kubernetes.Clientset
k8sClientOnce sync.Once k8sClientOnce sync.Once
KubeConfig *rest.Config KubeConfig *rest.Config
masterURL string MasterURL string
) )
func init() { func init() {
flag.StringVar(&kubeConfigFile, "kubeconfig", "", "path to kubeconfig file") flag.StringVar(&kubeConfigFile, "kubeconfig", "", "path to kubeconfig file")
flag.StringVar(&masterURL, "master-url", "", "kube-apiserver url, only needed when out of cluster") flag.StringVar(&MasterURL, "master-url", "", "kube-apiserver url, only needed when out of cluster")
} }
func Client() *kubernetes.Clientset { func Client() *kubernetes.Clientset {
@@ -63,7 +63,7 @@ func Client() *kubernetes.Clientset {
func Config() (kubeConfig *rest.Config, err error) { func Config() (kubeConfig *rest.Config, err error) {
if _, err = os.Stat(kubeConfigFile); err == nil { if _, err = os.Stat(kubeConfigFile); err == nil {
kubeConfig, err = clientcmd.BuildConfigFromFlags(masterURL, kubeConfigFile) kubeConfig, err = clientcmd.BuildConfigFromFlags(MasterURL, kubeConfigFile)
} else { } else {
kubeConfig, err = rest.InClusterConfig() kubeConfig, err = rest.InClusterConfig()
} }