From 6b3b0aa4f184865a0f6a8fe03d40647bb70606f7 Mon Sep 17 00:00:00 2001 From: soulseen Date: Wed, 15 May 2019 15:52:34 +0800 Subject: [PATCH 01/24] update jenkins log Signed-off-by: soulseen --- pkg/models/devops/devops.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index 461d469a7..f91c5ef10 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -683,7 +683,6 @@ func sendJenkinsRequest(baseUrl string, req *http.Request) ([]byte, error) { defer resp.Body.Close() resBody, _ := getRespBody(resp) - log.Info(string(resBody)) if resp.StatusCode >= http.StatusBadRequest { jkerr := new(JkError) jkerr.Code = resp.StatusCode From d9cce21f051800bdcd7a70fc679bd0e69ad11a92 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 15 May 2019 15:53:28 +0800 Subject: [PATCH 02/24] add quota left to namespace quota --- pkg/apis/resources/v1alpha2/register.go | 1 + pkg/models/quotas/quotas.go | 83 ++++++++++++++++++------- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/pkg/apis/resources/v1alpha2/register.go b/pkg/apis/resources/v1alpha2/register.go index 729fc2a42..0f0445917 100644 --- a/pkg/apis/resources/v1alpha2/register.go +++ b/pkg/apis/resources/v1alpha2/register.go @@ -180,6 +180,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/quotas"). To(quotas.GetClusterQuotas). + Deprecate(). Doc("get whole cluster's resource usage"). Writes(models.ResourceQuota{}). Metadata(restfulspec.KeyOpenAPITags, tags)) diff --git a/pkg/models/quotas/quotas.go b/pkg/models/quotas/quotas.go index b1cc20087..d85686a33 100644 --- a/pkg/models/quotas/quotas.go +++ b/pkg/models/quotas/quotas.go @@ -37,18 +37,33 @@ const ( servicesKey = "count/services" statefulsetsKey = "count/statefulsets.apps" persistentvolumeclaimsKey = "persistentvolumeclaims" - storageClassesKey = "count/storageClass" - namespaceKey = "count/namespace" jobsKey = "count/jobs.batch" cronJobsKey = "count/cronjobs.batch" ) +type NamespacedResourceQuota struct { + Namespace string `json:"namespace,omitempty"` + + Data struct { + v1.ResourceQuotaStatus + + // quota left status, do the math on the side, cause it's + // a lot easier with go-client library + Left v1.ResourceList `json:"left,omitempty"` + } `json:"data,omitempty"` +} + var ( - resourceMap = map[string]string{daemonsetsKey: resources.DaemonSets, deploymentsKey: resources.Deployments, - ingressKey: resources.Ingresses, servicesKey: resources.Services, - statefulsetsKey: resources.StatefulSets, persistentvolumeclaimsKey: resources.PersistentVolumeClaims, podsKey: resources.Pods, - namespaceKey: resources.Namespaces, storageClassesKey: resources.StorageClasses, - jobsKey: resources.Jobs, cronJobsKey: resources.CronJobs} + resourceMap = map[string]string{ + daemonsetsKey: resources.DaemonSets, + deploymentsKey: resources.Deployments, + ingressKey: resources.Ingresses, + servicesKey: resources.Services, + statefulsetsKey: resources.StatefulSets, + persistentvolumeclaimsKey: resources.PersistentVolumeClaims, + podsKey: resources.Pods, + jobsKey: resources.Jobs, + cronJobsKey: resources.CronJobs} ) func getUsage(namespace, resource string) (int, error) { @@ -61,12 +76,14 @@ func getUsage(namespace, resource string) (int, error) { } if err != nil { + glog.Error(err) return 0, err } return result.TotalCount, nil } +// no one use this api anymore, marked as deprecated func GetClusterQuotas() (*models.ResourceQuota, error) { quota := v1.ResourceQuotaStatus{Hard: make(v1.ResourceList), Used: make(v1.ResourceList)} @@ -85,7 +102,7 @@ func GetClusterQuotas() (*models.ResourceQuota, error) { } -func GetNamespaceQuotas(namespace string) (*models.ResourceQuota, error) { +func GetNamespaceQuotas(namespace string) (*NamespacedResourceQuota, error) { quota, err := getNamespaceResourceQuota(namespace) if err != nil { glog.Error(err) @@ -95,23 +112,43 @@ func GetNamespaceQuotas(namespace string) (*models.ResourceQuota, error) { quota = &v1.ResourceQuotaStatus{Hard: make(v1.ResourceList), Used: make(v1.ResourceList)} } - for k, v := range resourceMap { - if _, exist := quota.Used[v1.ResourceName(k)]; !exist { - if k == namespaceKey || k == storageClassesKey { - continue + var resourceQuotaLeft = v1.ResourceList{} + + for key, hardLimit := range quota.Hard { + if used, ok := quota.Used[key]; ok { + left := hardLimit.DeepCopy() + left.Sub(used) + if hardLimit.Cmp(used) < 0 { + left = resource.MustParse("0") } - used, err := getUsage(namespace, v) - if err != nil { - return nil, err - } - var quantity resource.Quantity - quantity.Set(int64(used)) - quota.Used[v1.ResourceName(k)] = quantity + resourceQuotaLeft[key] = left } } - return &models.ResourceQuota{Namespace: namespace, Data: *quota}, nil + // add extra quota usage, cause user may not specify them + for key, val := range resourceMap { + // only add them when they don't exist in quotastatus + if _, ok := quota.Used[v1.ResourceName(key)]; !ok { + used, err := getUsage(namespace, val) + if err != nil { + glog.Error(err) + return nil, err + } + + quota.Used[v1.ResourceName(key)] = *(resource.NewQuantity(int64(used), resource.DecimalSI)) + } + } + + var result = NamespacedResourceQuota{ + Namespace: namespace, + } + result.Data.Hard = quota.Hard + result.Data.Used = quota.Used + result.Data.Left = resourceQuotaLeft + + return &result, nil + } func updateNamespaceQuota(tmpResourceList, resourceList v1.ResourceList) { @@ -127,14 +164,16 @@ func updateNamespaceQuota(tmpResourceList, resourceList v1.ResourceList) { tmpResourceList[res] = usage } } - } func getNamespaceResourceQuota(namespace string) (*v1.ResourceQuotaStatus, error) { resourceQuotaLister := informers.SharedInformerFactory().Core().V1().ResourceQuotas().Lister() quotaList, err := resourceQuotaLister.ResourceQuotas(namespace).List(labels.Everything()) - if err != nil || len(quotaList) == 0 { + if err != nil { + glog.Error(err) return nil, err + } else if len(quotaList) == 0 { + return nil, nil } quotaStatus := v1.ResourceQuotaStatus{Hard: make(v1.ResourceList), Used: make(v1.ResourceList)} From 2259924e17c0eb6ca78dbf5008ce28ad84c9ed36 Mon Sep 17 00:00:00 2001 From: runzexia Date: Mon, 13 May 2019 17:56:39 +0800 Subject: [PATCH 03/24] delete all devops project when delete ws Signed-off-by: runzexia --- .../workspace/workspace_controller.go | 39 ++++++++++ pkg/models/devops/project.go | 5 ++ .../client/kubesphere/kubesphereclient.go | 72 ++++++++++++++++++- 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/pkg/controller/workspace/workspace_controller.go b/pkg/controller/workspace/workspace_controller.go index 72d3a5ee0..b1f6dff19 100644 --- a/pkg/controller/workspace/workspace_controller.go +++ b/pkg/controller/workspace/workspace_controller.go @@ -43,6 +43,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/source" + "sync" ) const ( @@ -137,6 +138,10 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res return reconcile.Result{}, err } + if err := r.deleteDevOpsProjects(instance); err != nil { + return reconcile.Result{}, err + } + // remove our finalizer from the list and update it. instance.ObjectMeta.Finalizers = sliceutil.RemoveString(instance.ObjectMeta.Finalizers, func(item string) bool { return item == finalizer @@ -327,6 +332,40 @@ func (r *ReconcileWorkspace) deleteGroup(instance *tenantv1alpha1.Workspace) err return nil } +func (r *ReconcileWorkspace) deleteDevOpsProjects(instance *tenantv1alpha1.Workspace) error { + var wg sync.WaitGroup + + log.Info("Delete DevOps Projects") + for { + errChan := make(chan error, 10) + projects, err := r.ksclient.ListWorkspaceDevOpsProjects(instance.Name) + if err != nil { + log.Error(err, "Failed to Get Workspace's DevOps Projects", "ws", instance.Name) + return err + } + if projects.TotalCount == 0 { + return nil + } + for _, project := range projects.Items { + wg.Add(1) + go func(workspace, devops string) { + err := r.ksclient.DeleteWorkspaceDevOpsProjects(workspace, devops) + errChan <- err + wg.Done() + }(instance.Name, project.ProjectId) + } + wg.Wait() + close(errChan) + for err := range errChan { + if err != nil { + log.Error(err, "delete devops project error") + return err + } + } + + } +} + func (r *ReconcileWorkspace) createWorkspaceRoleBindings(instance *tenantv1alpha1.Workspace) error { adminRoleBinding := &rbac.ClusterRoleBinding{} diff --git a/pkg/models/devops/project.go b/pkg/models/devops/project.go index e62271499..37111f3e5 100644 --- a/pkg/models/devops/project.go +++ b/pkg/models/devops/project.go @@ -31,6 +31,11 @@ const ( DevOpsProjectCreateTimeColumn = "project.create_time" ) +type PageableDevOpsProject struct { + Items []*DevOpsProject `json:"items"` + TotalCount int `json:"total_count"` +} + type DevOpsProject struct { ProjectId string `json:"project_id" db:"project_id"` Name string `json:"name"` diff --git a/pkg/simple/client/kubesphere/kubesphereclient.go b/pkg/simple/client/kubesphere/kubesphereclient.go index f7040e2da..f5880525a 100644 --- a/pkg/simple/client/kubesphere/kubesphereclient.go +++ b/pkg/simple/client/kubesphere/kubesphereclient.go @@ -23,7 +23,9 @@ import ( "flag" "fmt" "io/ioutil" + "kubesphere.io/kubesphere/pkg/constants" "kubesphere.io/kubesphere/pkg/models" + "kubesphere.io/kubesphere/pkg/models/devops" "log" "net/http" "strings" @@ -32,7 +34,7 @@ import ( var ( accountAPIServer string - devopsAPIServer string + ksAPIServer string once sync.Once c client ) @@ -43,6 +45,8 @@ type Interface interface { DescribeGroup(name string) (*models.Group, error) DeleteGroup(name string) error ListUsers() (*models.PageableResponse, error) + ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableDevOpsProject, error) + DeleteWorkspaceDevOpsProjects(workspace, devops string) error } type client struct { @@ -51,6 +55,7 @@ type client struct { func init() { flag.StringVar(&accountAPIServer, "ks-account-api-server", "http://ks-account.kubesphere-system.svc", "kubesphere account api server") + flag.StringVar(&ksAPIServer, "ks-api-server", "http://ks-apiserver.kubesphere-system.svc", "kubesphere api server") } func Client() Interface { @@ -248,6 +253,71 @@ func (c client) ListUsers() (*models.PageableResponse, error) { return &result, nil } +func (c client) ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableDevOpsProject, error) { + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops", ksAPIServer, workspace), nil) + + if err != nil { + return nil, err + } + req.Header.Add(constants.UserNameHeader, constants.AdminUserName) + if err != nil { + return nil, err + } + log.Println(req.Method, req.URL) + resp, err := c.client.Do(req) + + if err != nil { + return nil, err + } + defer resp.Body.Close() + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return nil, err + } + if resp.StatusCode > http.StatusOK { + return nil, Error{resp.StatusCode, string(data)} + } + + var result devops.PageableDevOpsProject + err = json.Unmarshal(data, &result) + + if err != nil { + return nil, err + } + return &result, nil + +} + +func (c client) DeleteWorkspaceDevOpsProjects(workspace, devops string) error { + req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops/%s", ksAPIServer, workspace, devops), nil) + + if err != nil { + return err + } + req.Header.Add(constants.UserNameHeader, constants.AdminUserName) + if err != nil { + return err + } + log.Println(req.Method, req.URL) + resp, err := c.client.Do(req) + + if err != nil { + return err + } + defer resp.Body.Close() + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return err + } + if resp.StatusCode > http.StatusOK { + return Error{resp.StatusCode, string(data)} + } + + return nil +} + func IsNotFound(err error) bool { if e, ok := err.(Error); ok { if e.status == http.StatusNotFound { From dae04e2ad34ac4869f08d2902103f9a67c8ba307 Mon Sep 17 00:00:00 2001 From: runzexia Date: Wed, 15 May 2019 17:09:07 +0800 Subject: [PATCH 04/24] update Signed-off-by: runzexia --- .../client/kubesphere/kubesphereclient.go | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/simple/client/kubesphere/kubesphereclient.go b/pkg/simple/client/kubesphere/kubesphereclient.go index f5880525a..e5e6c9867 100644 --- a/pkg/simple/client/kubesphere/kubesphereclient.go +++ b/pkg/simple/client/kubesphere/kubesphereclient.go @@ -22,6 +22,7 @@ import ( "encoding/json" "flag" "fmt" + "github.com/golang/glog" "io/ioutil" "kubesphere.io/kubesphere/pkg/constants" "kubesphere.io/kubesphere/pkg/models" @@ -257,25 +258,28 @@ func (c client) ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableD req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops", ksAPIServer, workspace), nil) if err != nil { + glog.Error(err) return nil, err } + req.Header.Add(constants.UserNameHeader, constants.AdminUserName) - if err != nil { - return nil, err - } - log.Println(req.Method, req.URL) + + glog.Info(req.Method, req.URL) resp, err := c.client.Do(req) if err != nil { + glog.Error(err) return nil, err } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { + glog.Error(err) return nil, err } if resp.StatusCode > http.StatusOK { + glog.Error(req.Method, req.URL, resp.StatusCode, string(data)) return nil, Error{resp.StatusCode, string(data)} } @@ -283,6 +287,7 @@ func (c client) ListWorkspaceDevOpsProjects(workspace string) (*devops.PageableD err = json.Unmarshal(data, &result) if err != nil { + glog.Error(err) return nil, err } return &result, nil @@ -293,25 +298,27 @@ func (c client) DeleteWorkspaceDevOpsProjects(workspace, devops string) error { req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/kapis/tenant.kubesphere.io/v1alpha2/workspaces/%s/devops/%s", ksAPIServer, workspace, devops), nil) if err != nil { + glog.Error(err) return err } req.Header.Add(constants.UserNameHeader, constants.AdminUserName) - if err != nil { - return err - } - log.Println(req.Method, req.URL) + + glog.Info(req.Method, req.URL) resp, err := c.client.Do(req) if err != nil { + glog.Error(err) return err } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { + glog.Error(err) return err } if resp.StatusCode > http.StatusOK { + glog.Error(req.Method, req.URL, resp.StatusCode, string(data)) return Error{resp.StatusCode, string(data)} } From 2b427b8e685222994b25598f2892936b0535ce94 Mon Sep 17 00:00:00 2001 From: soulseen Date: Wed, 15 May 2019 20:49:10 +0800 Subject: [PATCH 05/24] update jenkins api doc Signed-off-by: soulseen --- pkg/apis/devops/v1alpha2/register.go | 322 +++++++++++++-------------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index 3d00249e7..e9db0ce7c 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -134,7 +134,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.UpdateDevOpsProjectPipelineHandler). Doc("update devops project pipeline"). Param(webservice.PathParameter("devops", "devops project's Id")). - Param(webservice.PathParameter("pipelines", "pipeline name")). + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Metadata(restfulspec.KeyOpenAPITags, tags). Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}). Writes(devops.ProjectPipeline{}). @@ -145,7 +145,7 @@ func addWebService(c *restful.Container) error { Doc("get devops project pipeline config"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). - Param(webservice.PathParameter("pipelines", "pipeline name")). + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}). Writes(devops.ProjectPipeline{})) @@ -154,7 +154,7 @@ func addWebService(c *restful.Container) error { Doc("get devops project pipeline sonarStatus"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). - Param(webservice.PathParameter("pipelines", "pipeline name")). + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Returns(http.StatusOK, RespOK, []devops.SonarStatus{}). Writes([]devops.SonarStatus{})) @@ -163,7 +163,7 @@ func addWebService(c *restful.Container) error { Doc("get devops project pipeline sonarStatus"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). - Param(webservice.PathParameter("pipelines", "pipeline name")). + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branches", "branch name")). Returns(http.StatusOK, RespOK, []devops.SonarStatus{}). Writes([]devops.SonarStatus{})) @@ -173,7 +173,7 @@ func addWebService(c *restful.Container) error { Doc("delete devops project pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). - Param(webservice.PathParameter("pipelines", "pipeline name"))) + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment."))) webservice.Route(webservice.POST("/devops/{devops}/credentials"). To(devopsapi.CreateDevOpsProjectCredentialHandler). @@ -223,8 +223,8 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get DevOps Pipelines."). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("projectName", "devops project name")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). Returns(http.StatusOK, RespOK, devops.Pipeline{}). Writes(devops.Pipeline{})) @@ -233,16 +233,16 @@ func addWebService(c *restful.Container) error { To(devopsapi.SearchPipelines). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Search DevOps resource."). - Param(webservice.QueryParameter("q", "query pipelines"). + Param(webservice.QueryParameter("q", "query pipelines, condition for filtering."). Required(false). DataFormat("q=%s")). - Param(webservice.QueryParameter("filter", "filter resource"). + Param(webservice.QueryParameter("filter", "Condition for filteringfilter folders or not.."). Required(false). DataFormat("filter=%s")). - Param(webservice.QueryParameter("start", "start page"). + Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.Pipeline{}). @@ -253,15 +253,15 @@ func addWebService(c *restful.Container) error { To(devopsapi.SearchPipelineRuns). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Search DevOps Pipelines runs in branch."). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.QueryParameter("start", "start page"). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). - Param(webservice.QueryParameter("branch", "branch "). + Param(webservice.QueryParameter("branch", "the name of branch, same as repository brnach, will be filter by branch."). Required(false). DataFormat("branch=%s")). Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}). @@ -272,11 +272,11 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get DevOps Pipelines run in branch."). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). Returns(http.StatusOK, RespOK, devops.BranchPipelineRun{}). @@ -287,11 +287,11 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipelineRunNodesbyBranch). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get node on DevOps Pipelines run."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("limit", "limit"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d"). DefaultValue("limit=10000")). @@ -304,13 +304,13 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.PathParameter("nodeId", "pipeline runs node id")). - Param(webservice.PathParameter("stepId", "pipeline runs step id")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(true). DataFormat("start=%d"). DefaultValue("start=0"))) @@ -321,12 +321,12 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.PathParameter("nodeId", "pipeline runs node id")). - Param(webservice.PathParameter("stepId", "pipeline runs step id")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(true). DataFormat("start=%d"). DefaultValue("start=0"))) @@ -336,7 +336,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.Validate). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Validate Github personal access token."). - Param(webservice.PathParameter("scmId", "SCM id")). + Param(webservice.PathParameter("scmId", "the id of SCM.")). Returns(http.StatusOK, RespOK, devops.Validates{}). Writes(devops.Validates{})) @@ -345,8 +345,8 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetSCMOrg). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("List organizations of SCM"). - Param(webservice.PathParameter("scmId", "SCM id")). - Param(webservice.QueryParameter("credentialId", "credential id for SCM"). + Param(webservice.PathParameter("scmId", "the id of SCM.")). + Param(webservice.QueryParameter("credentialId", "credential id for SCM."). Required(true). DataFormat("credentialId=%s")). Returns(http.StatusOK, RespOK, []devops.SCMOrg{}). @@ -358,14 +358,14 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get SCM repositories in an organization"). Param(webservice.PathParameter("scmId", "SCM id")). - Param(webservice.PathParameter("organizationId", "organization Id, such as github username")). - Param(webservice.QueryParameter("credentialId", "credential id for SCM"). + Param(webservice.PathParameter("organizationId", "organization Id, such as github username.")). + Param(webservice.QueryParameter("credentialId", "credential id for SCM."). Required(true). DataFormat("credentialId=%s")). - Param(webservice.QueryParameter("pageNumber", "page number"). + Param(webservice.QueryParameter("pageNumber", "the number of page."). Required(true). DataFormat("pageNumber=%d")). - Param(webservice.QueryParameter("pageSize", "page size"). + Param(webservice.QueryParameter("pageSize", "the size of page."). Required(true). DataFormat("pageSize=%d")). Returns(http.StatusOK, RespOK, []devops.OrgRepo{}). @@ -376,15 +376,15 @@ func addWebService(c *restful.Container) error { To(devopsapi.StopBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Stop pipeline in running"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep."). Required(false). DataFormat("blocking=%t"). DefaultValue("blocking=false")). - Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep"). + Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep."). Required(false). DataFormat("timeOutInSecs=%d"). DefaultValue("timeOutInSecs=10")). @@ -396,14 +396,14 @@ func addWebService(c *restful.Container) error { To(devopsapi.StopPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Stop pipeline in running"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep."). Required(false). DataFormat("blocking=%t"). DefaultValue("blocking=false")). - Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep"). + Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep."). Required(false). DataFormat("timeOutInSecs=%d"). DefaultValue("timeOutInSecs=10")). @@ -415,10 +415,10 @@ func addWebService(c *restful.Container) error { To(devopsapi.ReplayBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.ReplayPipe{}). Writes(devops.ReplayPipe{})) @@ -427,9 +427,9 @@ func addWebService(c *restful.Container) error { To(devopsapi.ReplayPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.ReplayPipe{}). Writes(devops.ReplayPipe{})) @@ -439,11 +439,11 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(true). DataFormat("start=%d"). DefaultValue("start=0"))) @@ -454,10 +454,10 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(true). DataFormat("start=%d"). DefaultValue("start=0"))) @@ -467,14 +467,14 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("start", "start page"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}). @@ -485,13 +485,13 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("start", "start page"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}). @@ -502,15 +502,15 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipeBranch). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline of branch."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.QueryParameter("filter", "filter remote"). Required(true). DataFormat("filter=%s")). - Param(webservice.QueryParameter("start", "start"). + Param(webservice.QueryParameter("start", "the count of item start."). Required(true). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.PipeBranch{}). @@ -523,12 +523,12 @@ func addWebService(c *restful.Container) error { Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build."). Reads(devops.CheckPlayload{}). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). - Param(webservice.PathParameter("stepId", "pipeline step id"))) + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline."))) // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId} webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}"). @@ -537,10 +537,10 @@ func addWebService(c *restful.Container) error { Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build."). Reads(devops.CheckPlayload{}). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). Param(webservice.PathParameter("stepId", "pipeline step id"))) // match /job/project-8QnvykoJw4wZ/job/test-1/indexing/consoleText @@ -549,8 +549,8 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get index console log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name"))) + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment."))) // match /job/{projectName}/job/{pipelineName}/build?delay=0 webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/scan"). @@ -558,10 +558,10 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Start a build."). Produces("text/html; charset=utf-8"). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.QueryParameter("delay", "delay time"). - Required(true). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.QueryParameter("delay", "will be delay time to scan."). + Required(false). DataFormat("delay=%d"))) // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/ @@ -570,9 +570,9 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). Writes(devops.QueuedBlueRun{})) @@ -582,8 +582,8 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). Writes(devops.QueuedBlueRun{})) @@ -592,12 +592,12 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchStepsStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline steps status."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline run name")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). @@ -608,11 +608,11 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetStepsStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline steps status."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline run name")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). @@ -622,7 +622,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/crumbissuer"). To(devopsapi.GetCrumb). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get crumb"). + Doc("Get crumb issuer."). Returns(http.StatusOK, RespOK, devops.Crumb{}). Writes(devops.Crumb{})) @@ -643,7 +643,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Produces("application/json", "charset=utf-8"). Doc("Check cron script compile."). - Param(webservice.QueryParameter("value", "cpec value"). + Param(webservice.QueryParameter("value", "string of cron script."). Required(true). DataFormat("value=%s")). Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). @@ -655,9 +655,9 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get run pipeline in project."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline run id")). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.PipelineRun{}). Writes(devops.PipelineRun{})) @@ -665,10 +665,10 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}"). To(devopsapi.GetBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get Pipeline run in branch."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). + Doc("Get Pipeline run by branch."). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach")). Returns(http.StatusOK, RespOK, devops.BranchPipeline{}). Writes(devops.BranchPipeline{})) @@ -677,10 +677,10 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipelineRunNodes). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipeline run nodes."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline run id")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")). + Param(webservice.QueryParameter("limit", "the count of item limit"). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.PipelineRunNodes{}). @@ -690,13 +690,13 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps"). To(devopsapi.GetBranchNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get steps in node."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline run id")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). - Param(webservice.QueryParameter("limit", "limit count"). + Doc("Get steps in node by branch."). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.NodeSteps{}). @@ -707,11 +707,11 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get steps in node."). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("runId", "pipeline run id")). - Param(webservice.PathParameter("nodeId", "pipeline node id")). - Param(webservice.QueryParameter("limit", "limit count"). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")). + Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.NodeSteps{}). @@ -723,7 +723,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). Produces("application/json", "charset=utf-8"). - Doc("Json to Jenkinsfile."). + Doc("Convert json to jenkinsfile format."). Reads(devops.ReqJson{}). Returns(http.StatusOK, RespOK, devops.NodeSteps{}). Writes(devops.ResJenkinsfile{})) @@ -734,7 +734,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). Produces("application/json", "charset=utf-8"). - Doc("Jenkinsfile to Json."). + Doc("Convert jenkinsfile to json format."). Reads(devops.ReqJenkinsfile{}). Returns(http.StatusOK, RespOK, devops.ResJson{}). Writes(devops.ResJson{})) @@ -743,7 +743,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/notifycommit"). To(devopsapi.GetNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get Notify Commit by GET HTTP method."). + Doc("Get notify commit by GET HTTP method."). Produces("text/plain; charset=utf-8"). Param(webservice.QueryParameter("url", "the url for webhook to push."). Required(true). @@ -753,7 +753,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.POST("/devops/notifycommit"). To(devopsapi.GetNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get Notify Commit by POST HTTP method."). + Doc("Get notify commit by POST HTTP method."). Consumes("application/json"). Produces("text/plain; charset=utf-8"). Param(webservice.QueryParameter("url", "the url for webhook to push."). @@ -769,12 +769,12 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodesdetail"). To(devopsapi.GetBranchNodesDetail). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get pipeline nodes stages detail"). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("limit", "limit count"). + Doc("Gives steps details inside a pipeline node by branch. For a Stage, the steps will include all the steps defined inside the stage."). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.NodesDetail{}). @@ -784,12 +784,12 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodesdetail"). To(devopsapi.GetNodesDetail). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get pipeline nodes stages detail"). - Param(webservice.PathParameter("pipelineName", "pipeline name")). - Param(webservice.PathParameter("projectName", "devops project name")). - Param(webservice.PathParameter("branchName", "pipeline branch name")). - Param(webservice.PathParameter("runId", "pipeline runs id")). - Param(webservice.QueryParameter("limit", "limit count"). + Doc("Gives steps details inside a pipeline node. For a Stage, the steps will include all the steps defined inside the stage."). + Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.QueryParameter("limit", "the count of item limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.NodesDetail{}). From 8979d3a67ddd903f64313e907e14e01be6957241 Mon Sep 17 00:00:00 2001 From: soulseen Date: Wed, 22 May 2019 11:58:19 +0800 Subject: [PATCH 06/24] filter jenkins header Signed-off-by: soulseen --- pkg/apiserver/devops/devops.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/devops/devops.go b/pkg/apiserver/devops/devops.go index 13314add0..3fe06266c 100644 --- a/pkg/apiserver/devops/devops.go +++ b/pkg/apiserver/devops/devops.go @@ -23,8 +23,11 @@ import ( log "github.com/golang/glog" "kubesphere.io/kubesphere/pkg/models/devops" "net/http" + "strings" ) +const jenkinsHeaderPre = "X-" + func GetPipeline(req *restful.Request, resp *restful.Response) { projectName := req.PathParameter("projectName") pipelineName := req.PathParameter("pipelineName") @@ -111,7 +114,9 @@ func GetBranchStepLog(req *restful.Request, resp *restful.Response) { return } for k, v := range header { - resp.AddHeader(k, v[0]) + if strings.HasPrefix(k, jenkinsHeaderPre) { + resp.AddHeader(k, v[0]) + } } resp.Write(res) } @@ -129,7 +134,9 @@ func GetStepLog(req *restful.Request, resp *restful.Response) { return } for k, v := range header { - resp.AddHeader(k, v[0]) + if strings.HasPrefix(k, jenkinsHeaderPre) { + resp.AddHeader(k, v[0]) + } } resp.Write(res) } From 01b79df455bc0a0fe2af737568ed42da09bef813 Mon Sep 17 00:00:00 2001 From: soulseen Date: Mon, 27 May 2019 17:19:11 +0800 Subject: [PATCH 07/24] add log err Signed-off-by: soulseen --- pkg/models/devops/devops.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index 69c4d37a5..4b2a1d152 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -698,6 +698,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro defer resp.Body.Close() if resp.StatusCode >= http.StatusBadRequest { + log.Errorf("%+v", string(resBody)) jkerr := new(JkError) jkerr.Code = resp.StatusCode jkerr.Message = http.StatusText(resp.StatusCode) From 7e1774eb069659ab9ffd491c12c76dbecf19893f Mon Sep 17 00:00:00 2001 From: soulseen Date: Tue, 4 Jun 2019 11:05:08 +0800 Subject: [PATCH 08/24] fix url format Signed-off-by: soulseen --- pkg/models/devops/devops.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index 4b2a1d152..cc07aa469 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -68,10 +68,11 @@ func SearchPipelines(req *http.Request) ([]byte, error) { } func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]byte, error) { - baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl+req.URL.RawQuery, projectName, pipelineName) + baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl, projectName, pipelineName) + log.Infof("Jenkins-url: " + baseUrl) - res, err := sendJenkinsRequest(baseUrl, req) + res, err := sendJenkinsRequest(baseUrl + req.URL.RawQuery, req) if err != nil { log.Error(err) return nil, err @@ -277,10 +278,10 @@ func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([ } func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) { - baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl+req.URL.RawQuery, projectName, pipelineName) + baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl, projectName, pipelineName) log.Infof("Jenkins-url: " + baseUrl) - res, err := sendJenkinsRequest(baseUrl, req) + res, err := sendJenkinsRequest(baseUrl + req.URL.RawQuery, req) if err != nil { log.Error(err) return nil, err @@ -544,7 +545,7 @@ func ToJson(req *http.Request) ([]byte, error) { } func GetNotifyCommit(req *http.Request) ([]byte, error) { - baseUrl := fmt.Sprintf(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery) + baseUrl := fmt.Sprint(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery) log.Infof("Jenkins-url: " + baseUrl) req.Method = "GET" From 2f02aa55cca10b5babb6e9a809ce60dd765c4769 Mon Sep 17 00:00:00 2001 From: soulseen Date: Tue, 4 Jun 2019 11:08:11 +0800 Subject: [PATCH 09/24] format log Signed-off-by: soulseen --- pkg/apiserver/devops/devops.go | 2 +- pkg/models/devops/devops.go | 84 +++++++++++++++++----------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/pkg/apiserver/devops/devops.go b/pkg/apiserver/devops/devops.go index 3fe06266c..275635b4f 100644 --- a/pkg/apiserver/devops/devops.go +++ b/pkg/apiserver/devops/devops.go @@ -26,7 +26,7 @@ import ( "strings" ) -const jenkinsHeaderPre = "X-" +const jenkinsHeaderPre = "X-" func GetPipeline(req *restful.Request, resp *restful.Response) { projectName := req.PathParameter("projectName") diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index cc07aa469..bad0c3f87 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -70,9 +70,9 @@ func SearchPipelines(req *http.Request) ([]byte, error) { func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl, projectName, pipelineName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) - res, err := sendJenkinsRequest(baseUrl + req.URL.RawQuery, req) + res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req) if err != nil { log.Error(err) return nil, err @@ -83,7 +83,7 @@ func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([] func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchRunUrl, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -96,7 +96,7 @@ func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, r func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -109,7 +109,7 @@ func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId st func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, header, err := jenkinsClient(baseUrl, req) if err != nil { @@ -122,7 +122,7 @@ func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, step func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetStepLogUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId, stepId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, header, err := jenkinsClient(baseUrl, req) if err != nil { @@ -136,7 +136,7 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht func Validate(scmId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -149,7 +149,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) { func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetSCMOrgUrl+req.URL.RawQuery, scmId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -162,7 +162,7 @@ func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) { func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetOrgRepoUrl+req.URL.RawQuery, scmId, organizationId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -175,7 +175,7 @@ func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error) func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+StopBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -188,7 +188,7 @@ func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -201,7 +201,7 @@ func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([ func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+ReplayBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -214,7 +214,7 @@ func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, r func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+ReplayPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -227,7 +227,7 @@ func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchRunLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -240,7 +240,7 @@ func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *h func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetRunLogUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -253,7 +253,7 @@ func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]by func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -266,7 +266,7 @@ func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -279,9 +279,9 @@ func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl, projectName, pipelineName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) - res, err := sendJenkinsRequest(baseUrl + req.URL.RawQuery, req) + res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req) if err != nil { log.Error(err) return nil, err @@ -292,7 +292,7 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+CheckBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -305,7 +305,7 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+CheckPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId, stepId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -318,7 +318,7 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetConsoleLogUrl+req.URL.RawQuery, projectName, pipelineName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -331,7 +331,7 @@ func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+ScanBranchUrl+req.URL.RawQuery, projectName, pipelineName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -344,7 +344,7 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+RunBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -357,7 +357,7 @@ func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.R func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -370,7 +370,7 @@ func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, e func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -383,7 +383,7 @@ func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId s func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -396,7 +396,7 @@ func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.R func GetCrumb(req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -409,7 +409,7 @@ func GetCrumb(req *http.Request) ([]byte, error) { func CheckScriptCompile(req *http.Request) ([]byte, error) { baseUrl := jenkins.Server + CheckScriptCompileUrl - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password) resBody, err := sendJenkinsRequest(baseUrl, req) @@ -455,7 +455,7 @@ func CheckCron(req *http.Request) (*CheckCronRes, error) { func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetPipelineRunUrl, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -468,7 +468,7 @@ func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeUrl, projectName, pipelineName, branchName) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -481,7 +481,7 @@ func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.R func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -494,7 +494,7 @@ func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Requ func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetBranchNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -507,7 +507,7 @@ func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId str func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+GetNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -520,7 +520,7 @@ func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Req func ToJenkinsfile(req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server + ToJenkinsfileUrl) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -533,7 +533,7 @@ func ToJenkinsfile(req *http.Request) ([]byte, error) { func ToJson(req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server + ToJsonUrl) - log.Infof("Jenkins-url: " + baseUrl) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -545,8 +545,8 @@ func ToJson(req *http.Request) ([]byte, error) { } func GetNotifyCommit(req *http.Request) ([]byte, error) { - baseUrl := fmt.Sprint(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery) - log.Infof("Jenkins-url: " + baseUrl) + baseUrl := fmt.Sprint(jenkins.Server, GetNotifyCommitUrl, req.URL.RawQuery) + log.Info("Jenkins-url: " + baseUrl) req.Method = "GET" res, err := sendJenkinsRequest(baseUrl, req) @@ -559,8 +559,8 @@ func GetNotifyCommit(req *http.Request) ([]byte, error) { } func GithubWebhook(req *http.Request) ([]byte, error) { - baseUrl := fmt.Sprintf(jenkins.Server + GithubWebhookUrl + req.URL.RawQuery) - log.Infof("Jenkins-url: " + baseUrl) + baseUrl := fmt.Sprint(jenkins.Server, GithubWebhookUrl, req.URL.RawQuery) + log.Info("Jenkins-url: " + baseUrl) res, err := sendJenkinsRequest(baseUrl, req) if err != nil { @@ -573,7 +573,7 @@ func GithubWebhook(req *http.Request) ([]byte, error) { func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, req *http.Request) ([]NodesDetail, error) { getNodesUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) - log.Infof("getNodesUrl: " + getNodesUrl) + log.Info("getNodesUrl: " + getNodesUrl) var wg sync.WaitGroup var nodesDetails []NodesDetail stepChan := make(chan *NodesStepsIndex, channelMaxCapacity) @@ -620,7 +620,7 @@ func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, r func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]NodesDetail, error) { getNodesUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId) - log.Infof("getNodesUrl: " + getNodesUrl) + log.Info("getNodesUrl: " + getNodesUrl) var wg sync.WaitGroup var nodesDetails []NodesDetail stepChan := make(chan *NodesStepsIndex, channelMaxCapacity) From 6f941dce91ac6b89f562a48d3380d929967b2959 Mon Sep 17 00:00:00 2001 From: huanggze Date: Tue, 4 Jun 2019 13:53:56 +0800 Subject: [PATCH 10/24] fix: update log statistics response, remove sorting by time Signed-off-by: huanggze --- pkg/simple/client/elasticsearch/esclient.go | 36 ++++++--------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/pkg/simple/client/elasticsearch/esclient.go b/pkg/simple/client/elasticsearch/esclient.go index b78900b32..0e44fbac5 100644 --- a/pkg/simple/client/elasticsearch/esclient.go +++ b/pkg/simple/client/elasticsearch/esclient.go @@ -137,12 +137,9 @@ type ContainerHighLightField struct { type EmptyField struct { } -// The aggs object holds two aggregations to be computed by Elasticsearch -// ContainterAgg is a cardinality aggregation to calculate the count of distinct containers -// StartTimeAgg is a top hits aggregation to retrieve the first record +// StatisticsAggs, the struct for `aggs` of type Request, holds a cardinality aggregation for distinct container counting type StatisticsAggs struct { ContainerAgg ContainerAgg `json:"containers"` - StartTimeAgg StartTimeAgg `json:"starttime"` } type ContainerAgg struct { @@ -153,15 +150,6 @@ type AggField struct { Field string `json:"field"` } -type StartTimeAgg struct { - TopHits TopHits `json:"top_hits"` -} - -type TopHits struct { - Sort []Sort `json:"sort"` - Size int `json:"size"` -} - type HistogramAggs struct { HistogramAgg HistogramAgg `json:"histogram"` } @@ -255,8 +243,7 @@ func createQueryRequest(param QueryParameters) (int, []byte, error) { if param.Operation == "statistics" { operation = OperationStatistics containerAgg := AggField{"kubernetes.docker_id.keyword"} - startTimeAgg := TopHits{[]Sort{{Order{"asc"}}}, 1} - statisticAggs := StatisticsAggs{ContainerAgg{containerAgg}, StartTimeAgg{startTimeAgg}} + statisticAggs := StatisticsAggs{ContainerAgg{containerAgg}} request.Aggs = statisticAggs request.Size = 0 } else if param.Operation == "histogram" { @@ -361,20 +348,15 @@ type ReadResult struct { Records []LogRecord `json:"records,omitempty"` } -// The aggregations object represents the return from an aggregation (see StatisticsAggs type) +// StatisticsResponseAggregations, the struct for `aggregations` of type Reponse, holds return results from the aggregation StatisticsAggs type StatisticsResponseAggregations struct { - ContainerCount ContainerCount `json:"containers"` - StartTime StartTimeTopHit `json:"starttime"` + ContainerCount ContainerCount `json:"containers"` } type ContainerCount struct { Value int64 `json:"value"` } -type StartTimeTopHit struct { - Hits Hits `json:"hits"` -} - type HistogramAggregations struct { HistogramAggregation HistogramAggregation `json:"histogram"` } @@ -396,7 +378,6 @@ type HistogramRecord struct { type StatisticsResult struct { Containers int64 `json:"containers"` Logs int64 `json:"logs"` - StartTime int64 `json:"starttime"` } type HistogramResult struct { @@ -460,13 +441,14 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [ if response.Status != 0 { //Elastic error, eg, es_rejected_execute_exception queryResult.Status = response.Status + glog.Errorln("The query failed with no response") return &queryResult } if response.Shards.Successful != response.Shards.Total { //Elastic some shards error - queryResult.Status = http.StatusInternalServerError - return &queryResult + glog.Warningf("Not all shards succeed, successful shards: %d, skipped shards: %d, failed shards: %d", + response.Shards.Successful, response.Shards.Skipped, response.Shards.Failed) } switch operation { @@ -496,8 +478,7 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [ queryResult.Status = http.StatusInternalServerError return &queryResult } - queryResult.Statistics = &StatisticsResult{Containers: statisticsResponse.ContainerCount.Value, - Logs: statisticsResponse.StartTime.Hits.Total, StartTime: statisticsResponse.StartTime.Hits.Hits[0].Sort[0]} + queryResult.Statistics = &StatisticsResult{Containers: statisticsResponse.ContainerCount.Value, Logs: response.Hits.Total} case OperationHistogram: var histogramResult HistogramResult @@ -583,6 +564,7 @@ func Query(param QueryParameters) *QueryResult { } url := fmt.Sprintf("http://%s:%s/%s*/_search", es.Host, es.Port, es.Index) + request, err := http.NewRequest("GET", url, bytes.NewBuffer(query)) if err != nil { glog.Errorln(err) From 22dca0ad55f29ec12f2e4ad6494cb9fb037cfbb3 Mon Sep 17 00:00:00 2001 From: hongming Date: Tue, 4 Jun 2019 16:43:11 +0800 Subject: [PATCH 11/24] fix: enable clusterrolebinding controller Signed-off-by: hongming --- pkg/controller/add_clusterrolebinding.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/controller/add_clusterrolebinding.go b/pkg/controller/add_clusterrolebinding.go index 81f328438..2fc0def5d 100644 --- a/pkg/controller/add_clusterrolebinding.go +++ b/pkg/controller/add_clusterrolebinding.go @@ -18,7 +18,9 @@ package controller +import "kubesphere.io/kubesphere/pkg/controller/clusterrolebinding" + func init() { // AddToManagerFuncs is a list of functions to create controllers and add them to a manager. - //AddToManagerFuncs = append(AddToManagerFuncs, clusterrolebinding.Add) + AddToManagerFuncs = append(AddToManagerFuncs, clusterrolebinding.Add) } From fd530f4c1ecc4a81946c35419132a56a95b58f08 Mon Sep 17 00:00:00 2001 From: runzexia Date: Wed, 5 Jun 2019 14:09:39 +0800 Subject: [PATCH 12/24] tmp commit Signed-off-by: runzexia --- pkg/apis/devops/v1alpha2/register.go | 4 +- pkg/models/devops/common.go | 4 +- pkg/models/devops/membership.go | 10 +-- pkg/models/devops/project.go | 26 ++++-- pkg/models/devops/project_credential.go | 8 +- pkg/models/devops/project_pipeline.go | 110 ++++++++++++------------ 6 files changed, 85 insertions(+), 77 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index 3d00249e7..b1ae75ac7 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -58,7 +58,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.PATCH("/devops/{devops}"). To(devopsapi.UpdateProjectHandler). - Doc("get devops project"). + Doc("update devops project"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). @@ -66,7 +66,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/defaultroles"). To(devopsapi.GetDevOpsProjectDefaultRoles). - Doc("get devops project defaultroles"). + Doc("get devops project default roles"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Returns(http.StatusOK, RespOK, []devops.Role{}). diff --git a/pkg/models/devops/common.go b/pkg/models/devops/common.go index 2419945e3..f2c51ed07 100644 --- a/pkg/models/devops/common.go +++ b/pkg/models/devops/common.go @@ -79,8 +79,8 @@ const ( ) type Role struct { - Name string `json:"name"` - Description string `json:"description"` + Name string `json:"name" description:"role's name'"` + Description string `json:"description" description:"role 's description'"` } var DefaultRoles = []*Role{ diff --git a/pkg/models/devops/membership.go b/pkg/models/devops/membership.go index cbce69e31..8f48a92d7 100644 --- a/pkg/models/devops/membership.go +++ b/pkg/models/devops/membership.go @@ -21,11 +21,11 @@ const ( ) type DevOpsProjectMembership struct { - Username string `json:"username"` - ProjectId string `json:"project_id" db:"project_id"` - Role string `json:"role"` - Status string `json:"status"` - GrantBy string `json:"grand_by,omitempty"` + Username string `json:"username" description:"member's username,username can uniquely identify a user"` + ProjectId string `json:"project_id" db:"project_id" description:"the devops projects which project membership belongs to"` + Role string `json:"role" description:"devops project membership's role type'"` + Status string `json:"status" description:"Desperated, status of project membership"` + GrantBy string `json:"grand_by,omitempty" description:"Username of the user who assigned the role"` } var DevOpsProjectMembershipColumns = GetColumnsFromStruct(&DevOpsProjectMembership{}) diff --git a/pkg/models/devops/project.go b/pkg/models/devops/project.go index 37111f3e5..222b2f01b 100644 --- a/pkg/models/devops/project.go +++ b/pkg/models/devops/project.go @@ -37,15 +37,23 @@ type PageableDevOpsProject struct { } type DevOpsProject struct { - ProjectId string `json:"project_id" db:"project_id"` - Name string `json:"name"` - Description string `json:"description,omitempty"` - Creator string `json:"creator"` - CreateTime time.Time `json:"create_time"` - Status string `json:"status"` - Visibility string `json:"visibility,omitempty"` - Extra string `json:"extra,omitempty"` - Workspace string `json:"workspace"` + ProjectId string `json:"project_id" db:"project_id" description:"ProjectId must be unique within a namespace, it is generated by kubesphere."` + + Name string `json:"name" description:"DevOps Projects's Name'"` + + Description string `json:"description,omitempty" description:"DevOps Projets's Description, used to describe the DevOps Project'"` + + Creator string `json:"creator" description:"Creator's username'"` + + CreateTime time.Time `json:"create_time" description:"DevOps Project's Creation time'"` + + Status string `json:"status" description:"DevOps project's status"` + + Visibility string `json:"visibility,omitempty" description:"Desperated Field"` + + Extra string `json:"extra,omitempty" description:"Internal Use"` + + Workspace string `json:"workspace" description:"The workspace to which the devops project belongs"` } func NewDevOpsProject(name, description, creator, extra, workspace string) *DevOpsProject { diff --git a/pkg/models/devops/project_credential.go b/pkg/models/devops/project_credential.go index dd08a4dab..7b6b49f65 100644 --- a/pkg/models/devops/project_credential.go +++ b/pkg/models/devops/project_credential.go @@ -26,9 +26,9 @@ const ( ) type JenkinsCredential struct { - Id string `json:"id"` - Type string `json:"type"` - DisplayName string `json:"display_name,omitempty"` + Id string `json:"id" description:"id of credential"` + Type string `json:"type" description:"type of credential,such as ssh/kubeconfig"` + DisplayName string `json:"display_name,omitempty" description:"credential's display name'"` Fingerprint *struct { FileName string `json:"file_name,omitempty"` Hash string `json:"hash,omitempty"` @@ -41,7 +41,7 @@ type JenkinsCredential struct { } `json:"ranges,omitempty"` } `json:"ranges,omitempty"` } `json:"usage,omitempty"` - } `json:"fingerprint,omitempty"` + } `json:"fingerprint,omitempty" description:""` Description string `json:"description,omitempty"` Domain string `json:"domain,omitempty"` CreateTime *time.Time `json:"create_time,omitempty"` diff --git a/pkg/models/devops/project_pipeline.go b/pkg/models/devops/project_pipeline.go index 08ea84596..ad876ebac 100644 --- a/pkg/models/devops/project_pipeline.go +++ b/pkg/models/devops/project_pipeline.go @@ -53,99 +53,99 @@ type SonarStatus struct { } type ProjectPipeline struct { - Type string `json:"type"` - Pipeline *NoScmPipeline `json:"pipeline,omitempty"` - MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty"` + Type string `json:"type" description:"type of devops pipeline, in scm or no scm"` + Pipeline *NoScmPipeline `json:"pipeline,omitempty" description:"no scm pipeline structs"` + MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty" description:"in scm pipeline structs"` } type NoScmPipeline struct { - Name string `json:"name"` - Description string `json:"descriptio,omitempty"` - Discarder *DiscarderProperty `json:"discarder,omitempty"` - Parameters []*Parameter `json:"parameters,omitempty"` - DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent"` - TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger"` - RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger"` - Jenkinsfile string `json:"jenkinsfile,omitempty"` + Name string `json:"name" description:"name of pipeline"` + Description string `json:"descriptio,omitempty" description:"description of pipeline"` + Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"` + Parameters []*Parameter `json:"parameters,omitempty" description:"Parameters define of pipeline,user could pass param when run pipeline"` + DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent" description:"Whether to prohibit the pipeline from running in parallel"` + TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"` + RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger" description:"Remote api define to trigger pipeline run"` + Jenkinsfile string `json:"jenkinsfile,omitempty" description:"Jenkinsfile's content'"` } type MultiBranchPipeline struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - Discarder *DiscarderProperty `json:"discarder,omitempty"` - TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger"` - SourceType string `json:"source_type"` - GitSource *GitSource `json:"git_source,omitempty"` - GitHubSource *GithubSource `json:"github_source,omitempty"` - SvnSource *SvnSource `json:"svn_source,omitempty"` - SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty"` - ScriptPath string `json:"script_path" mapstructure:"script_path"` + Name string `json:"name" description:"name of pipeline"` + Description string `json:"descriptio,omitempty" description:"description of pipeline"` + Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"` + TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"` + SourceType string `json:"source_type" description:"type of scm, such as github/git/svn"` + GitSource *GitSource `json:"git_source,omitempty" description:"git scm define"` + GitHubSource *GithubSource `json:"github_source,omitempty" description:"github scm define"` + SvnSource *SvnSource `json:"svn_source,omitempty" description:"multi branch svn scm define"` + SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty" description:"single branch svn scm define"` + ScriptPath string `json:"script_path" mapstructure:"script_path" description:"script path in scm"` } type GitSource struct { - Url string `json:"url,omitempty" mapstructure:"url"` - CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"` - DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches"` - CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option"` - RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter"` + Url string `json:"url,omitempty" mapstructure:"url" description:"url of git source"` + CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access git source"` + DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Whether to discover a branch"` + CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"` + RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"` } type GithubSource struct { - Owner string `json:"owner,omitempty" mapstructure:"owner"` - Repo string `json:"repo,omitempty" mapstructure:"repo"` - CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"` - ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri"` - DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches"` - DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin"` - DiscoverPRFromForks *GithubDiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks"` - CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option"` - RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter"` + Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"` + Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"` + CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"` + ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github apiserver.For private cloud configuration"` + DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"` + DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"` + DiscoverPRFromForks *GithubDiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"` + CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"` + RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"` } type GitCloneOption struct { - Shallow bool `json:"shallow,omitempty" mapstructure:"shallow"` - Timeout int `json:"timeout,omitempty" mapstructure:"timeout"` - Depth int `json:"depth,omitempty" mapstructure:"depth"` + Shallow bool `json:"shallow,omitempty" mapstructure:"shallow" description:"Whether to use git shallow clone"` + Timeout int `json:"timeout,omitempty" mapstructure:"timeout" description:"git clone timeout mins"` + Depth int `json:"depth,omitempty" mapstructure:"depth" description:"git clone depth"` } type SvnSource struct { - Remote string `json:"remote,omitempty"` - CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"` - Includes string `json:"includes,omitempty"` - Excludes string `json:"excludes,omitempty"` + Remote string `json:"remote,omitempty" description:"remote address url"` + CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"` + Includes string `json:"includes,omitempty" description:"branches to run pipeline"` + Excludes string `json:"excludes,omitempty" description:"branches do not run pipeline"` } type SingleSvnSource struct { - Remote string `json:"remote,omitempty"` - CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"` + Remote string `json:"remote,omitempty" description:"remote address url"` + CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"` } type GithubDiscoverPRFromForks struct { - Strategy int `json:"strategy,omitempty" mapstructure:"strategy"` - Trust int `json:"trust,omitempty" mapstructure:"trust"` + Strategy int `json:"strategy,omitempty" mapstructure:"strategy" description:"github discover startegy"` + Trust int `json:"trust,omitempty" mapstructure:"trust" description:"trust user type"` } type DiscarderProperty struct { - DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep"` - NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep"` + DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep" description:"days to keep pipeline"` + NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep" description:"nums to keep pipeline"` } type Parameter struct { - Name string `json:"name"` - DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value"` - Type string `json:"type"` - Description string `json:"description,omitempty"` + Name string `json:"name" description:"name of param"` + DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value" description:"default value of param"` + Type string `json:"type" description:"type of param"` + Description string `json:"description,omitempty" description:"description of pipeline"` } type TimerTrigger struct { // user in no scm job - Cron string `json:"cron,omitempty"` + Cron string `json:"cron,omitempty" description:"jenkins cron script"` // use in multi-branch job - Interval string `json:"interval,omitempty"` + Interval string `json:"interval,omitempty" description:"interval ms"` } type RemoteTrigger struct { - Token string `json:"token,omitempty"` + Token string `json:"token,omitempty" description:"remote trigger token"` } func replaceXmlVersion(config, oldVersion, targetVersion string) string { From 1b3e80519d9bb144910c92abb4e693790a7ea8e4 Mon Sep 17 00:00:00 2001 From: runzexia Date: Wed, 5 Jun 2019 15:47:38 +0800 Subject: [PATCH 13/24] update docs Signed-off-by: runzexia --- pkg/apis/devops/v1alpha2/register.go | 37 ++++++++------- pkg/apis/tenant/v1alpha2/register.go | 30 +++++++++++- pkg/gojenkins/credential.go | 16 +++---- pkg/models/devops/project_credential.go | 47 +++++++++---------- .../devops/project_credential_handler.go | 16 +++---- 5 files changed, 87 insertions(+), 59 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index b1ae75ac7..69637263c 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -50,7 +50,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}"). To(devopsapi.GetDevOpsProjectHandler). - Doc("get devops project"). + Doc("Get devops project"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). @@ -58,15 +58,16 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.PATCH("/devops/{devops}"). To(devopsapi.UpdateProjectHandler). - Doc("update devops project"). + Doc("Update devops project"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). + Reads(devops.DevOpsProject{}). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Writes(devops.DevOpsProject{})) webservice.Route(webservice.GET("/devops/{devops}/defaultroles"). To(devopsapi.GetDevOpsProjectDefaultRoles). - Doc("get devops project default roles"). + Doc("Get devops project default roles"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Returns(http.StatusOK, RespOK, []devops.Role{}). @@ -74,7 +75,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/members"). To(devopsapi.GetDevOpsProjectMembersHandler). - Doc("get devops project members"). + Doc("Get devops project members"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.QueryParameter(params.PagingParam, "page"). @@ -89,7 +90,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/members/{members}"). To(devopsapi.GetDevOpsProjectMemberHandler). - Doc("get devops project member"). + Doc("Get devops project member"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("members", "member's username")). @@ -98,7 +99,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.POST("/devops/{devops}/members"). To(devopsapi.AddDevOpsProjectMemberHandler). - Doc("add devops project members"). + Doc("Add devops project members"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}). @@ -106,7 +107,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.PATCH("/devops/{devops}/members/{members}"). To(devopsapi.UpdateDevOpsProjectMemberHandler). - Doc("update devops project members"). + Doc("Update devops project members"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("members", "member's username")). @@ -115,7 +116,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.DELETE("/devops/{devops}/members/{members}"). To(devopsapi.DeleteDevOpsProjectMemberHandler). - Doc("delete devops project members"). + Doc("Delete devops project members"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("members", "member's username")). @@ -123,7 +124,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.POST("/devops/{devops}/pipelines"). To(devopsapi.CreateDevOpsProjectPipelineHandler). - Doc("add devops project pipeline"). + Doc("Add devops project pipeline"). Param(webservice.PathParameter("devops", "devops project's Id")). Metadata(restfulspec.KeyOpenAPITags, tags). Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}). @@ -132,7 +133,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.PUT("/devops/{devops}/pipelines/{pipelines}"). To(devopsapi.UpdateDevOpsProjectPipelineHandler). - Doc("update devops project pipeline"). + Doc("Update devops project pipeline"). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("pipelines", "pipeline name")). Metadata(restfulspec.KeyOpenAPITags, tags). @@ -142,7 +143,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/config"). To(devopsapi.GetDevOpsProjectPipelineHandler). - Doc("get devops project pipeline config"). + Doc("Get devops project pipeline config"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("pipelines", "pipeline name")). @@ -151,7 +152,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/sonarStatus"). To(devopsapi.GetPipelineSonarStatusHandler). - Doc("get devops project pipeline sonarStatus"). + Doc("Get devops project pipeline sonarStatus"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("pipelines", "pipeline name")). @@ -160,7 +161,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/branches/{branches}/sonarStatus"). To(devopsapi.GetMultiBranchesPipelineSonarStatusHandler). - Doc("get devops project pipeline sonarStatus"). + Doc("Get devops project pipeline sonarStatus"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("pipelines", "pipeline name")). @@ -170,21 +171,21 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.DELETE("/devops/{devops}/pipelines/{pipelines}"). To(devopsapi.DeleteDevOpsProjectPipelineHandler). - Doc("delete devops project pipeline"). + Doc("Delete devops project pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("pipelines", "pipeline name"))) webservice.Route(webservice.POST("/devops/{devops}/credentials"). To(devopsapi.CreateDevOpsProjectCredentialHandler). - Doc("add project credential pipeline"). + Doc("Add project credential pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Reads(devops.JenkinsCredential{})) webservice.Route(webservice.PUT("/devops/{devops}/credentials/{credentials}"). To(devopsapi.UpdateDevOpsProjectCredentialHandler). - Doc("update project credential pipeline"). + Doc("Update project credential pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("credentials", "credential's Id")). @@ -199,7 +200,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/credentials/{credentials}"). To(devopsapi.GetDevOpsProjectCredentialHandler). - Doc("get project credential pipeline"). + Doc("Get project credential pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("credentials", "credential's Id")). @@ -210,7 +211,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{devops}/credentials"). To(devopsapi.GetDevOpsProjectCredentialsHandler). - Doc("get project credential pipeline"). + Doc("Get project credential pipeline"). Metadata(restfulspec.KeyOpenAPITags, tags). Param(webservice.PathParameter("devops", "devops project's Id")). Param(webservice.PathParameter("credentials", "credential's Id")). diff --git a/pkg/apis/tenant/v1alpha2/register.go b/pkg/apis/tenant/v1alpha2/register.go index 85684aff6..0af2b21c5 100644 --- a/pkg/apis/tenant/v1alpha2/register.go +++ b/pkg/apis/tenant/v1alpha2/register.go @@ -23,9 +23,15 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/tenant" + "kubesphere.io/kubesphere/pkg/models/devops" + "kubesphere.io/kubesphere/pkg/params" + "net/http" ) -const GroupName = "tenant.kubesphere.io" +const ( + GroupName = "tenant.kubesphere.io" + RespOK = "ok" +) var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"} @@ -87,23 +93,45 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/workspaces/{workspace}/devops"). To(tenant.ListDevopsProjects). Param(ws.PathParameter("workspace", "workspace name")). + Param(ws.QueryParameter(params.PagingParam, "page"). + Required(false). + DataFormat("limit=%d,page=%d"). + DefaultValue("limit=10,page=1")). + Param(ws.QueryParameter(params.ConditionsParam, "query conditions"). + Required(false). + DataFormat("key=%s,key~%s")). Doc("List devops projects for the current user"). + Writes([]devops.DevOpsProject{}). + Returns(http.StatusOK, RespOK, []devops.DevOpsProject{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). To(tenant.ListDevopsProjects). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "workspace member's username")). + Param(ws.QueryParameter(params.PagingParam, "page"). + Required(false). + DataFormat("limit=%d,page=%d"). + DefaultValue("limit=10,page=1")). + Param(ws.QueryParameter(params.ConditionsParam, "query conditions"). + Required(false). + DataFormat("key=%s,key~%s")). Doc("List the devops projects for the workspace member"). + Writes([]devops.DevOpsProject{}). + Returns(http.StatusOK, RespOK, []devops.DevOpsProject{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.POST("/workspaces/{workspace}/devops"). To(tenant.CreateDevopsProject). Param(ws.PathParameter("workspace", "workspace name")). Doc("Create devops project"). + Reads(devops.DevOpsProject{}). + Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{id}"). To(tenant.DeleteDevopsProject). Param(ws.PathParameter("workspace", "workspace name")). + Param(ws.PathParameter("id", "devops project id")). Doc("Delete devops project"). + Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/logging"). To(tenant.LogQuery). diff --git a/pkg/gojenkins/credential.go b/pkg/gojenkins/credential.go index 22576b013..0fc8f937c 100644 --- a/pkg/gojenkins/credential.go +++ b/pkg/gojenkins/credential.go @@ -87,18 +87,18 @@ type CredentialResponse struct { TypeName string `json:"typeName"` DisplayName string `json:"displayName"` Fingerprint *struct { - FileName string `json:"fileName,omitempty"` - Hash string `json:"hash,omitempty"` + FileName string `json:"file_name,omitempty" description:"credential's display name and description"` + Hash string `json:"hash,omitempty" description:"credential's hash'"` Usage []*struct { - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty" description:"jenkins pipeline full name"` Ranges struct { Ranges []*struct { - Start int `json:"start,omitempty"` - End int `json:"end,omitempty"` + Start int `json:"start,omitempty" description:"start build number"` + End int `json:"end,omitempty" description:"end build number"` } `json:"ranges,omitempty"` - } `json:"ranges,omitempty"` - } `json:"usage,omitempty"` - } `json:"fingerprint,omitempty"` + } `json:"ranges,omitempty" description:"all build num using credential"` + } `json:"usage,omitempty" description:"all usage of credential"` + } `json:"fingerprint,omitempty" description:"usage of credential"` Description string `json:"description,omitempty"` Domain string `json:"domain"` } diff --git a/pkg/models/devops/project_credential.go b/pkg/models/devops/project_credential.go index 7b6b49f65..f0a8663e3 100644 --- a/pkg/models/devops/project_credential.go +++ b/pkg/models/devops/project_credential.go @@ -30,46 +30,45 @@ type JenkinsCredential struct { Type string `json:"type" description:"type of credential,such as ssh/kubeconfig"` DisplayName string `json:"display_name,omitempty" description:"credential's display name'"` Fingerprint *struct { - FileName string `json:"file_name,omitempty"` - Hash string `json:"hash,omitempty"` + FileName string `json:"file_name,omitempty" description:"credential's display name and description"` + Hash string `json:"hash,omitempty" description:"credential's hash'"` Usage []*struct { - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty" description:"jenkins pipeline full name"` Ranges struct { Ranges []*struct { - Start int `json:"start,omitempty"` - End int `json:"end,omitempty"` + Start int `json:"start,omitempty" description:"start build number"` + End int `json:"end,omitempty" description:"end build number"` } `json:"ranges,omitempty"` - } `json:"ranges,omitempty"` - } `json:"usage,omitempty"` - } `json:"fingerprint,omitempty" description:""` - Description string `json:"description,omitempty"` - Domain string `json:"domain,omitempty"` - CreateTime *time.Time `json:"create_time,omitempty"` - Creator string `json:"creator,omitempty"` - UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty"` - SshCredential *SshCredential `json:"ssh,omitempty"` - SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty"` - KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty"` + } `json:"ranges,omitempty" description:"all build num using credential"` + } `json:"usage,omitempty" description:"all usage of credential"` + } `json:"fingerprint,omitempty" description:"usage of credential"` + Description string `json:"description,omitempty" description:"credential's description'"` + Domain string `json:"domain,omitempty" description:"credential's domain, default '_''"` + CreateTime *time.Time `json:"create_time,omitempty" description:"credential's create_time'"` + Creator string `json:"creator,omitempty" description:"creator's username"` + UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty" description:"username password credential struct"` + SshCredential *SshCredential `json:"ssh,omitempty" description:"ssh credential struct"` + SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty" description:"secret_text credential struct"` + KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty" description:"kubeconfig credential struct"` } type UsernamePasswordCredential struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` + Username string `json:"username,omitempty" description:"username of username_password credential"` + Password string `json:"password,omitempty" description:"password of username_password credential"` } type SshCredential struct { - Username string `json:"username,omitempty"` - Passphrase string `json:"passphrase,omitempty"` - PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key"` + Username string `json:"username,omitempty" description:"username of ssh credential"` + Passphrase string `json:"passphrase,omitempty" description:"passphrase of ssh credential, password of ssh credential"` + PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key" description:"private key of ssh credential"` } type SecretTextCredential struct { - Secret string `json:"secret,omitempty"` - Description string `json:"description,omitempty"` + Secret string `json:"secret,omitempty" description:"secret content of credential"` } type KubeconfigCredential struct { - Content string `json:"content,omitempty"` + Content string `json:"content,omitempty" description:"content of kubeconfig"` } const ( diff --git a/pkg/models/devops/project_credential_handler.go b/pkg/models/devops/project_credential_handler.go index cc7d08f11..dce8416c7 100644 --- a/pkg/models/devops/project_credential_handler.go +++ b/pkg/models/devops/project_credential_handler.go @@ -205,7 +205,7 @@ func UpdateProjectCredential(projectId, credentialId string, credentialRequest * credentialId, err := jenkinsClient.UpdateSecretTextCredentialInFolder(credentialRequest.Domain, credentialId, credentialRequest.SecretTextCredential.Secret, - credentialRequest.SecretTextCredential.Description, + credentialRequest.Description, projectId) if err != nil { glog.Errorf("%+v", err) @@ -421,17 +421,17 @@ func formatCredentialResponse( response.DisplayName = jenkinsCredentialResponse.DisplayName if jenkinsCredentialResponse.Fingerprint != nil && jenkinsCredentialResponse.Fingerprint.Hash != "" { response.Fingerprint = &struct { - FileName string `json:"file_name,omitempty"` - Hash string `json:"hash,omitempty"` + FileName string `json:"file_name,omitempty" description:"credential's display name and description"` + Hash string `json:"hash,omitempty" description:"credential's hash'"` Usage []*struct { - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty" description:"jenkins pipeline full name"` Ranges struct { Ranges []*struct { - Start int `json:"start,omitempty"` - End int `json:"end,omitempty"` + Start int `json:"start,omitempty" description:"start build number"` + End int `json:"end,omitempty" description:"end build number"` } `json:"ranges,omitempty"` - } `json:"ranges,omitempty"` - } `json:"usage,omitempty"` + } `json:"ranges,omitempty" description:"all build num using credential"` + } `json:"usage,omitempty" description:"all usage of credential"` }{} response.Fingerprint.FileName = jenkinsCredentialResponse.Fingerprint.FileName response.Fingerprint.Hash = jenkinsCredentialResponse.Fingerprint.Hash From 8fe88f23b7f30d3d1ec5a7f091333d567a0cb255 Mon Sep 17 00:00:00 2001 From: soulseen Date: Wed, 5 Jun 2019 21:55:59 +0800 Subject: [PATCH 14/24] update devops api doc Signed-off-by: soulseen --- pkg/models/devops/json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/devops/json.go b/pkg/models/devops/json.go index 8c14c3313..6c6c72bce 100644 --- a/pkg/models/devops/json.go +++ b/pkg/models/devops/json.go @@ -226,7 +226,7 @@ type BranchPipelineRunNodes struct { URLName string `json:"urlName,omitempty"` } `json:"actions,omitempty" description:"references the reachable path to this resource"` DisplayDescription interface{} `json:"displayDescription,omitempty" description:"display description"` - DisplayName string `json:"displayName,omitempty",description:"display name"` + DisplayName string `json:"displayName,omitempty" description:"display name"` DurationInMillis int `json:"durationInMillis,omitempty" description:"duration time in millis"` ID string `json:"id,omitempty" description:"id"` Input interface{} `json:"input,omitempty" description:"input"` From a9237a5c72d58d3b1c6577f1f9eae26c0cfe673b Mon Sep 17 00:00:00 2001 From: runzexia Date: Thu, 6 Jun 2019 17:59:17 +0800 Subject: [PATCH 15/24] update docs Signed-off-by: runzexia --- pkg/apis/devops/v1alpha2/register.go | 90 ++++++++++++------------- pkg/models/devops/json.go | 20 +++--- pkg/models/devops/membership.go | 2 +- pkg/models/devops/project.go | 2 +- pkg/models/devops/project_credential.go | 2 +- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index bfc2e3df8..d88be27a1 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -223,9 +223,9 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}"). To(devopsapi.GetPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get DevOps Pipelines."). + Doc("Get a Pipeline Inside a DevOps Project"). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Returns(http.StatusOK, RespOK, devops.Pipeline{}). Writes(devops.Pipeline{})) @@ -255,7 +255,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Search DevOps Pipelines runs in branch."). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). @@ -272,9 +272,9 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}"). To(devopsapi.GetBranchPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get DevOps Pipelines run in branch."). + Doc("Get all runs in a branch"). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.QueryParameter("start", "the count of item start."). @@ -287,8 +287,8 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes"). To(devopsapi.GetPipelineRunNodesbyBranch). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get node on DevOps Pipelines run."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Doc("Get MultiBranch Pipeline run nodes."). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -305,7 +305,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -322,7 +322,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). @@ -377,7 +377,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.StopBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Stop pipeline in running"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -397,7 +397,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.StopPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Stop pipeline in running"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep."). @@ -416,7 +416,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.ReplayBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -428,7 +428,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.ReplayPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.ReplayPipe{}). @@ -440,7 +440,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -455,7 +455,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.QueryParameter("start", "the count of item start."). @@ -468,7 +468,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -486,7 +486,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.QueryParameter("start", "the count of item start."). @@ -502,16 +502,16 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches"). To(devopsapi.GetPipeBranch). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get pipeline of branch."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Doc("Get MultiBranch pipeline branches."). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). - Param(webservice.QueryParameter("filter", "filter remote"). + Param(webservice.QueryParameter("filter", "filter remote scm. e.g. origin"). Required(true). DataFormat("filter=%s")). - Param(webservice.QueryParameter("start", "the count of item start."). + Param(webservice.QueryParameter("start", "the count of branches start."). Required(true). DataFormat("start=%d")). - Param(webservice.QueryParameter("limit", "the count of item limit."). + Param(webservice.QueryParameter("limit", "the count of branches limit."). Required(true). DataFormat("limit=%d")). Returns(http.StatusOK, RespOK, []devops.PipeBranch{}). @@ -524,7 +524,7 @@ func addWebService(c *restful.Container) error { Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build."). Reads(devops.CheckPlayload{}). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -538,7 +538,7 @@ func addWebService(c *restful.Container) error { Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build."). Reads(devops.CheckPlayload{}). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). @@ -550,7 +550,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get index console log."). Produces("text/plain; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment."))) // match /job/{projectName}/job/{pipelineName}/build?delay=0 @@ -559,7 +559,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Start a build."). Produces("text/html; charset=utf-8"). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.QueryParameter("delay", "will be delay time to scan."). Required(false). @@ -571,7 +571,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). @@ -583,7 +583,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). Writes(devops.QueuedBlueRun{})) @@ -593,7 +593,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchStepsStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline steps status."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -609,7 +609,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetStepsStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline steps status."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). @@ -623,7 +623,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/crumbissuer"). To(devopsapi.GetCrumb). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get crumb issuer."). + Doc("Get crumb issuer. A CrumbIssuer represents an algorithm to generate a nonce value, known as a crumb, to counter cross site request forgery exploits. Crumbs are typically hashes incorporating information that uniquely identifies an agent that sends a request, along with a guarded secret so that the crumb value cannot be forged by a third party."). Returns(http.StatusOK, RespOK, devops.Crumb{}). Writes(devops.Crumb{})) @@ -656,7 +656,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get run pipeline in project."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.PipelineRun{}). @@ -667,7 +667,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipeline run by branch."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach")). Returns(http.StatusOK, RespOK, devops.BranchPipeline{}). @@ -678,7 +678,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetPipelineRunNodes). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipeline run nodes."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")). Param(webservice.QueryParameter("limit", "the count of item limit"). @@ -692,7 +692,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get steps in node by branch."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -708,7 +708,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get steps in node."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")). Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). @@ -724,9 +724,9 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). Produces("application/json", "charset=utf-8"). - Doc("Convert json to jenkinsfile format."). + Doc("Convert json to jenkinsfile format. Usually the frontend uses json to edit jenkinsfile"). Reads(devops.ReqJson{}). - Returns(http.StatusOK, RespOK, devops.NodeSteps{}). + Returns(http.StatusOK, RespOK, devops.ResJenkinsfile{}). Writes(devops.ResJenkinsfile{})) // match /pipeline-model-converter/toJson @@ -735,7 +735,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). Produces("application/json", "charset=utf-8"). - Doc("Convert jenkinsfile to json format."). + Doc("Convert jenkinsfile to json format. Usually the frontend uses json to edit jenkinsfile"). Reads(devops.ReqJenkinsfile{}). Returns(http.StatusOK, RespOK, devops.ResJson{}). Writes(devops.ResJson{})) @@ -744,9 +744,9 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/devops/notifycommit"). To(devopsapi.GetNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get notify commit by GET HTTP method."). + Doc("Get notification commit by HTTP GET method."). Produces("text/plain; charset=utf-8"). - Param(webservice.QueryParameter("url", "the url for webhook to push."). + Param(webservice.QueryParameter("url", "url of git scm"). Required(true). DataFormat("url=%s"))) @@ -754,10 +754,10 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.POST("/devops/notifycommit"). To(devopsapi.GetNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get notify commit by POST HTTP method."). + Doc("Get notify commit by HTTP POST method."). Consumes("application/json"). Produces("text/plain; charset=utf-8"). - Param(webservice.QueryParameter("url", "the url for webhook to push."). + Param(webservice.QueryParameter("url", "url of git scm"). Required(true). DataFormat("url=%s"))) @@ -771,7 +771,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetBranchNodesDetail). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Gives steps details inside a pipeline node by branch. For a Stage, the steps will include all the steps defined inside the stage."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). @@ -786,7 +786,7 @@ func addWebService(c *restful.Container) error { To(devopsapi.GetNodesDetail). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Gives steps details inside a pipeline node. For a Stage, the steps will include all the steps defined inside the stage."). - Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")). + Param(webservice.PathParameter("projectName", "the name of devops project.")). Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")). Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")). diff --git a/pkg/models/devops/json.go b/pkg/models/devops/json.go index 6c6c72bce..0d351dc7c 100644 --- a/pkg/models/devops/json.go +++ b/pkg/models/devops/json.go @@ -247,17 +247,17 @@ type SCMOrg struct { Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."` Links struct { Repositories struct { - Class string `json:"_class,omitempty"` - Href string `json:"href,omitempty"` + Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."` + Href string `json:"href,omitempty" description:"url in api"` } `json:"repositories,omitempty"` Self struct { - Class string `json:"_class,omitempty"` - Href string `json:"href,omitempty"` - } `json:"self,omitempty"` + Class string `json:"_class,omitempty" description:"It’s a fully qualified name and is an identifier of the producer of this resource's capability."` + Href string `json:"href,omitempty" description:"self url in api"` + } `json:"self,omitempty" description:"scm org self info"` } `json:"_links,omitempty" description:"references the reachable path to this resource"` Avatar string `json:"avatar,omitempty" description:"avatar url"` JenkinsOrganizationPipeline bool `json:"jenkinsOrganizationPipeline,omitempty" description:"jenkins organization pipeline"` - Name string `json:"name,omitempty" description:"name "` + Name string `json:"name,omitempty" description:"org name "` } // GetOrgRepo @@ -733,10 +733,10 @@ type Crumb struct { // CheckScriptCompile type CheckScript struct { - Column int `json:"column,omitempty" description:"column"` - Line int `json:"line,omitempty" description:"line"` - Message string `json:"message,omitempty" description:"message"` - Status string `json:"status,omitempty" description:"statue"` + Column int `json:"column,omitempty" description:"column e.g. 0"` + Line int `json:"line,omitempty" description:"line e.g. 0"` + Message string `json:"message,omitempty" description:"message e.g. success"` + Status string `json:"status,omitempty" description:"status e.g. success"` } // CheckCron diff --git a/pkg/models/devops/membership.go b/pkg/models/devops/membership.go index 8f48a92d7..9e9234cd6 100644 --- a/pkg/models/devops/membership.go +++ b/pkg/models/devops/membership.go @@ -23,7 +23,7 @@ const ( type DevOpsProjectMembership struct { Username string `json:"username" description:"member's username,username can uniquely identify a user"` ProjectId string `json:"project_id" db:"project_id" description:"the devops projects which project membership belongs to"` - Role string `json:"role" description:"devops project membership's role type'"` + Role string `json:"role" description:"devops project membership's role type. e.g. owner '"` Status string `json:"status" description:"Desperated, status of project membership"` GrantBy string `json:"grand_by,omitempty" description:"Username of the user who assigned the role"` } diff --git a/pkg/models/devops/project.go b/pkg/models/devops/project.go index 222b2f01b..fb906a126 100644 --- a/pkg/models/devops/project.go +++ b/pkg/models/devops/project.go @@ -47,7 +47,7 @@ type DevOpsProject struct { CreateTime time.Time `json:"create_time" description:"DevOps Project's Creation time'"` - Status string `json:"status" description:"DevOps project's status"` + Status string `json:"status" description:"DevOps project's status. e.g. active"` Visibility string `json:"visibility,omitempty" description:"Desperated Field"` diff --git a/pkg/models/devops/project_credential.go b/pkg/models/devops/project_credential.go index f0a8663e3..6425e9780 100644 --- a/pkg/models/devops/project_credential.go +++ b/pkg/models/devops/project_credential.go @@ -43,7 +43,7 @@ type JenkinsCredential struct { } `json:"usage,omitempty" description:"all usage of credential"` } `json:"fingerprint,omitempty" description:"usage of credential"` Description string `json:"description,omitempty" description:"credential's description'"` - Domain string `json:"domain,omitempty" description:"credential's domain, default '_''"` + Domain string `json:"domain,omitempty" description:"credential's domain,In ks we only use the default domain, default '_''"` CreateTime *time.Time `json:"create_time,omitempty" description:"credential's create_time'"` Creator string `json:"creator,omitempty" description:"creator's username"` UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty" description:"username password credential struct"` From 468ef322d1fbda4ca3c00e72cf5e49a3ec658054 Mon Sep 17 00:00:00 2001 From: hongming Date: Thu, 6 Jun 2019 18:35:57 +0800 Subject: [PATCH 16/24] update api doc Signed-off-by: hongming --- pkg/apis/iam/v1alpha2/register.go | 102 +++++++++++++++++------ pkg/apis/operations/v1alpha2/register.go | 11 +-- pkg/apis/resources/v1alpha2/register.go | 49 ++++++----- pkg/apis/tenant/v1alpha2/register.go | 20 +++++ pkg/apiserver/iam/am.go | 4 +- pkg/apiserver/iam/auth.go | 16 ++-- pkg/errors/errors.go | 2 +- pkg/models/applications/applications.go | 38 ++++----- pkg/models/git/git.go | 4 +- pkg/models/registries/registries.go | 6 +- pkg/models/status/status.go | 14 ++-- pkg/models/types.go | 34 ++++---- 12 files changed, 190 insertions(+), 110 deletions(-) diff --git a/pkg/apis/iam/v1alpha2/register.go b/pkg/apis/iam/v1alpha2/register.go index bb3ff2460..c6f66ebe5 100644 --- a/pkg/apis/iam/v1alpha2/register.go +++ b/pkg/apis/iam/v1alpha2/register.go @@ -28,6 +28,7 @@ import ( "kubesphere.io/kubesphere/pkg/models" "kubesphere.io/kubesphere/pkg/models/iam/policy" "net/http" + "time" ) const GroupName = "iam.kubesphere.io" @@ -39,15 +40,74 @@ var ( AddToContainer = WebServiceBuilder.AddToContainer ) +type UserUpdateRequest struct { + Username string `json:"username" description:"username"` + Email string `json:"email" description:"email address"` + Lang string `json:"lang" description:"user's language setting, default is zh-CN"` + Description string `json:"description" description:"user's description"` + Password string `json:"password,omitempty" description:"this is necessary if you need to change your password"` + CurrentPassword string `json:"current_password,omitempty" description:"this is necessary if you need to change your password"` + ClusterRole string `json:"cluster_role" description:"user's cluster role"` +} + +type CreateUserRequest struct { + Username string `json:"username" description:"username"` + Email string `json:"email" description:"email address"` + Lang string `json:"lang,omitempty" description:"user's language setting, default is zh-CN"` + Description string `json:"description" description:"user's description"` + Password string `json:"password" description:"password'"` + ClusterRole string `json:"cluster_role" description:"user's cluster role"` +} + +type UserList struct { + Items []struct { + Username string `json:"username" description:"username"` + Email string `json:"email" description:"email address"` + Lang string `json:"lang,omitempty" description:"user's language setting, default is zh-CN"` + Description string `json:"description" description:"user's description"` + ClusterRole string `json:"cluster_role" description:"user's cluster role"` + CreateTime time.Time `json:"create_time" description:"user creation time"` + LastLoginTime time.Time `json:"last_login_time" description:"last login time"` + } `json:"items" description:"paging data"` + TotalCount int `json:"total_count" description:"total count"` +} + +type ClusterRoleList struct { + Items []rbacv1.ClusterRole `json:"items" description:"paging data"` + TotalCount int `json:"total_count" description:"total count"` +} + +type LoginLog struct { + LoginTime string `json:"login_time" description:"last login time"` + LoginIP string `json:"login_ip" description:"last login ip"` +} + +type RoleList struct { + Items []rbacv1.Role `json:"items" description:"paging data"` + TotalCount int `json:"total_count" description:"total count"` +} + +type InviteUserRequest struct { + Username string `json:"username" description:"username"` + WorkspaceRole string `json:"workspace_role" description:"user's workspace role'"` +} + +type DescribeWorkspaceUserResponse struct { + Username string `json:"username" description:"username"` + Email string `json:"email" description:"email address"` + Lang string `json:"lang" description:"user's language setting, default is zh-CN"` + Description string `json:"description" description:"user's description"` + ClusterRole string `json:"cluster_role" description:"user's cluster role"` + WorkspaceRole string `json:"workspace_role" description:"user's workspace role"` + CreateTime time.Time `json:"create_time" description:"user creation time"` + LastLoginTime time.Time `json:"last_login_time" description:"last login time"` +} + func addWebService(c *restful.Container) error { tags := []string{"IAM"} ws := runtime.NewWebService(GroupVersion) ok := "ok" - pageableUserList := struct { - Items []models.User `json:"items"` - TotalCount int `json:"total_count"` - }{} ws.Route(ws.POST("/authenticate"). To(iam.TokenReviewHandler). @@ -70,7 +130,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.POST("/users"). To(iam.CreateUser). Doc("Create a user account."). - Reads(models.User{}). + Reads(CreateUserRequest{}). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/users/{name}"). @@ -83,22 +143,19 @@ func addWebService(c *restful.Container) error { To(iam.UpdateUser). Doc("Updates information about the specified user."). Param(ws.PathParameter("name", "username")). - Reads(models.User{}). + Reads(UserUpdateRequest{}). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/users/{name}/log"). To(iam.UserLoginLog). Doc("This method is used to retrieve the \"login logs\" for the specified user."). Param(ws.PathParameter("name", "username")). - Returns(http.StatusOK, ok, struct { - LoginTime string `json:"login_time"` - LoginIP string `json:"login_ip"` - }{}). + Returns(http.StatusOK, ok, LoginLog{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/users"). To(iam.ListUsers). Doc("List all users."). - Returns(http.StatusOK, ok, pageableUserList). + Returns(http.StatusOK, ok, UserList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/groups"). To(iam.ListGroups). @@ -146,18 +203,12 @@ func addWebService(c *restful.Container) error { To(iam.ListRoles). Doc("This method is used to retrieve the roles that are assigned to the user in the specified namespace."). Param(ws.PathParameter("namespace", "kubernetes namespace")). - Returns(http.StatusOK, ok, struct { - Items []rbacv1.Role `json:"items"` - TotalCount int `json:"total_count"` - }{}). + Returns(http.StatusOK, ok, RoleList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/clusterroles"). To(iam.ListClusterRoles). Doc("List all cluster roles."). - Returns(http.StatusOK, ok, struct { - Items []rbacv1.ClusterRole `json:"items"` - TotalCount int `json:"total_count"` - }{}). + Returns(http.StatusOK, ok, ClusterRoleList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/users"). To(iam.ListRoleUsers). @@ -176,7 +227,7 @@ func addWebService(c *restful.Container) error { To(iam.ListClusterRoleUsers). Doc("List all users that are bind the cluster role."). Param(ws.PathParameter("clusterrole", "cluster role name")). - Returns(http.StatusOK, ok, pageableUserList). + Returns(http.StatusOK, ok, UserList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/clusterroles/{clusterrole}/rules"). To(iam.ListClusterRoleRules). @@ -212,10 +263,7 @@ func addWebService(c *restful.Container) error { To(iam.ListWorkspaceRoles). Doc("List all workspace roles."). Param(ws.PathParameter("workspace", "workspace name")). - Returns(http.StatusOK, ok, struct { - Items []rbacv1.ClusterRole `json:"items"` - TotalCount int `json:"total_count"` - }{}). + Returns(http.StatusOK, ok, ClusterRoleList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}"). To(iam.DescribeWorkspaceRole). @@ -235,13 +283,13 @@ func addWebService(c *restful.Container) error { To(iam.ListWorkspaceUsers). Doc("List all members in the specified workspace."). Param(ws.PathParameter("workspace", "workspace name")). - Returns(http.StatusOK, ok, pageableUserList). + Returns(http.StatusOK, ok, UserList{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.POST("/workspaces/{workspace}/members"). To(iam.InviteUser). Doc("Invite members to a workspace."). Param(ws.PathParameter("workspace", "workspace name")). - Reads(models.User{}). + Reads(InviteUserRequest{}). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/workspaces/{workspace}/members/{username}"). @@ -256,7 +304,7 @@ func addWebService(c *restful.Container) error { Doc("Describes the specified user."). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "username")). - Returns(http.StatusOK, ok, models.User{}). + Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags)) c.Add(ws) return nil diff --git a/pkg/apis/operations/v1alpha2/register.go b/pkg/apis/operations/v1alpha2/register.go index a42ddca9c..b3b23d755 100644 --- a/pkg/apis/operations/v1alpha2/register.go +++ b/pkg/apis/operations/v1alpha2/register.go @@ -24,6 +24,7 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/operations" "kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/errors" + "net/http" ) const GroupName = "operations.kubesphere.io" @@ -38,24 +39,24 @@ var ( func addWebService(c *restful.Container) error { tags := []string{"Operations"} - + ok := "ok" webservice := runtime.NewWebService(GroupVersion) webservice.Route(webservice.POST("/nodes/{node}/drainage"). To(operations.DrainNode). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc(""). + Doc("Drain node"). Param(webservice.PathParameter("node", "node name")). - Writes(errors.Error{})) + Returns(http.StatusOK, ok, errors.Error{})) webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}"). To(operations.RerunJob). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Handle job operation"). + Doc("Job rerun"). Param(webservice.PathParameter("job", "job name")). Param(webservice.PathParameter("namespace", "job's namespace")). Param(webservice.QueryParameter("a", "action")). - Writes("")) + Returns(http.StatusOK, ok, errors.Error{})) c.Add(webservice) diff --git a/pkg/apis/resources/v1alpha2/register.go b/pkg/apis/resources/v1alpha2/register.go index 0f0445917..58487eec0 100644 --- a/pkg/apis/resources/v1alpha2/register.go +++ b/pkg/apis/resources/v1alpha2/register.go @@ -36,8 +36,11 @@ import ( "kubesphere.io/kubesphere/pkg/models" "kubesphere.io/kubesphere/pkg/models/applications" gitmodel "kubesphere.io/kubesphere/pkg/models/git" + registriesmodel "kubesphere.io/kubesphere/pkg/models/registries" + "kubesphere.io/kubesphere/pkg/models/status" "kubesphere.io/kubesphere/pkg/params" "kubesphere.io/kubesphere/pkg/simple/client/openpitrix" + "net/http" ) const GroupName = "resources.kubesphere.io" @@ -54,6 +57,7 @@ func addWebService(c *restful.Container) error { webservice := runtime.NewWebService(GroupVersion) tags := []string{"Namespace resources"} + ok := "ok" webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}"). To(resources.ListResources). @@ -68,13 +72,13 @@ func addWebService(c *restful.Container) error { Required(false). DataFormat("limit=%d,page=%d"). DefaultValue("limit=10,page=1")). - Writes(models.PageableResponse{})) + Returns(http.StatusOK, ok, models.PageableResponse{})) tags = []string{"Cluster resources"} webservice.Route(webservice.GET("/{resources}"). To(resources.ListResources). - Writes(models.PageableResponse{}). + Returns(http.StatusOK, ok, models.PageableResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Cluster level resource query"). Param(webservice.PathParameter("resources", "cluster level resource type"))). @@ -91,7 +95,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/applications"). To(resources.ListApplication). - Writes(models.PageableResponse{}). + Returns(http.StatusOK, ok, models.PageableResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("List applications in cluster"). Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). @@ -107,7 +111,7 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/namespaces/{namespace}/applications"). To(resources.ListNamespacedApplication). - Writes(models.PageableResponse{}). + Returns(http.StatusOK, ok, models.PageableResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("List applications"). Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). @@ -122,24 +126,27 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{cluster_id}"). To(resources.DescribeApplication). - Writes(applications.Application{}). + Returns(http.StatusOK, ok, applications.Application{}). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Describe application"). Param(webservice.PathParameter("namespace", "namespace name")). - Param(webservice.PathParameter("cluster_id", "openpitrix cluster id"))) + Param(webservice.PathParameter("cluster_id", "application id"))) webservice.Route(webservice.POST("/namespaces/{namespace}/applications"). To(resources.DeployApplication). Doc("Deploy application"). Metadata(restfulspec.KeyOpenAPITags, tags). Reads(openpitrix.CreateClusterRequest{}). + Returns(http.StatusOK, ok, errors.Error{}). Param(webservice.PathParameter("namespace", "namespace name"))) webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{cluster_id}"). To(resources.DeleteApplication). Doc("Delete application"). Metadata(restfulspec.KeyOpenAPITags, tags). - Param(webservice.PathParameter("namespace", "namespace name"))) + Returns(http.StatusOK, ok, errors.Error{}). + Param(webservice.PathParameter("namespace", "namespace name")). + Param(webservice.PathParameter("cluster_id", "application id"))) tags = []string{"User resources"} @@ -148,13 +155,14 @@ func addWebService(c *restful.Container) error { Doc("get user's kubectl pod"). Param(webservice.PathParameter("username", "username")). Metadata(restfulspec.KeyOpenAPITags, tags). - Writes(models.PodInfo{})) + Returns(http.StatusOK, ok, models.PodInfo{})) webservice.Route(webservice.GET("/users/{username}/kubeconfig"). Produces("text/plain"). To(resources.GetKubeconfig). Doc("get users' kubeconfig"). Param(webservice.PathParameter("username", "username")). + Returns(http.StatusOK, ok, ""). Metadata(restfulspec.KeyOpenAPITags, tags)) tags = []string{"Components"} @@ -163,18 +171,18 @@ func addWebService(c *restful.Container) error { To(components.GetComponents). Metadata(restfulspec.KeyOpenAPITags, tags). Doc(""). - Writes(map[string]models.Component{})) + Returns(http.StatusOK, ok, map[string]models.Component{})) webservice.Route(webservice.GET("/components/{component}"). To(components.GetComponentStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc(""). Param(webservice.PathParameter("component", "component name")). - Writes(models.Component{})) + Returns(http.StatusOK, ok, models.Component{})) webservice.Route(webservice.GET("/health"). To(components.GetSystemHealthStatus). Metadata(restfulspec.KeyOpenAPITags, tags). Doc(""). - Writes(map[string]int{})) + Returns(http.StatusOK, ok, map[string]int{})) tags = []string{"Quotas"} @@ -182,13 +190,13 @@ func addWebService(c *restful.Container) error { To(quotas.GetClusterQuotas). Deprecate(). Doc("get whole cluster's resource usage"). - Writes(models.ResourceQuota{}). + Returns(http.StatusOK, ok, models.ResourceQuota{}). Metadata(restfulspec.KeyOpenAPITags, tags)) webservice.Route(webservice.GET("/namespaces/{namespace}/quotas"). Doc("get specified namespace's resource quota and usage"). Param(webservice.PathParameter("namespace", "namespace's name")). - Writes(models.ResourceQuota{}). + Returns(http.StatusOK, ok, models.ResourceQuota{}). Metadata(restfulspec.KeyOpenAPITags, tags). To(quotas.GetNamespaceQuotas)) @@ -198,7 +206,8 @@ func addWebService(c *restful.Container) error { To(registries.RegistryVerify). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("docker registry verify"). - Writes(errors.Error{})) + Reads(registriesmodel.AuthInfo{}). + Returns(http.StatusOK, ok, errors.Error{})) tags = []string{"Git"} webservice.Route(webservice.POST("/git/readverify"). @@ -207,7 +216,7 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("secret git read verify"). Reads(gitmodel.AuthInfo{}). - Writes(errors.Error{}), + Returns(http.StatusOK, ok, errors.Error{}), ) tags = []string{"Revision"} @@ -218,7 +227,7 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("daemonset", "daemonset's name")). Param(webservice.PathParameter("namespace", "daemonset's namespace")). Param(webservice.PathParameter("revision", "daemonset's revision")). - Writes(appsv1.DaemonSet{})) + Returns(http.StatusOK, ok, appsv1.DaemonSet{})) webservice.Route(webservice.GET("/namespaces/{namespace}/deployments/{deployment}/revisions/{revision}"). To(revisions.GetDeployRevision). Metadata(restfulspec.KeyOpenAPITags, tags). @@ -226,7 +235,7 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("deployment", "deployment's name")). Param(webservice.PathParameter("namespace", "deployment's namespace")). Param(webservice.PathParameter("revision", "deployment's revision")). - Writes(appsv1.ReplicaSet{})) + Returns(http.StatusOK, ok, appsv1.ReplicaSet{})) webservice.Route(webservice.GET("/namespaces/{namespace}/statefulsets/{statefulset}/revisions/{revision}"). To(revisions.GetStatefulSetRevision). Metadata(restfulspec.KeyOpenAPITags, tags). @@ -234,7 +243,7 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("statefulset", "statefulset's name")). Param(webservice.PathParameter("namespace", "statefulset's namespace")). Param(webservice.PathParameter("revision", "statefulset's revision")). - Writes(appsv1.StatefulSet{})) + Returns(http.StatusOK, ok, appsv1.StatefulSet{})) tags = []string{"Router"} @@ -242,7 +251,7 @@ func addWebService(c *restful.Container) error { To(routers.GetAllRouters). Doc("List all routers"). Metadata(restfulspec.KeyOpenAPITags, tags). - Writes(corev1.Service{})) + Returns(http.StatusOK, ok, corev1.Service{})) webservice.Route(webservice.GET("/namespaces/{namespace}/router"). To(routers.GetRouter). @@ -273,11 +282,13 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/workloadstatuses"). Doc("get abnormal workloads' count of whole cluster"). Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(http.StatusOK, ok, status.WorkLoadStatus{}). To(workloadstatuses.GetClusterResourceStatus)) webservice.Route(webservice.GET("/namespaces/{namespace}/workloadstatuses"). Doc("get abnormal workloads' count of specified namespace"). Param(webservice.PathParameter("namespace", "the name of namespace")). Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(http.StatusOK, ok, status.WorkLoadStatus{}). To(workloadstatuses.GetNamespacesResourceStatus)) c.Add(webservice) diff --git a/pkg/apis/tenant/v1alpha2/register.go b/pkg/apis/tenant/v1alpha2/register.go index 85684aff6..322f077f4 100644 --- a/pkg/apis/tenant/v1alpha2/register.go +++ b/pkg/apis/tenant/v1alpha2/register.go @@ -20,9 +20,15 @@ package v1alpha2 import ( "github.com/emicklei/go-restful" "github.com/emicklei/go-restful-openapi" + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" + "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1" "kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/tenant" + "kubesphere.io/kubesphere/pkg/errors" + "kubesphere.io/kubesphere/pkg/models" + "kubesphere.io/kubesphere/pkg/models/devops" + "net/http" ) const GroupName = "tenant.kubesphere.io" @@ -36,74 +42,88 @@ var ( func addWebService(c *restful.Container) error { tags := []string{"Tenant"} + ok := "ok" ws := runtime.NewWebService(GroupVersion) ws.Route(ws.GET("/workspaces"). To(tenant.ListWorkspaces). + Returns(http.StatusOK, ok, models.PageableResponse{}). Doc("List workspace by user"). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}"). To(tenant.DescribeWorkspace). Doc("Get workspace detail"). + Returns(http.StatusOK, ok, v1alpha1.Workspace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/rules"). To(tenant.ListWorkspaceRules). Param(ws.PathParameter("workspace", "workspace name")). Doc("List the rules for the current user"). + Returns(http.StatusOK, ok, models.SimpleRule{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/namespaces/{namespace}/rules"). To(tenant.ListNamespaceRules). Param(ws.PathParameter("namespace", "namespace")). Doc("List the rules for the current user"). + Returns(http.StatusOK, ok, models.SimpleRule{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/devops/{devops}/rules"). To(tenant.ListDevopsRules). Param(ws.PathParameter("devops", "devops project id")). Doc("List the rules for the current user"). + Returns(http.StatusOK, ok, models.SimpleRule{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/namespaces"). To(tenant.ListNamespaces). Param(ws.PathParameter("workspace", "workspace name")). Doc("List the namespaces for the current user"). + Returns(http.StatusOK, ok, []v1.Namespace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces"). To(tenant.ListNamespaces). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "workspace member's username")). Doc("List the namespaces for the workspace member"). + Returns(http.StatusOK, ok, []v1.Namespace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.POST("/workspaces/{workspace}/namespaces"). To(tenant.CreateNamespace). Param(ws.PathParameter("workspace", "workspace name")). Doc("Create namespace"). + Returns(http.StatusOK, ok, []v1.Namespace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/workspaces/{workspace}/namespaces/{namespace}"). To(tenant.DeleteNamespace). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("namespace", "namespace")). Doc("Delete namespace"). + Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/devops"). To(tenant.ListDevopsProjects). Param(ws.PathParameter("workspace", "workspace name")). Doc("List devops projects for the current user"). + Returns(http.StatusOK, ok, models.PageableResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). To(tenant.ListDevopsProjects). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "workspace member's username")). + Returns(http.StatusOK, ok, models.PageableResponse{}). Doc("List the devops projects for the workspace member"). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.POST("/workspaces/{workspace}/devops"). To(tenant.CreateDevopsProject). Param(ws.PathParameter("workspace", "workspace name")). Doc("Create devops project"). + Returns(http.StatusOK, ok, devops.DevOpsProject{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{id}"). To(tenant.DeleteDevopsProject). Param(ws.PathParameter("workspace", "workspace name")). Doc("Delete devops project"). + Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/logging"). To(tenant.LogQuery). diff --git a/pkg/apiserver/iam/am.go b/pkg/apiserver/iam/am.go index a86966593..51aa7b4b6 100644 --- a/pkg/apiserver/iam/am.go +++ b/pkg/apiserver/iam/am.go @@ -31,8 +31,8 @@ import ( ) type RoleList struct { - ClusterRoles []*v1.ClusterRole `json:"clusterRole" protobuf:"bytes,2,rep,name=clusterRoles"` - Roles []*v1.Role `json:"roles" protobuf:"bytes,2,rep,name=roles"` + ClusterRoles []*v1.ClusterRole `json:"clusterRole" description:"cluster role list"` + Roles []*v1.Role `json:"roles" description:"role list"` } func ListRoleUsers(req *restful.Request, resp *restful.Response) { diff --git a/pkg/apiserver/iam/auth.go b/pkg/apiserver/iam/auth.go index 2d463f173..49245654e 100644 --- a/pkg/apiserver/iam/auth.go +++ b/pkg/apiserver/iam/auth.go @@ -30,24 +30,24 @@ import ( ) type Spec struct { - Token string `json:"token"` + Token string `json:"token" description:"access token"` } type Status struct { - Authenticated bool `json:"authenticated"` - User map[string]interface{} `json:"user,omitempty"` + Authenticated bool `json:"authenticated" description:"is authenticated"` + User map[string]interface{} `json:"user,omitempty" description:"user info"` } type TokenReview struct { - APIVersion string `json:"apiVersion"` - Kind string `json:"kind"` + APIVersion string `json:"apiVersion" description:"Kubernetes API version"` + Kind string `json:"kind" description:"kind of the API object"` Spec *Spec `json:"spec,omitempty"` - Status *Status `json:"status,omitempty"` + Status *Status `json:"status,omitempty" description:"token review status"` } type LoginRequest struct { - Username string `json:"username"` - Password string `json:"password"` + Username string `json:"username" description:"username"` + Password string `json:"password" description:"password"` } const ( diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 75bab86a9..437bdfb62 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -25,7 +25,7 @@ import ( ) type Error struct { - Message string `json:"message"` + Message string `json:"message" description:"error message"` } var None = Error{Message: "success"} diff --git a/pkg/models/applications/applications.go b/pkg/models/applications/applications.go index dd215fc3b..c90a00cdf 100644 --- a/pkg/models/applications/applications.go +++ b/pkg/models/applications/applications.go @@ -38,28 +38,28 @@ import ( ) type Application struct { - Name string `json:"name"` - RepoName string `json:"repoName"` - Runtime string `json:"namespace"` - RuntimeId string `json:"runtime_id"` - Version string `json:"version"` - VersionId string `json:"version_id"` - Status string `json:"status"` - UpdateTime time.Time `json:"updateTime"` - CreateTime time.Time `json:"createTime"` - App string `json:"app"` - AppId string `json:"app_id"` - Description string `json:"description,omitempty"` - WorkLoads *workLoads `json:"workloads,omitempty"` - Services []v1.Service `json:"services,omitempty"` - Ingresses []v1beta1.Ingress `json:"ingresses,omitempty"` - ClusterID string `json:"cluster_id"` + Name string `json:"name" description:"application name"` + RepoName string `json:"repoName" description:"repo name"` + Runtime string `json:"namespace" description:"namespace"` + RuntimeId string `json:"runtime_id" description:"runtime id"` + Version string `json:"version" description:"application version"` + VersionId string `json:"version_id" description:"application version id"` + Status string `json:"status" description:"application status"` + UpdateTime time.Time `json:"updateTime" description:"update time"` + CreateTime time.Time `json:"createTime" description:"create name"` + App string `json:"app" description:"application template name"` + AppId string `json:"app_id" description:"application template id"` + Description string `json:"description,omitempty" description:"application description"` + WorkLoads *workLoads `json:"workloads,omitempty" description:"application workloads"` + Services []v1.Service `json:"services,omitempty" description:"application services"` + Ingresses []v1beta1.Ingress `json:"ingresses,omitempty" description:"application ingresses"` + ClusterID string `json:"cluster_id" description:"application id"` } type workLoads struct { - Deployments []appsv1.Deployment `json:"deployments,omitempty"` - Statefulsets []appsv1.StatefulSet `json:"statefulsets,omitempty"` - Daemonsets []appsv1.DaemonSet `json:"daemonsets,omitempty"` + Deployments []appsv1.Deployment `json:"deployments,omitempty" description:"deployment list"` + Statefulsets []appsv1.StatefulSet `json:"statefulsets,omitempty" description:"statefulset list"` + Daemonsets []appsv1.DaemonSet `json:"daemonsets,omitempty" description:"daemonset list"` } func ListApplication(runtimeId string, conditions *params.Conditions, limit, offset int) (*models.PageableResponse, error) { diff --git a/pkg/models/git/git.go b/pkg/models/git/git.go index 4abeddfec..c4f6a027c 100644 --- a/pkg/models/git/git.go +++ b/pkg/models/git/git.go @@ -11,8 +11,8 @@ import ( ) type AuthInfo struct { - RemoteUrl string `json:"remoteUrl"` - SecretRef *corev1.SecretReference `json:"secretRef,omitempty"` + RemoteUrl string `json:"remoteUrl" description:"git server url"` + SecretRef *corev1.SecretReference `json:"secretRef,omitempty" description:"auth secret reference"` } func GitReadVerify(namespace string, authInfo AuthInfo) error { diff --git a/pkg/models/registries/registries.go b/pkg/models/registries/registries.go index 4c31b7853..32df98fca 100644 --- a/pkg/models/registries/registries.go +++ b/pkg/models/registries/registries.go @@ -28,9 +28,9 @@ import ( ) type AuthInfo struct { - Username string `json:"username"` - Password string `json:"password"` - ServerHost string `json:"serverhost"` + Username string `json:"username" description:"username"` + Password string `json:"password" description:"password"` + ServerHost string `json:"serverhost" description:"registry server host"` } const loginSuccess = "Login Succeeded" diff --git a/pkg/models/status/status.go b/pkg/models/status/status.go index 9e90b68de..040f09499 100644 --- a/pkg/models/status/status.go +++ b/pkg/models/status/status.go @@ -26,14 +26,14 @@ import ( "kubesphere.io/kubesphere/pkg/models/resources" ) -type workLoadStatus struct { - Namespace string `json:"namespace"` - Count map[string]int `json:"data"` - Items map[string]interface{} `json:"items,omitempty"` +type WorkLoadStatus struct { + Namespace string `json:"namespace" description:"namespace"` + Count map[string]int `json:"data" description:"unhealthy workload count"` + Items map[string]interface{} `json:"items,omitempty" description:"unhealthy workloads"` } -func GetNamespacesResourceStatus(namespace string) (*workLoadStatus, error) { - res := workLoadStatus{Count: make(map[string]int), Namespace: namespace, Items: make(map[string]interface{})} +func GetNamespacesResourceStatus(namespace string) (*WorkLoadStatus, error) { + res := WorkLoadStatus{Count: make(map[string]int), Namespace: namespace, Items: make(map[string]interface{})} var notReadyList *models.PageableResponse var err error for _, resource := range []string{resources.Deployments, resources.StatefulSets, resources.DaemonSets, resources.PersistentVolumeClaims, resources.Jobs} { @@ -61,7 +61,7 @@ func GetNamespacesResourceStatus(namespace string) (*workLoadStatus, error) { return &res, nil } -func GetClusterResourceStatus() (*workLoadStatus, error) { +func GetClusterResourceStatus() (*WorkLoadStatus, error) { return GetNamespacesResourceStatus("") } diff --git a/pkg/models/types.go b/pkg/models/types.go index bc91ad533..378a8717f 100644 --- a/pkg/models/types.go +++ b/pkg/models/types.go @@ -25,8 +25,8 @@ import ( ) type PageableResponse struct { - Items []interface{} `json:"items"` - TotalCount int `json:"total_count"` + Items []interface{} `json:"items" description:"paging data"` + TotalCount int `json:"total_count" description:"total count"` } type Workspace struct { @@ -47,8 +47,8 @@ type Rule struct { } type SimpleRule struct { - Name string `json:"name"` - Actions []string `json:"actions"` + Name string `json:"name" description:"rule name"` + Actions []string `json:"actions" description:"actions"` } type User struct { @@ -82,26 +82,26 @@ type Group struct { } type Component struct { - Name string `json:"name"` - Namespace string `json:"namespace"` - SelfLink string `json:"selfLink"` - Label interface{} `json:"label"` - StartedAt time.Time `json:"startedAt"` - TotalBackends int `json:"totalBackends"` - HealthyBackends int `json:"healthyBackends"` + Name string `json:"name" description:"component name"` + Namespace string `json:"namespace" description:"namespace"` + SelfLink string `json:"selfLink" description:"self link"` + Label interface{} `json:"label" description:"labels"` + StartedAt time.Time `json:"startedAt" description:"started time"` + TotalBackends int `json:"totalBackends" description:"total backends"` + HealthyBackends int `json:"healthyBackends" description:"healthy backends"` } type PodInfo struct { - Namespace string `json:"namespace"` - Pod string `json:"pod"` - Container string `json:"container"` + Namespace string `json:"namespace" description:"namespace"` + Pod string `json:"pod" description:"pod name"` + Container string `json:"container" description:"container name"` } type Token struct { - Token string `json:"access_token"` + Token string `json:"access_token" description:"access token"` } type ResourceQuota struct { - Namespace string `json:"namespace"` - Data corev1.ResourceQuotaStatus `json:"data"` + Namespace string `json:"namespace" description:"namespace"` + Data corev1.ResourceQuotaStatus `json:"data" description:"resource quota status"` } From 2861865c09f4c15bb35ba20414f6a0c81d9d454b Mon Sep 17 00:00:00 2001 From: huanggze Date: Thu, 6 Jun 2019 19:28:52 +0800 Subject: [PATCH 17/24] doc: add monitoring and logging api doc Signed-off-by: huanggze --- pkg/apis/logging/v1alpha2/register.go | 253 +++++++------ pkg/apis/monitoring/v1alpha2/register.go | 350 +++++++++++------- pkg/models/log/types.go | 4 +- pkg/models/metrics/metrics.go | 14 +- pkg/simple/client/elasticsearch/esclient.go | 50 +-- .../client/fluentbit/fluentbitcrdclient.go | 16 +- 6 files changed, 392 insertions(+), 295 deletions(-) diff --git a/pkg/apis/logging/v1alpha2/register.go b/pkg/apis/logging/v1alpha2/register.go index 2247e7f76..c2cc8d637 100644 --- a/pkg/apis/logging/v1alpha2/register.go +++ b/pkg/apis/logging/v1alpha2/register.go @@ -24,9 +24,16 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/logging" "kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/filter" + "kubesphere.io/kubesphere/pkg/models/log" + esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" + fluentbitclient "kubesphere.io/kubesphere/pkg/simple/client/fluentbit" + "net/http" ) -const GroupName = "logging.kubesphere.io" +const ( + GroupName = "logging.kubesphere.io" + RespOK = "ok" +) var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"} @@ -41,174 +48,196 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/cluster").To(logging.LoggingQueryCluster). Filter(filter.Logging). - Doc("cluster level log query"). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("workspaces", "workspaces specify").DataType("string").Required(false)). - Param(ws.QueryParameter("workspace_query", "workspace query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)). - Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)). - Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)). - Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)). - Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against the cluster."). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("workspaces", "List of workspaces the query will perform against, eg. wk-one,wk-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workspace_query", "List of keywords for filtering workspaces. Workspaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)). + Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)). + Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/workspaces/{workspace}").To(logging.LoggingQueryWorkspace). Filter(filter.Logging). - Doc("workspace level log query"). - Param(ws.PathParameter("workspace", "workspace specify").DataType("string").Required(true)). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)). - Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)). - Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)). - Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)). - Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against a specific workspace."). + Param(ws.PathParameter("workspace", "Perform query against a specific workspace.").DataType("string").Required(true)). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)). + Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)). + Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}").To(logging.LoggingQueryNamespace). Filter(filter.Logging). - Doc("namespace level log query"). - Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)). - Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)). - Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)). - Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against a specific namespace."). + Param(ws.PathParameter("namespace", "Perform query against a specific namespace.").DataType("string").Required(true)). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)). + Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload}").To(logging.LoggingQueryWorkload). Filter(filter.Logging). - Doc("workload level log query"). - Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)). - Param(ws.PathParameter("workload", "workload specify").DataType("string").Required(true)). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)). - Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)). - Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against a specific workload."). + Param(ws.PathParameter("namespace", "Specify the namespace of the workload.").DataType("string").Required(true)). + Param(ws.PathParameter("workload", "Perform query against a specific workload.").DataType("string").Required(true)). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)). + Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(logging.LoggingQueryPod). Filter(filter.Logging). - Doc("pod level log query"). - Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)). - Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)). - Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against a specific pod."). + Param(ws.PathParameter("namespace", "Specify the namespace of the pod.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Perform query against a specific pod.").DataType("string").Required(true)). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(logging.LoggingQueryContainer). Filter(filter.Logging). - Doc("container level log query"). - Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)). - Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)). - Param(ws.PathParameter("container", "container specify").DataType("string").Required(true)). - Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)). - Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)). - Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)). - Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)). - Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)). - Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)). - Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)). - Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Log query against a specific container."). + Param(ws.PathParameter("namespace", "Specify the namespace of the pod.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the pod of the container.").DataType("string").Required(true)). + Param(ws.PathParameter("container", "Perform query against a specific container.").DataType("string").Required(true)). + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/fluentbit/filters").To(logging.LoggingQueryFluentbitFilters). Filter(filter.Logging). - Doc("log fluent-bit filters query"). + Doc("List all Fluent bit filter plugins. This API is work-in-process."). Metadata(restfulspec.KeyOpenAPITags, tags)). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.POST("/fluentbit/filters").To(logging.LoggingUpdateFluentbitFilters). Filter(filter.Logging). - Doc("log fluent-bit filters update"). + Doc("Add a new Fluent bit filter plugin. This API is work-in-process."). Metadata(restfulspec.KeyOpenAPITags, tags)). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/fluentbit/outputs").To(logging.LoggingQueryFluentbitOutputs). Filter(filter.Logging). - Doc("log fluent-bit outputs query"). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("List all Fluent bit output plugins."). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(log.FluentbitOutputsResult{}). + Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.POST("/fluentbit/outputs").To(logging.LoggingInsertFluentbitOutput). Filter(filter.Logging). - Doc("log fluent-bit outputs insert"). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Add a new Fluent bit output plugin."). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(fluentbitclient.OutputPlugin{}). + Writes(log.FluentbitOutputsResult{}). + Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.POST("/fluentbit/outputs/{output}").To(logging.LoggingUpdateFluentbitOutput). Filter(filter.Logging). - Doc("log fluent-bit outputs update"). - Param(ws.PathParameter("output", "output id").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Update a Fluent bit output plugin."). + Param(ws.PathParameter("output", "ID of the output to update.").DataType("string").Required(true)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(fluentbitclient.OutputPlugin{}). + Writes(log.FluentbitOutputsResult{}). + Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.DELETE("/fluentbit/outputs/{output}").To(logging.LoggingDeleteFluentbitOutput). Filter(filter.Logging). - Doc("log fluent-bit outputs delete"). - Param(ws.PathParameter("output", "output id").DataType("int").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Delete a Fluent bit output plugin."). + Param(ws.PathParameter("output", "ID of the output to delete.").DataType("string").Required(true)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(log.FluentbitOutputsResult{}). + Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) diff --git a/pkg/apis/monitoring/v1alpha2/register.go b/pkg/apis/monitoring/v1alpha2/register.go index 9862b4f5e..fb0eb0a3b 100644 --- a/pkg/apis/monitoring/v1alpha2/register.go +++ b/pkg/apis/monitoring/v1alpha2/register.go @@ -23,9 +23,14 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/apiserver/monitoring" "kubesphere.io/kubesphere/pkg/apiserver/runtime" + "kubesphere.io/kubesphere/pkg/models/metrics" + "net/http" ) -const GroupName = "monitoring.kubesphere.io" +const ( + GroupName = "monitoring.kubesphere.io" + RespOK = "ok" +) var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"} @@ -40,217 +45,280 @@ func addWebService(c *restful.Container) error { tags := []string{"Monitoring"} ws.Route(ws.GET("/cluster").To(monitoring.MonitorCluster). - Doc("monitor cluster level metrics"). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("cluster_cpu_utilisation")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get cluster-level metrics."). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. cluster_cpu|cluster_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/nodes").To(monitoring.MonitorNode). - Doc("monitor nodes level metrics"). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("node_cpu_utilisation")). - Param(ws.QueryParameter("resources_filter", "node re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get node-level metrics."). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Node filter in regexp pattern, eg. i-caojnter|i-cmu82ogj.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort nodes by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorNode). - Doc("monitor specific node level metrics"). - Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("node_cpu_utilisation")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific node metrics."). + Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces").To(monitoring.MonitorNamespace). - Doc("monitor namespaces level metrics"). - Param(ws.QueryParameter("resources_filter", "namespaces re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("namespace_memory_utilisation")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get namespace-level metrics."). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Namespace filter in regexp pattern, eg. namespace-1|namespace-2.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort namespaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorNamespace). - Doc("monitor specific namespace level metrics"). - Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("namespace_memory_utilisation")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific namespace metrics."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorPod). - Doc("monitor pods level metrics"). - Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("pod_memory_utilisation_wo_cache")). - Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get pod-level metrics of a given namespace."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Pods filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(monitoring.MonitorPod). - Doc("monitor specific pod level metrics"). - Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")). - Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific pod metrics."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorPod). - Doc("monitor pods level metrics by nodeid"). - Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("i-k89a62il")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("pod_memory_utilisation_wo_cache")). - Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get metrics of all pod on a specific node."). + Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Pod filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/nodes/{node}/pods/{pod}").To(monitoring.MonitorPod). - Doc("monitor specific pod level metrics by nodeid"). - Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("i-k89a62il")). - Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific pod metrics under a given namespace."). + Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/nodes/{node}/pods/{pod}/containers").To(monitoring.MonitorContainer). - Doc("monitor specific pod level metrics by nodeid"). - Param(ws.PathParameter("node", "specific node").DataType("string").Required(true)). - Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true)). - Param(ws.QueryParameter("resources_filter", "container re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get container-level metrics under a given node and pod."). + Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers").To(monitoring.MonitorContainer). - Doc("monitor containers level metrics"). - Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")). - Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("resources_filter", "container re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("container_memory_utilisation_wo_cache")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get container-level metrics under a given namespace and pod."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(monitoring.MonitorContainer). - Doc("monitor specific container level metrics"). - Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")). - Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")). - Param(ws.PathParameter("container", "specific container").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("container_memory_utilisation_wo_cache")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific container metrics under a given node and pod."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). + Param(ws.PathParameter("container", "Specify the target container.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)).Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) // Only use this api to monitor status of pods under the {workload} // To monitor a specific workload, try the next two apis with "resources_filter" ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}/{workload}").To(monitoring.MonitorWorkload). - Doc("monitor specific workload level metrics"). - Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")). - Param(ws.PathParameter("workload_kind", "workload kind").DataType("string").Required(true).DefaultValue("daemonset")). - Param(ws.PathParameter("workload", "workload name").DataType("string").Required(true).DefaultValue("")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)). - Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "max metric items in a page").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific workload metrics under a given namespace."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")). + Param(ws.PathParameter("workload", "Specify the target workload.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workload_cpu|workload_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}").To(monitoring.MonitorWorkload). - Doc("monitor specific workload kind level metrics"). - Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")). - Param(ws.PathParameter("workload_kind", "workload kind").DataType("string").Required(true).DefaultValue("daemonset")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)). - Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "max metric items in a page").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get workload-level metrics of specific workload kind."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorWorkload). - Doc("monitor all workload level metrics"). - Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)). - Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get workload-level metrics under a given namespace."). + Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workload_cpu|workload_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) // list all namespace in this workspace by selected metrics ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorOneWorkspace). - Doc("monitor workspaces level metrics"). - Param(ws.PathParameter("workspace", "workspace name").DataType("string").Required(true)). - Param(ws.QueryParameter("resources_filter", "namespaces filter").DataType("string").Required(false).DefaultValue("k.*")). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("namespace_memory_utilisation_wo_cache")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get specific workspace metrics."). + Param(ws.PathParameter("workspace", "Specify the target workspace.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workspace_cpu|workspace_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/workspaces").To(monitoring.MonitorAllWorkspaces). - Doc("monitor workspaces level metrics"). - Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("workspace_memory_utilisation")). - Param(ws.QueryParameter("resources_filter", "workspaces re2 expression filter").DataType("string").Required(false).DefaultValue(".*")). - Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)). - Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")). - Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get workspace-level metrics."). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workspace_cpu|workspace_memory.").DataType("string").Required(false)). + Param(ws.QueryParameter("resources_filter", "Workspace filter in regexp pattern, eg. workspace_1|workspace_2.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_metric", "Sort workspaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/components/{component}").To(monitoring.MonitorComponent). - Doc("monitor component level metrics"). - Param(ws.QueryParameter("metrics_filter", "metrics names in re2 regex").DataType("string").Required(false).DefaultValue("")). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Doc("Get service component-level metrics."). + Param(ws.PathParameter("component", "Specify the target component. One of etcd, apiserver, scheduler, controller_manager, coredns, prometheus.").DataType("string").Required(true)). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. etcd_server_list|coredns_proxy.").DataType("string").Required(false)). + Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). + Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(metrics.FormatedLevelMetric{}). + Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) diff --git a/pkg/models/log/types.go b/pkg/models/log/types.go index c2356d986..97a4779b3 100644 --- a/pkg/models/log/types.go +++ b/pkg/models/log/types.go @@ -48,6 +48,6 @@ type FluentbitFiltersResult struct { } type FluentbitOutputsResult struct { - Status int `json:"status"` - Outputs []fb.OutputPlugin `json:"outputs,omitempty"` + Status int `json:"status" description:"response status"` + Outputs []fb.OutputPlugin `json:"outputs,omitempty" description:"array of fluent bit output plugins"` } diff --git a/pkg/models/metrics/metrics.go b/pkg/models/metrics/metrics.go index 0537e93c7..79d03d016 100644 --- a/pkg/models/metrics/metrics.go +++ b/pkg/models/metrics/metrics.go @@ -47,19 +47,19 @@ const ( ) type FormatedLevelMetric struct { - MetricsLevel string `json:"metrics_level"` - Results []FormatedMetric `json:"results"` + MetricsLevel string `json:"metrics_level" description:"metrics level, eg. cluster"` + Results []FormatedMetric `json:"results" description:"actual array of results"` } type FormatedMetric struct { - MetricName string `json:"metric_name,omitempty"` - Status string `json:"status"` - Data FormatedMetricData `json:"data,omitempty"` + MetricName string `json:"metric_name,omitempty" description:"metrics name, eg. scheduler_up_sum"` + Status string `json:"status" description:"result status, one of error, success"` + Data FormatedMetricData `json:"data,omitempty" description:"actual metrics result"` } type FormatedMetricData struct { - Result []map[string]interface{} `json:"result"` - ResultType string `json:"resultType"` + Result []map[string]interface{} `json:"result" description:"result presenting metric labels, a series of time points and their instant values"` + ResultType string `json:"resultType" description:"result type, one of matrix, vector"` } type MetricResultValues []MetricResultValue diff --git a/pkg/simple/client/elasticsearch/esclient.go b/pkg/simple/client/elasticsearch/esclient.go index 0e44fbac5..0d8c7f58c 100644 --- a/pkg/simple/client/elasticsearch/esclient.go +++ b/pkg/simple/client/elasticsearch/esclient.go @@ -286,49 +286,49 @@ func createQueryRequest(param QueryParameters) (int, []byte, error) { } type Response struct { - Status int `json:"status"` - Workspace string `json:"workspace,omitempty"` - Shards Shards `json:"_shards"` - Hits Hits `json:"hits"` - Aggregations json.RawMessage `json:"aggregations"` + Status int `json:"status" description:"query status"` + Workspace string `json:"workspace,omitempty" description:"workspace the query was performed against"` + Shards Shards `json:"_shards" description:"tells shard information"` + Hits Hits `json:"hits" description:"search results"` + Aggregations json.RawMessage `json:"aggregations" description:"aggregation results"` } type Shards struct { - Total int64 `json:"total"` - Successful int64 `json:"successful"` - Skipped int64 `json:"skipped"` - Failed int64 `json:"failed"` + Total int64 `json:"total" description:"tells how many shards were searched"` + Successful int64 `json:"successful" description:"count of the successful searched shards"` + Skipped int64 `json:"skipped" description:"count of the skipped searched shards"` + Failed int64 `json:"failed" description:"count of the failed searched shards"` } type Hits struct { - Total int64 `json:"total"` - Hits []Hit `json:"hits"` + Total int64 `json:"total" description:"total number of documents matching our search criteria"` + Hits []Hit `json:"hits" description:"actual array of search results"` } type Hit struct { - Source Source `json:"_source"` - HighLight HighLight `json:"highlight"` - Sort []int64 `json:"sort"` + Source Source `json:"_source" description:"search result item"` + HighLight HighLight `json:"highlight" description:"highlighted log fragment"` + Sort []int64 `json:"sort" description:"sort key for results"` } type Source struct { - Log string `json:"log"` - Time string `json:"time"` - Kubernetes Kubernetes `json:"kubernetes"` + Log string `json:"log" description:"the log message"` + Time string `json:"time" description:"log timestamp"` + Kubernetes Kubernetes `json:"kubernetes" description:"kubernetes addon information on the log"` } type Kubernetes struct { - Namespace string `json:"namespace_name"` - Pod string `json:"pod_name"` - Container string `json:"container_name"` - Host string `json:"host"` + Namespace string `json:"namespace_name" description:"the namespace the log is from"` + Pod string `json:"pod_name" description:"the pod the log is from"` + Container string `json:"container_name" description:"the container the log is from"` + Host string `json:"host" description:"the node the log if from"` } type HighLight struct { - LogHighLights []string `json:"log,omitempty"` - NamespaceHighLights []string `json:"kubernetes.namespace_name.keyword,omitempty"` - PodHighLights []string `json:"kubernetes.pod_name.keyword,omitempty"` - ContainerHighLights []string `json:"kubernetes.container_name.keyword,omitempty"` + LogHighLights []string `json:"log,omitempty" description:"log messages to highlight"` + NamespaceHighLights []string `json:"kubernetes.namespace_name.keyword,omitempty" description:"namespaces to highlight"` + PodHighLights []string `json:"kubernetes.pod_name.keyword,omitempty" description:"pods to highlight"` + ContainerHighLights []string `json:"kubernetes.container_name.keyword,omitempty" description:"containers to highlight"` } type LogRecord struct { diff --git a/pkg/simple/client/fluentbit/fluentbitcrdclient.go b/pkg/simple/client/fluentbit/fluentbitcrdclient.go index 86cc6aa41..e914bc757 100644 --- a/pkg/simple/client/fluentbit/fluentbitcrdclient.go +++ b/pkg/simple/client/fluentbit/fluentbitcrdclient.go @@ -64,24 +64,24 @@ type FluentBitStatus struct { // Plugin struct for fluent-bit plugins type Plugin struct { - Type string `json:"type"` - Name string `json:"name"` - Parameters []Parameter `json:"parameters"` + Type string `json:"type" description:"output plugin type, eg. fluentbit-output-es"` + Name string `json:"name" description:"output plugin name, eg. fluentbit-output-es"` + Parameters []Parameter `json:"parameters" description:"output plugin configuration parameters"` } // Fluent-bit output plugins type OutputPlugin struct { Plugin - Id string `json:"id"` - Enable bool `json:"enable"` - Updatetime time.Time `json:"updatetime,omitempty"` + Id string `json:"id,omitempty" description:"output plugin uuid"` + Enable bool `json:"enable" description:"current output plugin status, one of true, false"` + Updatetime time.Time `json:"updatetime,omitempty" description:"last updatetime of the output plugin"` } // Parameter generic parameter type to handle values from different sources type Parameter struct { - Name string `json:"name"` + Name string `json:"name" description:"configuration parameter key, eg. Name. refer to fluent bit official doc for more information."` ValueFrom *ValueFrom `json:"valueFrom,omitempty"` - Value string `json:"value"` + Value string `json:"value" description:"configuration parameter value, eg. es. refer to fluent bit official doc for more information."` } // ValueFrom generic type to determine value origin From a4d25f15dd8c9bfddc9f09107c169e99b3835d3b Mon Sep 17 00:00:00 2001 From: runzexia Date: Mon, 10 Jun 2019 10:26:18 +0800 Subject: [PATCH 18/24] update api docs --- pkg/apis/devops/v1alpha2/register.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index d88be27a1..f864ada2e 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -237,7 +237,7 @@ func addWebService(c *restful.Container) error { Param(webservice.QueryParameter("q", "query pipelines, condition for filtering."). Required(false). DataFormat("q=%s")). - Param(webservice.QueryParameter("filter", "Condition for filteringfilter folders or not.."). + Param(webservice.QueryParameter("filter", "Filter some types of jobs. e.g. no-folder,will not get a job of type folder"). Required(false). DataFormat("filter=%s")). Param(webservice.QueryParameter("start", "the count of item start."). From 2878ff052fc73ec5bd226e69d1d261b9388c5088 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 10 Jun 2019 10:16:22 +0800 Subject: [PATCH 19/24] update servicemesh api doc Signed-off-by: Jeff --- .../servicemesh/metrics/v1alpha2/register.go | 143 ++++++++++-------- .../metrics/v1alpha2/swagger-doc.go | 54 +++++++ 2 files changed, 137 insertions(+), 60 deletions(-) create mode 100644 pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go diff --git a/pkg/apis/servicemesh/metrics/v1alpha2/register.go b/pkg/apis/servicemesh/metrics/v1alpha2/register.go index 0990ee9be..6c1b27b3e 100644 --- a/pkg/apis/servicemesh/metrics/v1alpha2/register.go +++ b/pkg/apis/servicemesh/metrics/v1alpha2/register.go @@ -7,7 +7,7 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/servicemesh/metrics" "kubesphere.io/kubesphere/pkg/apiserver/servicemesh/tracing" - "kubesphere.io/kubesphere/pkg/errors" + "net/http" ) const GroupName = "servicemesh.kubesphere.io" @@ -30,19 +30,21 @@ func addWebService(c *restful.Container) error { webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/metrics"). To(metrics.GetServiceMetrics). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get app metrics from a specific namespace"). + Doc("Get service metrics from a specific namespace"). Param(webservice.PathParameter("namespace", "name of the namespace")). Param(webservice.PathParameter("service", "name of the service")). - Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). + Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). - Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). - Param(webservice.QueryParameter("step", "metrics step")). - Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")). - Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")). - Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")). - Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")). - Param(webservice.QueryParameter("reporter", "destination")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")). + Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")). + Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")). + Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")). + Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")). + Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")). + Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")). + Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")). + Returns(http.StatusOK, "ok", MetricsResponse{}). + Writes(MetricsResponse{})).Produces(restful.MIME_JSON) // Get app metrics // Get /namespaces/{namespace}/apps/{app}/metrics @@ -51,17 +53,20 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get app metrics from a specific namespace"). Param(webservice.PathParameter("namespace", "name of the namespace")). - Param(webservice.PathParameter("app", "name of the workload label app value")). - Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). + Param(webservice.PathParameter("app", "name of the app")). + Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). - Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). - Param(webservice.QueryParameter("step", "metrics step")). - Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")). - Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")). - Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")). - Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")). - Param(webservice.QueryParameter("reporter", "destination")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")). + Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")). + Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")). + Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")). + Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")). + Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")). + Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")). + Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")). + Returns(http.StatusOK, "ok", MetricsResponse{}). + Writes(MetricsResponse{})). + Produces(restful.MIME_JSON) // Get workload metrics // Get /namespaces/{namespace}/workloads/{workload}/metrics @@ -71,16 +76,20 @@ func addWebService(c *restful.Container) error { Doc("Get workload metrics from a specific namespace"). Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)). Param(webservice.PathParameter("workload", "name of the workload").Required(true)). - Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). + Param(webservice.PathParameter("service", "name of the service")). + Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). - Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). - Param(webservice.QueryParameter("step", "metrics step")). - Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")). - Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")). - Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")). - Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")). - Param(webservice.QueryParameter("reporter", "destination")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")). + Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")). + Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")). + Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")). + Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")). + Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")). + Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")). + Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")). + Returns(http.StatusOK, "ok", MetricsResponse{}). + Writes(MetricsResponse{})). + Produces(restful.MIME_JSON) // Get namespace metrics // Get /namespaces/{namespace}/metrics @@ -89,16 +98,19 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get workload metrics from a specific namespace"). Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)). - Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")). + Param(webservice.PathParameter("service", "name of the service")). + Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")). Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")). - Param(webservice.QueryParameter("duration", "metrics duration, in seconds")). - Param(webservice.QueryParameter("step", "metrics step")). - Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")). - Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")). - Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")). - Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")). - Param(webservice.QueryParameter("reporter", "destination")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")). + Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")). + Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")). + Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")). + Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")). + Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")). + Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")). + Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")). + Returns(http.StatusOK, "ok", MetricsResponse{}). + Writes(MetricsResponse{})).Produces(restful.MIME_JSON) // Get namespace graph // Get /namespaces/{namespace}/graph @@ -107,25 +119,31 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get service graph for a specific namespace"). Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)). - Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")). - Param(webservice.QueryParameter("groupBy", "group nodes by kind")). - Param(webservice.QueryParameter("queryTime", "from which time point, default now")). - Param(webservice.QueryParameter("injectServiceNodes", "whether to inject service ndoes")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("10m")). + Param(webservice.QueryParameter("graphType", "type of the generated service graph. Available graph types: [app, service, versionedApp, workload].").DefaultValue("workload")). + Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")). + Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")). + Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")). + Returns(http.StatusBadRequest, "bad request", BadRequestError{}). + Returns(http.StatusNotFound, "not found", NotFoundError{}). + Returns(http.StatusOK, "ok", GraphResponse{}). + Writes(GraphResponse{})).Produces(restful.MIME_JSON) // Get namespaces graph, for multiple namespaces // Get /namespaces/graph - webservice.Route(webservice.GET("/namespaces/{namespace}/graph"). + webservice.Route(webservice.GET("/namespaces/graph"). To(metrics.GetNamespacesGraph). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get service graph for a specific namespace"). - Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)). - Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")). - Param(webservice.QueryParameter("groupBy", "group nodes by kind")). - Param(webservice.QueryParameter("queryTime", "from which time point, default now")). - Param(webservice.QueryParameter("injectServiceNodes", "whether to inject service ndoes")). - Param(webservice.QueryParameter("namespaces", "names of namespaces")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Doc("Get graph from all namespaces"). + Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("10m")). + Param(webservice.QueryParameter("graphType", "type of the generated service graph. Available graph types: [app, service, versionedApp, workload].").DefaultValue("workload")). + Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")). + Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")). + Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")). + Returns(http.StatusBadRequest, "bad request", BadRequestError{}). + Returns(http.StatusNotFound, "not found", NotFoundError{}). + Returns(http.StatusOK, "ok", GraphResponse{}). + Writes(GraphResponse{})).Produces(restful.MIME_JSON) // Get namespace health webservice.Route(webservice.GET("/namespaces/{namespace}/health"). @@ -136,7 +154,10 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("type", "the type of health, app/service/workload, default app").DefaultValue("app")). Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)). Param(webservice.QueryParameter("queryTime", "the time to use for query")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Returns(http.StatusBadRequest, "bad request", BadRequestError{}). + Returns(http.StatusNotFound, "not found", NotFoundError{}). + Returns(http.StatusOK, "ok", namespaceAppHealthResponse{}). + Writes(namespaceAppHealthResponse{})).Produces(restful.MIME_JSON) // Get workloads health webservice.Route(webservice.GET("/namespaces/{namespace}/workloads/{workload}/health"). @@ -147,7 +168,8 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("workload", "workload name").Required(true)). Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)). Param(webservice.QueryParameter("queryTime", "the time to use for query")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + ReturnsError(http.StatusOK, "ok", workloadHealthResponse{}). + Writes(workloadHealthResponse{})).Produces(restful.MIME_JSON) // Get app health webservice.Route(webservice.GET("/namespaces/{namespace}/apps/{app}/health"). @@ -158,7 +180,8 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("app", "app name").Required(true)). Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)). Param(webservice.QueryParameter("queryTime", "the time to use for query")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Returns(http.StatusOK, "ok", appHealthResponse{}). + Writes(appHealthResponse{})).Produces(restful.MIME_JSON) // Get service health webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/health"). @@ -169,7 +192,8 @@ func addWebService(c *restful.Container) error { Param(webservice.PathParameter("service", "service name").Required(true)). Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)). Param(webservice.QueryParameter("queryTime", "the time to use for query")). - Writes(errors.Error{})).Produces(restful.MIME_JSON) + Returns(http.StatusOK, "ok", serviceHealthResponse{}). + Writes(serviceHealthResponse{})).Produces(restful.MIME_JSON) // Get service tracing webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/traces"). @@ -182,9 +206,8 @@ func addWebService(c *restful.Container) error { Param(webservice.QueryParameter("end", "end of time range want to query, in unix timestamp")). Param(webservice.QueryParameter("limit", "maximum tracing entries returned at one query, default 10").DefaultValue("10")). Param(webservice.QueryParameter("loopback", "loopback of duration want to query, e.g. 30m/1h/2d")). - Param(webservice.QueryParameter("maxDuration", "maximum duration of tracing")). - Param(webservice.QueryParameter("minDuration", "minimum duration of tracing")). - Writes(errors.Error{}). + Param(webservice.QueryParameter("maxDuration", "maximum duration of a request")). + Param(webservice.QueryParameter("minDuration", "minimum duration of a request")). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON)) diff --git a/pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go b/pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go new file mode 100644 index 000000000..e8d3294d4 --- /dev/null +++ b/pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go @@ -0,0 +1,54 @@ +package v1alpha2 + +import ( + "github.com/kiali/kiali/graph/cytoscape" + "github.com/kiali/kiali/models" + "github.com/kiali/kiali/prometheus" +) + +///////////////////// +// SWAGGER RESPONSES +///////////////////// + +// NoContent: the response is empty +type NoContent struct { + Status int32 `json:"status"` + Reason error `json:"reason"` +} + +// BadRequestError: the client request is incorrect +type BadRequestError struct { + Status int32 `json:"status"` + Reason error `json:"reason"` +} + +// NotFoundError is the error message that is generated when server could not find +// what was requested +type NotFoundError struct { + Status int32 `json:"status"` + Reason error `json:"reason"` +} + +type GraphResponse struct { + cytoscape.Config +} + +type serviceHealthResponse struct { + models.ServiceHealth +} + +type namespaceAppHealthResponse struct { + models.NamespaceAppHealth +} + +type workloadHealthResponse struct { + models.WorkloadHealth +} + +type appHealthResponse struct { + models.AppHealth +} + +type MetricsResponse struct { + prometheus.Metrics +} From 3e2693739dcc557288c125897792920ff29669d0 Mon Sep 17 00:00:00 2001 From: huanggze Date: Mon, 10 Jun 2019 13:29:39 +0800 Subject: [PATCH 20/24] doc: fix swagger import errors caused by duplicate operationId and non-allowed data type values Signed-off-by: huanggze --- pkg/apis/logging/v1alpha2/register.go | 24 ++++----- pkg/apis/monitoring/v1alpha2/register.go | 66 ++++++++++++------------ pkg/apis/tenant/v1alpha2/register.go | 27 ++++++++-- pkg/apiserver/monitoring/monitoring.go | 58 ++++++++++++++++++++- 4 files changed, 126 insertions(+), 49 deletions(-) diff --git a/pkg/apis/logging/v1alpha2/register.go b/pkg/apis/logging/v1alpha2/register.go index c2cc8d637..6f5811af2 100644 --- a/pkg/apis/logging/v1alpha2/register.go +++ b/pkg/apis/logging/v1alpha2/register.go @@ -65,8 +65,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). @@ -91,8 +91,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). @@ -115,8 +115,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). @@ -138,8 +138,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). @@ -159,8 +159,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). @@ -179,8 +179,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). - Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("int").DefaultValue("0").Required(false)). - Param(ws.QueryParameter("size", "Size of result to return.").DataType("int").DefaultValue("10").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). diff --git a/pkg/apis/monitoring/v1alpha2/register.go b/pkg/apis/monitoring/v1alpha2/register.go index fb0eb0a3b..642660bc9 100644 --- a/pkg/apis/monitoring/v1alpha2/register.go +++ b/pkg/apis/monitoring/v1alpha2/register.go @@ -57,14 +57,14 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/nodes").To(monitoring.MonitorNode). + ws.Route(ws.GET("/nodes").To(monitoring.MonitorAllNodes). Doc("Get node-level metrics."). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "Node filter in regexp pattern, eg. i-caojnter|i-cmu82ogj.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort nodes by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -72,7 +72,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorNode). + ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorSpecificNode). Doc("Get specific node metrics."). Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). @@ -86,14 +86,14 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces").To(monitoring.MonitorNamespace). + ws.Route(ws.GET("/namespaces").To(monitoring.MonitorAllNamespaces). Doc("Get namespace-level metrics."). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "Namespace filter in regexp pattern, eg. namespace-1|namespace-2.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort namespaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -101,7 +101,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorNamespace). + ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorSpecificNamespace). Doc("Get specific namespace metrics."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)). @@ -115,15 +115,15 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorPod). + ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorAllPodsOfSpecificNamespace). Doc("Get pod-level metrics of a given namespace."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "Pods filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -131,7 +131,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(monitoring.MonitorPod). + ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(monitoring.MonitorSpecificPodOfSpecificNamespace). Doc("Get specific pod metrics."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). @@ -146,15 +146,15 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorPod). + ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorAllPodsOnSpecificNode). Doc("Get metrics of all pod on a specific node."). Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "Pod filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -162,7 +162,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/nodes/{node}/pods/{pod}").To(monitoring.MonitorPod). + ws.Route(ws.GET("/nodes/{node}/pods/{pod}").To(monitoring.MonitorSpecificPodOnSpecificNode). Doc("Get specific pod metrics under a given namespace."). Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). @@ -177,7 +177,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/nodes/{node}/pods/{pod}/containers").To(monitoring.MonitorContainer). + ws.Route(ws.GET("/nodes/{node}/pods/{pod}/containers").To(monitoring.MonitorAllContainersOnSpecificNode). Doc("Get container-level metrics under a given node and pod."). Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). @@ -185,8 +185,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -194,7 +194,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers").To(monitoring.MonitorContainer). + ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers").To(monitoring.MonitorAllContainersOfSpecificNamespace). Doc("Get container-level metrics under a given namespace and pod."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). @@ -202,8 +202,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -211,7 +211,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(monitoring.MonitorContainer). + ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(monitoring.MonitorSpecificContainerOfSpecificNamespace). Doc("Get specific container metrics under a given node and pod."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). @@ -229,7 +229,7 @@ func addWebService(c *restful.Container) error { // Only use this api to monitor status of pods under the {workload} // To monitor a specific workload, try the next two apis with "resources_filter" - ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}/{workload}").To(monitoring.MonitorWorkload). + ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}/{workload}").To(monitoring.MonitorSpecificWorkload). Doc("Get specific workload metrics under a given namespace."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")). @@ -245,7 +245,7 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}").To(monitoring.MonitorWorkload). + ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}").To(monitoring.MonitorAllWorkloadsOfSpecificKind). Doc("Get workload-level metrics of specific workload kind."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")). @@ -253,8 +253,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -262,15 +262,15 @@ func addWebService(c *restful.Container) error { Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) - ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorWorkload). + ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorAllWorkloadsOfSpecificNamespace). Doc("Get workload-level metrics under a given namespace."). Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workload_cpu|workload_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). @@ -279,7 +279,7 @@ func addWebService(c *restful.Container) error { Produces(restful.MIME_JSON) // list all namespace in this workspace by selected metrics - ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorOneWorkspace). + ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorSpecificWorkspace). Doc("Get specific workspace metrics."). Param(ws.PathParameter("workspace", "Specify the target workspace.").DataType("string").Required(true)). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workspace_cpu|workspace_memory.").DataType("string").Required(false)). @@ -299,8 +299,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("resources_filter", "Workspace filter in regexp pattern, eg. workspace_1|workspace_2.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_metric", "Sort workspaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)). Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). - Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("int").Required(false).DefaultValue("1")). - Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("int").Required(false).DefaultValue("5")). + Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). + Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). Metadata(restfulspec.KeyOpenAPITags, tags). Writes(metrics.FormatedLevelMetric{}). diff --git a/pkg/apis/tenant/v1alpha2/register.go b/pkg/apis/tenant/v1alpha2/register.go index cf30bb3d3..c7d4a7aa3 100644 --- a/pkg/apis/tenant/v1alpha2/register.go +++ b/pkg/apis/tenant/v1alpha2/register.go @@ -27,11 +27,11 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/tenant" "kubesphere.io/kubesphere/pkg/models/devops" "kubesphere.io/kubesphere/pkg/params" + esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" "kubesphere.io/kubesphere/pkg/errors" "kubesphere.io/kubesphere/pkg/models" - "net/http" ) @@ -118,7 +118,6 @@ func addWebService(c *restful.Container) error { Required(false). DataFormat("key=%s,key~%s")). Doc("List devops projects for the current user"). - Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). To(tenant.ListDevopsProjects). @@ -151,7 +150,29 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/logging"). To(tenant.LogQuery). Doc("Query cluster-level logs in a multi-tenants environment"). - Metadata(restfulspec.KeyOpenAPITags, tags)) + Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)). + Param(ws.QueryParameter("workspaces", "List of workspaces the query will perform against, eg. wk-one,wk-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workspace_query", "List of keywords for filtering workspaces. Workspaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)). + Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)). + Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)). + Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)). + Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)). + Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)). + Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)). + Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").Required(false)). + Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). + Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). + Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(esclient.Response{}). + Returns(http.StatusOK, RespOK, esclient.Response{})). + Consumes(restful.MIME_JSON, restful.MIME_XML). + Produces(restful.MIME_JSON) c.Add(ws) return nil diff --git a/pkg/apiserver/monitoring/monitoring.go b/pkg/apiserver/monitoring/monitoring.go index 5b6f5c8a3..3612fc40f 100644 --- a/pkg/apiserver/monitoring/monitoring.go +++ b/pkg/apiserver/monitoring/monitoring.go @@ -23,6 +23,22 @@ import ( "kubesphere.io/kubesphere/pkg/simple/client/prometheus" ) +func MonitorAllPodsOfSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorPod(request, response) +} + +func MonitorSpecificPodOfSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorPod(request, response) +} + +func MonitorAllPodsOnSpecificNode(request *restful.Request, response *restful.Response) { + MonitorPod(request, response) +} + +func MonitorSpecificPodOnSpecificNode(request *restful.Request, response *restful.Response) { + MonitorPod(request, response) +} + func MonitorPod(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) podName := requestParams.PodName @@ -48,6 +64,18 @@ func MonitorPod(request *restful.Request, response *restful.Response) { } } +func MonitorAllContainersOnSpecificNode(request *restful.Request, response *restful.Response) { + MonitorContainer(request, response) +} + +func MonitorAllContainersOfSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorContainer(request, response) +} + +func MonitorSpecificContainerOfSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorContainer(request, response) +} + func MonitorContainer(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) metricName := requestParams.MetricsName @@ -67,6 +95,18 @@ func MonitorContainer(request *restful.Request, response *restful.Response) { } +func MonitorSpecificWorkload(request *restful.Request, response *restful.Response) { + MonitorWorkload(request, response) +} + +func MonitorAllWorkloadsOfSpecificKind(request *restful.Request, response *restful.Response) { + MonitorWorkload(request, response) +} + +func MonitorAllWorkloadsOfSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorWorkload(request, response) +} + func MonitorWorkload(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) @@ -108,7 +148,7 @@ func MonitorAllWorkspaces(request *restful.Request, response *restful.Response) } } -func MonitorOneWorkspace(request *restful.Request, response *restful.Response) { +func MonitorSpecificWorkspace(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) tp := requestParams.Tp @@ -135,6 +175,14 @@ func MonitorOneWorkspace(request *restful.Request, response *restful.Response) { } } +func MonitorAllNamespaces(request *restful.Request, response *restful.Response) { + MonitorNamespace(request, response) +} + +func MonitorSpecificNamespace(request *restful.Request, response *restful.Response) { + MonitorNamespace(request, response) +} + func MonitorNamespace(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) // multiple @@ -165,6 +213,14 @@ func MonitorCluster(request *restful.Request, response *restful.Response) { } } +func MonitorAllNodes(request *restful.Request, response *restful.Response) { + MonitorNode(request, response) +} + +func MonitorSpecificNode(request *restful.Request, response *restful.Response) { + MonitorNode(request, response) +} + func MonitorNode(request *restful.Request, response *restful.Response) { requestParams := prometheus.ParseMonitoringRequestParams(request) From e86b2a4dcc474a211d9371d864f63544b1d16c72 Mon Sep 17 00:00:00 2001 From: runzexia Date: Mon, 10 Jun 2019 11:47:30 +0800 Subject: [PATCH 21/24] fix devops api import error Signed-off-by: runzexia --- pkg/apis/devops/v1alpha2/register.go | 8 ++++---- pkg/apiserver/devops/devops.go | 8 ++++++++ tools/cmd/doc-gen/main.go | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index f864ada2e..665b67269 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -220,12 +220,12 @@ func addWebService(c *restful.Container) error { Reads([]devops.JenkinsCredential{})) // match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}"). To(devopsapi.GetPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get a Pipeline Inside a DevOps Project"). - Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). - Param(webservice.PathParameter("projectName", "the name of devops project.")). + Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("devops", "the name of devops project.")). Returns(http.StatusOK, RespOK, devops.Pipeline{}). Writes(devops.Pipeline{})) @@ -752,7 +752,7 @@ func addWebService(c *restful.Container) error { // Gitlab or some other scm managers can only use HTTP method. match /git/notifyCommit/?url= webservice.Route(webservice.POST("/devops/notifycommit"). - To(devopsapi.GetNotifyCommit). + To(devopsapi.PostNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get notify commit by HTTP POST method."). Consumes("application/json"). diff --git a/pkg/apiserver/devops/devops.go b/pkg/apiserver/devops/devops.go index 275635b4f..f4f8bc268 100644 --- a/pkg/apiserver/devops/devops.go +++ b/pkg/apiserver/devops/devops.go @@ -585,6 +585,14 @@ func GetNotifyCommit(req *restful.Request, resp *restful.Response) { resp.Write(res) } +func PostNotifyCommit(req *restful.Request, resp *restful.Response) { + res, err := devops.GetNotifyCommit(req.Request) + if err != nil { + parseErr(err, resp) + return + } + resp.Write(res) +} func GithubWebhook(req *restful.Request, resp *restful.Response) { res, err := devops.GithubWebhook(req.Request) if err != nil { diff --git a/tools/cmd/doc-gen/main.go b/tools/cmd/doc-gen/main.go index 22c20d6ec..e61e57735 100644 --- a/tools/cmd/doc-gen/main.go +++ b/tools/cmd/doc-gen/main.go @@ -26,12 +26,12 @@ import ( "github.com/emicklei/go-restful-openapi" "github.com/go-openapi/spec" "io/ioutil" - _ "kubesphere.io/kubesphere/pkg/apis/iam/install" - _ "kubesphere.io/kubesphere/pkg/apis/logging/install" "kubesphere.io/kubesphere/pkg/apiserver/runtime" "log" // Install apis _ "kubesphere.io/kubesphere/pkg/apis/devops/install" + _ "kubesphere.io/kubesphere/pkg/apis/iam/install" + _ "kubesphere.io/kubesphere/pkg/apis/logging/install" _ "kubesphere.io/kubesphere/pkg/apis/monitoring/install" _ "kubesphere.io/kubesphere/pkg/apis/operations/install" _ "kubesphere.io/kubesphere/pkg/apis/resources/install" @@ -78,7 +78,7 @@ func enrichSwaggerObject(swo *spec.Swagger) { Contact: &spec.ContactInfo{ Name: "kubesphere", Email: "kubesphere@yunify.com", - URL: "kubesphere.io", + URL: "https://kubesphere.io", }, License: &spec.License{ Name: "Apache", From 08877f950be5f3d149b18c71d61f97910e6c0028 Mon Sep 17 00:00:00 2001 From: hongming Date: Mon, 10 Jun 2019 14:37:33 +0800 Subject: [PATCH 22/24] update api docs Signed-off-by: hongming --- pkg/apis/iam/v1alpha2/register.go | 14 +++++++------- pkg/apis/resources/v1alpha2/register.go | 6 +++--- pkg/apis/tenant/v1alpha2/register.go | 9 +++++---- pkg/apiserver/iam/im.go | 6 +++--- pkg/apiserver/resources/resources.go | 4 ++++ pkg/apiserver/tenant/tenant.go | 7 +++++++ 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pkg/apis/iam/v1alpha2/register.go b/pkg/apis/iam/v1alpha2/register.go index c6f66ebe5..4fd5312a4 100644 --- a/pkg/apis/iam/v1alpha2/register.go +++ b/pkg/apis/iam/v1alpha2/register.go @@ -133,23 +133,23 @@ func addWebService(c *restful.Container) error { Reads(CreateUserRequest{}). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) - ws.Route(ws.DELETE("/users/{name}"). + ws.Route(ws.DELETE("/users/{username}"). To(iam.DeleteUser). Doc("Remove a specified user."). - Param(ws.PathParameter("name", "username")). + Param(ws.PathParameter("username", "username")). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) - ws.Route(ws.PUT("/users/{name}"). + ws.Route(ws.PUT("/users/{username}"). To(iam.UpdateUser). Doc("Updates information about the specified user."). - Param(ws.PathParameter("name", "username")). + Param(ws.PathParameter("username", "username")). Reads(UserUpdateRequest{}). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) - ws.Route(ws.GET("/users/{name}/log"). + ws.Route(ws.GET("/users/{username}/log"). To(iam.UserLoginLog). Doc("This method is used to retrieve the \"login logs\" for the specified user."). - Param(ws.PathParameter("name", "username")). + Param(ws.PathParameter("username", "username")). Returns(http.StatusOK, ok, LoginLog{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/users"). @@ -296,7 +296,7 @@ func addWebService(c *restful.Container) error { To(iam.RemoveUser). Doc("Remove members from workspace."). Param(ws.PathParameter("workspace", "workspace name")). - Param(ws.PathParameter("name", "username")). + Param(ws.PathParameter("username", "username")). Returns(http.StatusOK, ok, errors.Error{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}"). diff --git a/pkg/apis/resources/v1alpha2/register.go b/pkg/apis/resources/v1alpha2/register.go index 58487eec0..824adfa66 100644 --- a/pkg/apis/resources/v1alpha2/register.go +++ b/pkg/apis/resources/v1alpha2/register.go @@ -60,7 +60,7 @@ func addWebService(c *restful.Container) error { ok := "ok" webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}"). - To(resources.ListResources). + To(resources.ListNamespacedResources). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Namespace level resource query"). Param(webservice.PathParameter("namespace", "which namespace")). @@ -81,7 +81,7 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, ok, models.PageableResponse{}). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Cluster level resource query"). - Param(webservice.PathParameter("resources", "cluster level resource type"))). + Param(webservice.PathParameter("resources", "cluster level resource type")). Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). Required(false). DataFormat("key=value,key~value"). @@ -89,7 +89,7 @@ func addWebService(c *restful.Container) error { Param(webservice.QueryParameter(params.PagingParam, "page"). Required(false). DataFormat("limit=%d,page=%d"). - DefaultValue("limit=10,page=1")) + DefaultValue("limit=10,page=1"))) tags = []string{"Applications"} diff --git a/pkg/apis/tenant/v1alpha2/register.go b/pkg/apis/tenant/v1alpha2/register.go index c7d4a7aa3..41391939d 100644 --- a/pkg/apis/tenant/v1alpha2/register.go +++ b/pkg/apis/tenant/v1alpha2/register.go @@ -27,7 +27,7 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/tenant" "kubesphere.io/kubesphere/pkg/models/devops" "kubesphere.io/kubesphere/pkg/params" - esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" + "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" "kubesphere.io/kubesphere/pkg/errors" "kubesphere.io/kubesphere/pkg/models" @@ -59,7 +59,8 @@ func addWebService(c *restful.Container) error { Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}"). To(tenant.DescribeWorkspace). - Doc("Get workspace detail"). + Doc("Describe workspace"). + Param(ws.PathParameter("workspace", "workspace name")). Returns(http.StatusOK, ok, v1alpha1.Workspace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/rules"). @@ -87,7 +88,7 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, ok, []v1.Namespace{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces"). - To(tenant.ListNamespaces). + To(tenant.ListNamespacesByUsername). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "workspace member's username")). Doc("List the namespaces for the workspace member"). @@ -120,7 +121,7 @@ func addWebService(c *restful.Container) error { Doc("List devops projects for the current user"). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). - To(tenant.ListDevopsProjects). + To(tenant.ListDevopsProjectsByUsername). Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("username", "workspace member's username")). Param(ws.QueryParameter(params.PagingParam, "page"). diff --git a/pkg/apiserver/iam/im.go b/pkg/apiserver/iam/im.go index aca828a55..2a2ef4007 100644 --- a/pkg/apiserver/iam/im.go +++ b/pkg/apiserver/iam/im.go @@ -77,7 +77,7 @@ func CreateUser(req *restful.Request, resp *restful.Response) { } func DeleteUser(req *restful.Request, resp *restful.Response) { - username := req.PathParameter("name") + username := req.PathParameter("username") 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) { - usernameInPath := req.PathParameter("name") + usernameInPath := req.PathParameter("username") usernameInHeader := req.HeaderParameter(constants.UserNameHeader) var user models.User @@ -162,7 +162,7 @@ func isUserManager(username string) (bool, error) { } func UserLoginLog(req *restful.Request, resp *restful.Response) { - username := req.PathParameter("name") + username := req.PathParameter("username") logs, err := iam.LoginLog(username) if err != nil { diff --git a/pkg/apiserver/resources/resources.go b/pkg/apiserver/resources/resources.go index 56b195fbb..66f31afc5 100644 --- a/pkg/apiserver/resources/resources.go +++ b/pkg/apiserver/resources/resources.go @@ -26,6 +26,10 @@ import ( "kubesphere.io/kubesphere/pkg/params" ) +func ListNamespacedResources(req *restful.Request, resp *restful.Response) { + ListResources(req, resp) +} + func ListResources(req *restful.Request, resp *restful.Response) { namespace := req.PathParameter("namespace") resourceName := req.PathParameter("resources") diff --git a/pkg/apiserver/tenant/tenant.go b/pkg/apiserver/tenant/tenant.go index 08e12de94..99355bfdf 100644 --- a/pkg/apiserver/tenant/tenant.go +++ b/pkg/apiserver/tenant/tenant.go @@ -101,6 +101,9 @@ func DescribeWorkspace(req *restful.Request, resp *restful.Response) { resp.WriteAsJson(result) } +func ListNamespacesByUsername(req *restful.Request, resp *restful.Response) { + ListNamespaces(req, resp) +} func ListNamespaces(req *restful.Request, resp *restful.Response) { workspace := req.PathParameter("workspace") @@ -208,6 +211,10 @@ func checkResourceQuotas(wokrspace *v1alpha1.Workspace) error { return nil } +func ListDevopsProjectsByUsername(req *restful.Request, resp *restful.Response) { + ListDevopsProjects(req, resp) +} + func ListDevopsProjects(req *restful.Request, resp *restful.Response) { workspace := req.PathParameter("workspace") From 758e2716725fdd9c101987f179759bc02a27ecd3 Mon Sep 17 00:00:00 2001 From: runzexia Date: Tue, 11 Jun 2019 16:05:13 +0800 Subject: [PATCH 23/24] fix-devops-api-get-pipelines-404 Signed-off-by: runzexia --- pkg/apiserver/devops/devops.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/devops/devops.go b/pkg/apiserver/devops/devops.go index f4f8bc268..53ddbf1e5 100644 --- a/pkg/apiserver/devops/devops.go +++ b/pkg/apiserver/devops/devops.go @@ -29,8 +29,8 @@ import ( const jenkinsHeaderPre = "X-" func GetPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipelines") res, err := devops.GetPipeline(projectName, pipelineName, req.Request) if err != nil { From fb068f2416e993630bbc1cc2ac78098d4bdc0905 Mon Sep 17 00:00:00 2001 From: huanggze Date: Mon, 17 Jun 2019 16:59:13 +0800 Subject: [PATCH 24/24] api: add tags to monitoring and logging apis for classififcation Signed-off-by: huanggze --- pkg/apis/logging/v1alpha2/register.go | 25 +++++----- pkg/apis/monitoring/v1alpha2/register.go | 58 ++++++++++++------------ 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/pkg/apis/logging/v1alpha2/register.go b/pkg/apis/logging/v1alpha2/register.go index 6f5811af2..fd2f9b0dc 100644 --- a/pkg/apis/logging/v1alpha2/register.go +++ b/pkg/apis/logging/v1alpha2/register.go @@ -44,7 +44,6 @@ var ( func addWebService(c *restful.Container) error { ws := runtime.NewWebService(GroupVersion) - tags := []string{"Logging"} ws.Route(ws.GET("/cluster").To(logging.LoggingQueryCluster). Filter(filter.Logging). @@ -67,7 +66,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -93,7 +92,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -117,7 +116,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -140,7 +139,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -161,7 +160,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -181,7 +180,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}). Writes(esclient.Response{}). Returns(http.StatusOK, RespOK, esclient.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -190,21 +189,21 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/fluentbit/filters").To(logging.LoggingQueryFluentbitFilters). Filter(filter.Logging). Doc("List all Fluent bit filter plugins. This API is work-in-process."). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.POST("/fluentbit/filters").To(logging.LoggingUpdateFluentbitFilters). Filter(filter.Logging). Doc("Add a new Fluent bit filter plugin. This API is work-in-process."). - Metadata(restfulspec.KeyOpenAPITags, tags)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"})). Consumes(restful.MIME_JSON, restful.MIME_XML). Produces(restful.MIME_JSON) ws.Route(ws.GET("/fluentbit/outputs").To(logging.LoggingQueryFluentbitOutputs). Filter(filter.Logging). Doc("List all Fluent bit output plugins."). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}). Writes(log.FluentbitOutputsResult{}). Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -213,7 +212,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.POST("/fluentbit/outputs").To(logging.LoggingInsertFluentbitOutput). Filter(filter.Logging). Doc("Add a new Fluent bit output plugin."). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}). Reads(fluentbitclient.OutputPlugin{}). Writes(log.FluentbitOutputsResult{}). Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). @@ -224,7 +223,7 @@ func addWebService(c *restful.Container) error { Filter(filter.Logging). Doc("Update a Fluent bit output plugin."). Param(ws.PathParameter("output", "ID of the output to update.").DataType("string").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}). Reads(fluentbitclient.OutputPlugin{}). Writes(log.FluentbitOutputsResult{}). Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). @@ -235,7 +234,7 @@ func addWebService(c *restful.Container) error { Filter(filter.Logging). Doc("Delete a Fluent bit output plugin."). Param(ws.PathParameter("output", "ID of the output to delete.").DataType("string").Required(true)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}). Writes(log.FluentbitOutputsResult{}). Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). diff --git a/pkg/apis/monitoring/v1alpha2/register.go b/pkg/apis/monitoring/v1alpha2/register.go index 642660bc9..e80123025 100644 --- a/pkg/apis/monitoring/v1alpha2/register.go +++ b/pkg/apis/monitoring/v1alpha2/register.go @@ -42,8 +42,6 @@ var ( func addWebService(c *restful.Container) error { ws := runtime.NewWebService(GroupVersion) - tags := []string{"Monitoring"} - ws.Route(ws.GET("/cluster").To(monitoring.MonitorCluster). Doc("Get cluster-level metrics."). Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. cluster_cpu|cluster_memory.").DataType("string").Required(false)). @@ -51,7 +49,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "cluster"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -65,8 +63,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -80,7 +78,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -94,8 +92,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -109,7 +107,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -124,8 +122,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -140,7 +138,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -155,8 +153,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -171,7 +169,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -187,8 +185,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -204,8 +202,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -216,12 +214,12 @@ func addWebService(c *restful.Container) error { Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)). Param(ws.PathParameter("container", "Specify the target container.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)).Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -239,7 +237,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -255,8 +253,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -271,8 +269,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -287,7 +285,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -301,8 +299,8 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")). Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")). - Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistic.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -316,7 +314,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)). Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "component"}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML).