From ed0b211c2b4cfa8ebd9689c592e4024de7c1c313 Mon Sep 17 00:00:00 2001 From: huanggze Date: Wed, 19 Jun 2019 20:17:13 +0800 Subject: [PATCH 1/3] fix: update metrics for node disk usage and capacity Signed-off-by: huanggze --- pkg/models/metrics/metricsruleconst.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/models/metrics/metricsruleconst.go b/pkg/models/metrics/metricsruleconst.go index 449d2f2bc..d14a2aeb1 100644 --- a/pkg/models/metrics/metricsruleconst.go +++ b/pkg/models/metrics/metricsruleconst.go @@ -400,10 +400,10 @@ var RulePromQLTmplMap = MetricMap{ "cluster_disk_read_throughput": "sum(node:data_volume_throughput_bytes_read:sum)", "cluster_disk_write_throughput": "sum(node:data_volume_throughput_bytes_written:sum)", - "cluster_disk_size_usage": `sum(max(node_filesystem_size_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"} - node_filesystem_avail_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"}) by (device, instance))`, + "cluster_disk_size_usage": `sum(max(node_filesystem_size_bytes{device=~"/dev/.*", job="node-exporter"} - node_filesystem_avail_bytes{device=~"/dev/.*", job="node-exporter"}) by (device, instance))`, "cluster_disk_size_utilisation": `cluster:disk_utilization:ratio`, - "cluster_disk_size_capacity": `sum(max(node_filesystem_size_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"}) by (device, instance))`, - "cluster_disk_size_available": `sum(max(node_filesystem_avail_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"}) by (device, instance))`, + "cluster_disk_size_capacity": `sum(max(node_filesystem_size_bytes{device=~"/dev/.*", job="node-exporter"}) by (device, instance))`, + "cluster_disk_size_available": `sum(max(node_filesystem_avail_bytes{device=~"/dev/.*", job="node-exporter"}) by (device, instance))`, "cluster_disk_inode_total": `sum(node:node_inodes_total:)`, "cluster_disk_inode_usage": `sum(node:node_inodes_total:) - sum(node:node_inodes_free:)`, @@ -481,9 +481,9 @@ var RulePromQLTmplMap = MetricMap{ "node_disk_read_throughput": "node:data_volume_throughput_bytes_read:sum", "node_disk_write_throughput": "node:data_volume_throughput_bytes_written:sum", - "node_disk_size_capacity": `sum(max(node_filesystem_size_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1) by (device, node)) by (node)`, + "node_disk_size_capacity": `sum(max(node_filesystem_size_bytes{device=~"/dev/.*", job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1) by (device, node)) by (node)`, "node_disk_size_available": `node:disk_space_available:$1`, - "node_disk_size_usage": `sum(max((node_filesystem_size_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"} - node_filesystem_avail_bytes{device=~"/dev/[vsh]d.+", job="node-exporter"}) * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1) by (device, node)) by (node)`, + "node_disk_size_usage": `sum(max((node_filesystem_size_bytes{device=~"/dev/.*", job="node-exporter"} - node_filesystem_avail_bytes{device=~"/dev/.*", job="node-exporter"}) * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1) by (device, node)) by (node)`, "node_disk_size_utilisation": `node:disk_space_utilization:ratio$1`, "node_disk_inode_total": `node:node_inodes_total:$1`, From 72875c788594dddee586bb3adabd0b68d11e1ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E7=BE=81?= Date: Thu, 20 Jun 2019 16:23:24 +0800 Subject: [PATCH 2/3] fix: get application details failed (#481) Signed-off-by: hongming --- cmd/ks-iam/app/options/options.go | 2 + cmd/ks-iam/app/server.go | 2 +- pkg/apis/iam/v1alpha2/register.go | 2 +- pkg/apiserver/iam/auth.go | 6 +- .../namespace/namespace_controller.go | 2 +- pkg/models/applications/applications.go | 15 ++++ pkg/models/iam/im.go | 71 ++++++++++++++++--- pkg/models/resources/nodes.go | 6 ++ pkg/models/resources/resources.go | 1 + 9 files changed, 94 insertions(+), 13 deletions(-) diff --git a/cmd/ks-iam/app/options/options.go b/cmd/ks-iam/app/options/options.go index 9de464ec6..85c678447 100644 --- a/cmd/ks-iam/app/options/options.go +++ b/cmd/ks-iam/app/options/options.go @@ -28,6 +28,7 @@ type ServerRunOptions struct { AdminPassword string TokenExpireTime string JWTSecret string + AuthRateLimit string } func NewServerRunOptions() *ServerRunOptions { @@ -42,5 +43,6 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.AdminPassword, "admin-password", "passw0rd", "default administrator's password") fs.StringVar(&s.TokenExpireTime, "token-expire-time", "2h", "token expire time,valid time units are \"ns\",\"us\",\"ms\",\"s\",\"m\",\"h\"") fs.StringVar(&s.JWTSecret, "jwt-secret", "", "jwt secret") + fs.StringVar(&s.AuthRateLimit, "auth-rate-limit", "5/30m", "specifies the maximum number of authentication attempts permitted and time interval,valid time units are \"s\",\"m\",\"h\"") s.GenericServerRunOptions.AddFlags(fs) } diff --git a/cmd/ks-iam/app/server.go b/cmd/ks-iam/app/server.go index cd9e31c6d..17239a7ba 100644 --- a/cmd/ks-iam/app/server.go +++ b/cmd/ks-iam/app/server.go @@ -75,7 +75,7 @@ func Run(s *options.ServerRunOptions) error { initializeAdminJenkins() initializeDevOpsDatabase() - err = iam.Init(s.AdminEmail, s.AdminPassword, expireTime) + err = iam.Init(s.AdminEmail, s.AdminPassword, expireTime, s.AuthRateLimit) jwtutil.Setup(s.JWTSecret) if err != nil { diff --git a/pkg/apis/iam/v1alpha2/register.go b/pkg/apis/iam/v1alpha2/register.go index 719dd0007..0771f0c5b 100644 --- a/pkg/apis/iam/v1alpha2/register.go +++ b/pkg/apis/iam/v1alpha2/register.go @@ -116,7 +116,7 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, ok, iam.TokenReview{}). Metadata(restfulspec.KeyOpenAPITags, tags)) ws.Route(ws.POST("/login"). - To(iam.LoginHandler). + To(iam.Login). Doc("KubeSphere APIs support token-based authentication via the Authtoken request header. The POST Login API is used to retrieve the authentication token. After the authentication token is obtained, it must be inserted into the Authtoken header for all requests."). Reads(iam.LoginRequest{}). Returns(http.StatusOK, ok, models.Token{}). diff --git a/pkg/apiserver/iam/auth.go b/pkg/apiserver/iam/auth.go index 49245654e..2a0cde349 100644 --- a/pkg/apiserver/iam/auth.go +++ b/pkg/apiserver/iam/auth.go @@ -55,7 +55,7 @@ const ( KindTokenReview = "TokenReview" ) -func LoginHandler(req *restful.Request, resp *restful.Response) { +func Login(req *restful.Request, resp *restful.Response) { var loginRequest LoginRequest err := req.ReadEntity(&loginRequest) @@ -70,6 +70,10 @@ func LoginHandler(req *restful.Request, resp *restful.Response) { token, err := iam.Login(loginRequest.Username, loginRequest.Password, ip) if err != nil { + if serviceError, ok := err.(restful.ServiceError); ok { + resp.WriteHeaderAndEntity(serviceError.Code, errors.New(serviceError.Message)) + return + } resp.WriteHeaderAndEntity(http.StatusUnauthorized, errors.Wrap(err)) return } diff --git a/pkg/controller/namespace/namespace_controller.go b/pkg/controller/namespace/namespace_controller.go index 81917aa44..b9035d658 100644 --- a/pkg/controller/namespace/namespace_controller.go +++ b/pkg/controller/namespace/namespace_controller.go @@ -60,7 +60,7 @@ var ( defaultRoles = []rbac.Role{ {ObjectMeta: metav1.ObjectMeta{Name: "admin", Annotations: map[string]string{constants.DescriptionAnnotationKey: adminDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, {ObjectMeta: metav1.ObjectMeta{Name: "operator", Annotations: map[string]string{constants.DescriptionAnnotationKey: operatorDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}, - {Verbs: []string{"*"}, APIGroups: []string{"", "apps", "extensions", "batch", "logging.kubesphere.io", "monitoring.kubesphere.io", "iam.kubesphere.io", "resources.kubesphere.io", "autoscaling", "alerting.kubesphere.io", "app.k8s.io", "servicemesh.kubesphere.io"}, Resources: []string{"*"}}}}, + {Verbs: []string{"*"}, APIGroups: []string{"", "apps", "extensions", "batch", "logging.kubesphere.io", "monitoring.kubesphere.io", "iam.kubesphere.io", "resources.kubesphere.io", "autoscaling", "alerting.kubesphere.io", "app.k8s.io", "servicemesh.kubesphere.io", "operations.kubesphere.io"}, Resources: []string{"*"}}}}, {ObjectMeta: metav1.ObjectMeta{Name: "viewer", Annotations: map[string]string{constants.DescriptionAnnotationKey: viewerDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, } ) diff --git a/pkg/models/applications/applications.go b/pkg/models/applications/applications.go index c90a00cdf..78b792f83 100644 --- a/pkg/models/applications/applications.go +++ b/pkg/models/applications/applications.go @@ -148,6 +148,11 @@ func getWorkLoads(namespace string, clusterRoles []openpitrix.ClusterRole) (*wor item, err := informers.SharedInformerFactory().Apps().V1().Deployments().Lister().Deployments(namespace).Get(name) if err != nil { + // app not ready + if errors.IsNotFound(err) { + continue + } + glog.Error(err) return nil, err } @@ -159,6 +164,11 @@ func getWorkLoads(namespace string, clusterRoles []openpitrix.ClusterRole) (*wor name := strings.Split(workLoadName, openpitrix.DaemonSuffix)[0] item, err := informers.SharedInformerFactory().Apps().V1().DaemonSets().Lister().DaemonSets(namespace).Get(name) if err != nil { + // app not ready + if errors.IsNotFound(err) { + continue + } + glog.Error(err) return nil, err } works.Daemonsets = append(works.Daemonsets, *item) @@ -169,6 +179,11 @@ func getWorkLoads(namespace string, clusterRoles []openpitrix.ClusterRole) (*wor name := strings.Split(workLoadName, openpitrix.StateSuffix)[0] item, err := informers.SharedInformerFactory().Apps().V1().StatefulSets().Lister().StatefulSets(namespace).Get(name) if err != nil { + // app not ready + if errors.IsNotFound(err) { + continue + } + glog.Error(err) return nil, err } works.Statefulsets = append(works.Statefulsets, *item) diff --git a/pkg/models/iam/im.go b/pkg/models/iam/im.go index 0ab9cae4e..bbe9e49b0 100644 --- a/pkg/models/iam/im.go +++ b/pkg/models/iam/im.go @@ -56,10 +56,12 @@ import ( ) var ( - adminEmail string - adminPassword string - tokenExpireTime time.Duration - initUsers []initUser + adminEmail string + adminPassword string + tokenExpireTime time.Duration + maxAuthFailed int + authTimeInterval time.Duration + initUsers []initUser ) type initUser struct { @@ -68,14 +70,17 @@ type initUser struct { } const ( - userInitFile = "/etc/ks-iam/users.json" + userInitFile = "/etc/ks-iam/users.json" + authRateLimitRegex = `(\d+)/(\d+[s|m|h])` + defaultMaxAuthFailed = 5 + defaultAuthTimeInterval = 30 * time.Minute ) -func Init(email, password string, t time.Duration) error { +func Init(email, password string, expireTime time.Duration, authRateLimit string) error { adminEmail = email adminPassword = password - tokenExpireTime = t - + tokenExpireTime = expireTime + maxAuthFailed, authTimeInterval = parseAuthRateLimit(authRateLimit) conn, err := ldapclient.Client() if err != nil { @@ -101,6 +106,23 @@ func Init(email, password string, t time.Duration) error { return nil } +func parseAuthRateLimit(authRateLimit string) (int, time.Duration) { + regex := regexp.MustCompile(authRateLimitRegex) + groups := regex.FindStringSubmatch(authRateLimit) + + maxCount := defaultMaxAuthFailed + timeInterval := defaultAuthTimeInterval + + if len(groups) == 3 { + maxCount, _ = strconv.Atoi(groups[1]) + timeInterval, _ = time.ParseDuration(groups[2]) + } else { + glog.Warning("invalid auth rate limit", authRateLimit) + } + + return maxCount, timeInterval +} + func checkAndCreateDefaultGroup(conn ldap.Client) error { groupSearchRequest := ldap.NewSearchRequest( @@ -203,9 +225,23 @@ func createGroupsBaseDN(conn ldap.Client) error { // User login func Login(username string, password string, ip string) (*models.Token, error) { + redisClient := redis.Client() + + records, err := redisClient.Keys(fmt.Sprintf("kubesphere:authfailed:%s:*", username)).Result() + + if err != nil { + glog.Error(err) + return nil, err + } + + if len(records) >= maxAuthFailed { + return nil, restful.NewError(http.StatusTooManyRequests, "auth rate limit exceeded") + } + conn, err := ldapclient.Client() if err != nil { + glog.Error(err) return nil, err } @@ -237,7 +273,13 @@ func Login(username string, password string, ip string) (*models.Token, error) { err = conn.Bind(dn, password) if err != nil { - glog.Errorln("auth error", username, err) + glog.Infoln("auth failed", username, err) + + if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) { + loginFailedRecord := fmt.Sprintf("kubesphere:authfailed:%s:%d", username, time.Now().UnixNano()) + redisClient.Set(loginFailedRecord, "", authTimeInterval) + } + return nil, err } @@ -876,6 +918,17 @@ func UpdateUser(user *models.User) (*models.User, error) { return nil, err } + // clear auth failed record + if user.Password != "" { + redisClient := redis.Client() + + records, err := redisClient.Keys(fmt.Sprintf("kubesphere:authfailed:%s:*", user.Username)).Result() + + if err == nil { + redisClient.Del(records...) + } + } + return GetUserInfo(user.Username) } func DeleteGroup(path string) error { diff --git a/pkg/models/resources/nodes.go b/pkg/models/resources/nodes.go index 6daa02c61..38e607f0b 100644 --- a/pkg/models/resources/nodes.go +++ b/pkg/models/resources/nodes.go @@ -18,6 +18,7 @@ package resources import ( + "fmt" "kubesphere.io/kubesphere/pkg/constants" "kubesphere.io/kubesphere/pkg/informers" "kubesphere.io/kubesphere/pkg/params" @@ -45,6 +46,11 @@ func (*nodeSearcher) match(match map[string]string, item *v1.Node) bool { if !sliceutil.HasString(names, item.Name) { return false } + case Role: + labelKey := fmt.Sprintf("node-role.kubernetes.io/%s", v) + if _, ok := item.Labels[labelKey]; !ok { + return false + } case Keyword: if !strings.Contains(item.Name, v) && !searchFuzzy(item.Labels, "", v) && !searchFuzzy(item.Annotations, "", v) { return false diff --git a/pkg/models/resources/resources.go b/pkg/models/resources/resources.go index 428ee70fb..4017cced5 100644 --- a/pkg/models/resources/resources.go +++ b/pkg/models/resources/resources.go @@ -61,6 +61,7 @@ const ( Label = "label" OwnerKind = "ownerKind" OwnerName = "ownerName" + Role = "role" CreateTime = "createTime" UpdateTime = "updateTime" LastScheduleTime = "lastScheduleTime" From 39e8de7de54217235bdaa1e4dd71fa4588441ce4 Mon Sep 17 00:00:00 2001 From: soulseen Date: Fri, 21 Jun 2019 10:47:24 +0800 Subject: [PATCH 3/3] update devops api doc & remove not used api Signed-off-by: soulseen --- pkg/apis/devops/v1alpha2/register.go | 416 +++++++++++++-------------- pkg/apiserver/devops/devops.go | 235 +++++++-------- pkg/models/devops/devops.go | 29 +- pkg/models/devops/urlconfig.go | 4 - 4 files changed, 297 insertions(+), 387 deletions(-) diff --git a/pkg/apis/devops/v1alpha2/register.go b/pkg/apis/devops/v1alpha2/register.go index 4cb4c4cdf..d010b48be 100644 --- a/pkg/apis/devops/v1alpha2/register.go +++ b/pkg/apis/devops/v1alpha2/register.go @@ -216,18 +216,18 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.JenkinsCredential{}). Reads([]devops.JenkinsCredential{})) - // match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}" - webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}"). + // match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}"). To(devopsapi.GetPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get a Pipeline Inside a 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.")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). Returns(http.StatusOK, RespOK, devops.Pipeline{}). Writes(devops.Pipeline{})) // match Jenkisn api: "jenkins_api/blue/rest/search" - webservice.Route(webservice.GET("/devops/search"). + webservice.Route(webservice.GET("/search"). To(devopsapi.SearchPipelines). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Search DevOps resource."). @@ -246,13 +246,13 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.Pipeline{}). Writes([]devops.Pipeline{})) - // match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs"). + // match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs"). To(devopsapi.SearchPipelineRuns). 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.")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). Param(webservice.QueryParameter("start", "the count of item start."). Required(false). DataFormat("start=%d")). @@ -265,30 +265,30 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}). Writes([]devops.BranchPipelineRun{})) - // match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}"). + // match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}"). To(devopsapi.GetBranchPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). 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.")). - 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("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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{}). Writes(devops.BranchPipelineRun{})) - // match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes"). + // match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/nodes" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes"). To(devopsapi.GetPipelineRunNodesbyBranch). Metadata(restfulspec.KeyOpenAPITags, tags). 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.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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"). @@ -296,67 +296,67 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.BranchPipelineRunNodes{}). Writes([]devops.BranchPipelineRunNodes{})) - // match "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log/?start=0" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log"). + // match "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}/log/?start=0" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}/log"). To(devopsapi.GetBranchStepLog). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - 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.")). - 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.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("step", "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"))) - // match "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log/?start=0" - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log"). + // match "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/nodes/{node}/steps/{step}/log/?start=0" + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}/log"). To(devopsapi.GetStepLog). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipelines step log."). Produces("text/plain; charset=utf-8"). - 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.")). - Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("step", "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"))) // match "/blue/rest/organizations/jenkins/scm/github/validate/" - webservice.Route(webservice.PUT("/devops/scm/{scmId}/validate"). + webservice.Route(webservice.POST("/scms/{scm}/verify"). To(devopsapi.Validate). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Validate Github personal access token."). - Param(webservice.PathParameter("scmId", "the id of SCM.")). + Param(webservice.PathParameter("scm", "the id of SCM.")). Returns(http.StatusOK, RespOK, devops.Validates{}). Writes(devops.Validates{})) - // match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/?credentialId=github" - webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations"). + // match "/blue/rest/organizations/jenkins/scm/{scm}/organizations/?credentialId=github" + webservice.Route(webservice.GET("/scms/{scm}/organizations"). To(devopsapi.GetSCMOrg). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("List organizations of SCM"). - Param(webservice.PathParameter("scmId", "the id of SCM.")). + Param(webservice.PathParameter("scm", "the id of SCM.")). Param(webservice.QueryParameter("credentialId", "credential id for SCM."). Required(true). DataFormat("credentialId=%s")). Returns(http.StatusOK, RespOK, []devops.SCMOrg{}). Writes([]devops.SCMOrg{})) - // match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/{organizationId}/repositories/?credentialId=&pageNumber&pageSize=" - webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations/{organizationId}/repositories"). + // match "/blue/rest/organizations/jenkins/scm/{scm}/organizations/{organization}/repositories/?credentialId=&pageNumber&pageSize=" + webservice.Route(webservice.GET("/scms/{scm}/organizations/{organization}/repositories"). To(devopsapi.GetOrgRepo). 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.PathParameter("scm", "SCM id")). + Param(webservice.PathParameter("organization", "organization Id, such as github username.")). Param(webservice.QueryParameter("credentialId", "credential id for SCM."). Required(true). DataFormat("credentialId=%s")). @@ -369,15 +369,15 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.OrgRepo{}). Writes([]devops.OrgRepo{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/stop/ - webservice.Route(webservice.PUT("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/stop"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/stop/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/stop"). To(devopsapi.StopBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Stop pipeline in running"). - 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.")). + Doc("Stop pipeline in running filter by branch"). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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"). @@ -389,14 +389,14 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, devops.StopPipe{}). Writes(devops.StopPipe{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/stop/ - webservice.Route(webservice.PUT("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/stop"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/stop/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/stop"). To(devopsapi.StopPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Stop pipeline in running"). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "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"). @@ -408,67 +408,67 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, devops.StopPipe{}). Writes(devops.StopPipe{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/Replay/ - webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/replay"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/Replay/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/replay"). To(devopsapi.ReplayBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - 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.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.ReplayPipe{}). Writes(devops.ReplayPipe{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/Replay/ - webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/replay"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/Replay/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/replay"). To(devopsapi.ReplayPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Replay pipeline"). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.ReplayPipe{}). Writes(devops.ReplayPipe{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/log/?start=0 - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/log"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/log/?start=0 + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/log"). To(devopsapi.GetBranchRunLog). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - 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.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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"))) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/log/?start=0 - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/log"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/log/?start=0 + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/log"). To(devopsapi.GetRunLog). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipelines run log."). Produces("text/plain; charset=utf-8"). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "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"))) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/artifacts - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/artifacts"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/artifacts + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/artifacts"). To(devopsapi.GetBranchArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - 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.")). + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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")). @@ -478,14 +478,14 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}). Writes([]devops.Artifacts{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/artifacts - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/artifacts"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/artifacts + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/artifacts"). To(devopsapi.GetArtifacts). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get pipeline artifacts."). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "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")). @@ -495,13 +495,13 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}). Writes([]devops.Artifacts{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/?filter=&start&limit= - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/?filter=&start&limit= + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches"). To(devopsapi.GetPipeBranch). Metadata(restfulspec.KeyOpenAPITags, tags). 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.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Param(webservice.QueryParameter("filter", "filter remote scm. e.g. origin"). Required(true). DataFormat("filter=%s")). @@ -514,170 +514,140 @@ func addWebService(c *restful.Container) error { Returns(http.StatusOK, RespOK, []devops.PipeBranch{}). Writes([]devops.PipeBranch{})) - // /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId} - webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}"). + // /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step} + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}"). To(devopsapi.CheckBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). 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.")). - 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.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("step", "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}"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step} + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}"). To(devopsapi.CheckPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). 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.")). - 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"))) + Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("step", "pipeline step id"))) // match /job/project-8QnvykoJw4wZ/job/test-1/indexing/consoleText - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/console/log"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/consolelog"). To(devopsapi.GetConsoleLog). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get index console log."). Produces("text/plain; charset=utf-8"). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "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"). + // match /job/{devops}/job/{pipeline}/build?delay=0 + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/scan"). To(devopsapi.ScanBranch). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Start a build."). + Doc("Scan remote Repositorie, Start a build if have new branch."). Produces("text/html; charset=utf-8"). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "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/ - webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{}/runs/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/run"). To(devopsapi.RunBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). Writes(devops.QueuedBlueRun{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/ - webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/run"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/ + webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/run"). To(devopsapi.RunPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Run pipeline."). Reads(devops.RunPayload{}). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}). Writes(devops.QueuedBlueRun{})) - // match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit= - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status"). - To(devopsapi.GetBranchStepsStatus). - Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get pipeline steps status."). - 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.")). - 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{}). - Writes([]devops.QueuedBlueRun{})) - - // match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/nodes/?limit= - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/status"). - To(devopsapi.GetStepsStatus). - Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get pipeline steps status."). - 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.")). - Param(webservice.QueryParameter("limit", "the count of item limit."). - Required(true). - DataFormat("limit=%d")). - Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). - Writes([]devops.QueuedBlueRun{})) - // match /crumbIssuer/api/json/ - webservice.Route(webservice.GET("/devops/crumbissuer"). + webservice.Route(webservice.GET("/crumbissuer"). To(devopsapi.GetCrumb). Metadata(restfulspec.KeyOpenAPITags, tags). 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{})) - // match /job/init-job/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile - webservice.Route(webservice.POST("/devops/check/scriptcompile"). - To(devopsapi.CheckScriptCompile). - Metadata(restfulspec.KeyOpenAPITags, tags). - Consumes("application/x-www-form-urlencoded", "charset=utf-8"). - Produces("application/json", "charset=utf-8"). - Doc("Check pipeline script compile."). - Reads(devops.ReqScript{}). - Returns(http.StatusOK, RespOK, devops.CheckScript{}). - Writes(devops.CheckScript{})) + // TODO are not used in this version. will be added in 2.1.0 + //// match /job/init-job/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile + //webservice.Route(webservice.POST("/devops/check/scriptcompile"). + // To(devopsapi.CheckScriptCompile). + // Metadata(restfulspec.KeyOpenAPITags, tags). + // Consumes("application/x-www-form-urlencoded", "charset=utf-8"). + // Produces("application/json", "charset=utf-8"). + // Doc("Check pipeline script compile."). + // Reads(devops.ReqScript{}). + // Returns(http.StatusOK, RespOK, devops.CheckScript{}). + // Writes(devops.CheckScript{})) // match /job/init-job/descriptorByName/hudson.triggers.TimerTrigger/checkSpec - webservice.Route(webservice.GET("/devops/check/cron"). - To(devopsapi.CheckCron). - Metadata(restfulspec.KeyOpenAPITags, tags). - Produces("application/json", "charset=utf-8"). - Doc("Check cron script compile."). - Param(webservice.QueryParameter("value", "string of cron script."). - Required(true). - DataFormat("value=%s")). - Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). - Returns(http.StatusOK, RespOK, devops.CheckCronRes{}). - Writes(devops.CheckCronRes{})) + //webservice.Route(webservice.GET("/devops/check/cron"). + // To(devopsapi.CheckCron). + // Metadata(restfulspec.KeyOpenAPITags, tags). + // Produces("application/json", "charset=utf-8"). + // Doc("Check cron script compile."). + // Param(webservice.QueryParameter("value", "string of cron script."). + // Required(true). + // DataFormat("value=%s")). + // Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}). + // Returns(http.StatusOK, RespOK, devops.CheckCronRes{}). + // Writes(devops.CheckCronRes{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/ - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/ + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}"). To(devopsapi.GetPipelineRun). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get run pipeline in project."). - 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("devops", "the name of devops project")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). Returns(http.StatusOK, RespOK, devops.PipelineRun{}). Writes(devops.PipelineRun{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName} - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch} + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}"). To(devopsapi.GetBranchPipeline). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get Pipeline run by branch."). - 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("devops", "the name of devops project")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach")). Returns(http.StatusOK, RespOK, devops.BranchPipeline{}). Writes(devops.BranchPipeline{})) - // match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/?limit=10000 - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes"). + // match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/?limit=10000 + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes"). To(devopsapi.GetPipelineRunNodes). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get 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("runId", "pipeline run id, the unique id for a pipeline once build")). + Param(webservice.PathParameter("devops", "the name of devops project")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "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")). @@ -685,15 +655,15 @@ func addWebService(c *restful.Container) error { Writes([]devops.PipelineRunNodes{})) // match /blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/?limit= - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps"). To(devopsapi.GetBranchNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get steps in node by branch."). - 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.")). - Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")). + Param(webservice.PathParameter("devops", "the name of devops project")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). @@ -701,14 +671,14 @@ func addWebService(c *restful.Container) error { Writes([]devops.NodeSteps{})) // match /blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?limit= - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps"). To(devopsapi.GetNodeSteps). Metadata(restfulspec.KeyOpenAPITags, tags). Doc("Get steps in node."). - 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.")). + Param(webservice.PathParameter("devops", "the name of devops project")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build")). + Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")). Param(webservice.QueryParameter("limit", "the count of item limit."). Required(false). DataFormat("limit=%d")). @@ -716,7 +686,7 @@ func addWebService(c *restful.Container) error { Writes([]devops.NodeSteps{})) // match /pipeline-model-converter/toJenkinsfile - webservice.Route(webservice.POST("/devops/tojenkinsfile"). + webservice.Route(webservice.POST("/tojenkinsfile"). To(devopsapi.ToJenkinsfile). Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). @@ -727,7 +697,7 @@ func addWebService(c *restful.Container) error { Writes(devops.ResJenkinsfile{})) // match /pipeline-model-converter/toJson - webservice.Route(webservice.POST("/devops/tojson"). + webservice.Route(webservice.POST("/tojson"). To(devopsapi.ToJson). Metadata(restfulspec.KeyOpenAPITags, tags). Consumes("application/x-www-form-urlencoded"). @@ -738,40 +708,40 @@ func addWebService(c *restful.Container) error { Writes(devops.ResJson{})) // match /git/notifyCommit/?url= - webservice.Route(webservice.GET("/devops/notifycommit"). + webservice.Route(webservice.GET("/webhook/git"). To(devopsapi.GetNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get notification commit by HTTP GET method."). + Doc("Get commit notification by HTTP GET method. Git webhook will request here."). Produces("text/plain; charset=utf-8"). Param(webservice.QueryParameter("url", "url of git scm"). Required(true). DataFormat("url=%s"))) // Gitlab or some other scm managers can only use HTTP method. match /git/notifyCommit/?url= - webservice.Route(webservice.POST("/devops/notifycommit"). + webservice.Route(webservice.POST("/webhook/git"). To(devopsapi.PostNotifyCommit). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("Get notification commit by HTTP POST method."). + Doc("Get commit notification by HTTP POST method. Git webhook will request here."). Consumes("application/json"). Produces("text/plain; charset=utf-8"). Param(webservice.QueryParameter("url", "url of git scm"). Required(true). DataFormat("url=%s"))) - webservice.Route(webservice.POST("/devops/github/webhook"). + webservice.Route(webservice.POST("/webhook/github"). To(devopsapi.GithubWebhook). Metadata(restfulspec.KeyOpenAPITags, tags). - Doc("receive webhook request.")) + Doc("Get commit notification. Github webhook will request here.")) // in scm get all steps in nodes. - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodesdetail"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodesdetail"). 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.")). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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")). @@ -779,14 +749,14 @@ func addWebService(c *restful.Container) error { Writes(devops.NodesDetail{})) // out of scm get all steps in nodes. - webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodesdetail"). + webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodesdetail"). 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.")). - 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("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")). + Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")). + Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")). + Param(webservice.PathParameter("run", "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")). diff --git a/pkg/apiserver/devops/devops.go b/pkg/apiserver/devops/devops.go index 53ddbf1e5..1f9edae0f 100644 --- a/pkg/apiserver/devops/devops.go +++ b/pkg/apiserver/devops/devops.go @@ -30,7 +30,7 @@ const jenkinsHeaderPre = "X-" func GetPipeline(req *restful.Request, resp *restful.Response) { projectName := req.PathParameter("devops") - pipelineName := req.PathParameter("pipelines") + pipelineName := req.PathParameter("pipeline") res, err := devops.GetPipeline(projectName, pipelineName, req.Request) if err != nil { @@ -54,8 +54,8 @@ func SearchPipelines(req *restful.Request, resp *restful.Response) { } func SearchPipelineRuns(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") res, err := devops.SearchPipelineRuns(projectName, pipelineName, req.Request) if err != nil { @@ -68,10 +68,10 @@ func SearchPipelineRuns(req *restful.Request, resp *restful.Response) { } func GetBranchPipelineRun(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.GetBranchPipelineRun(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -84,10 +84,10 @@ func GetBranchPipelineRun(req *restful.Request, resp *restful.Response) { } func GetPipelineRunNodesbyBranch(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -100,12 +100,12 @@ func GetPipelineRunNodesbyBranch(req *restful.Request, resp *restful.Response) { } func GetBranchStepLog(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - stepId := req.PathParameter("stepId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") + stepId := req.PathParameter("step") res, header, err := devops.GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId, req.Request) @@ -122,11 +122,11 @@ func GetBranchStepLog(req *restful.Request, resp *restful.Response) { } func GetStepLog(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - stepId := req.PathParameter("stepId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") + stepId := req.PathParameter("step") res, header, err := devops.GetStepLog(projectName, pipelineName, runId, nodeId, stepId, req.Request) if err != nil { @@ -142,7 +142,7 @@ func GetStepLog(req *restful.Request, resp *restful.Response) { } func Validate(req *restful.Request, resp *restful.Response) { - scmId := req.PathParameter("scmId") + scmId := req.PathParameter("scm") res, err := devops.Validate(scmId, req.Request) if err != nil { @@ -155,7 +155,7 @@ func Validate(req *restful.Request, resp *restful.Response) { } func GetSCMOrg(req *restful.Request, resp *restful.Response) { - scmId := req.PathParameter("scmId") + scmId := req.PathParameter("scm") res, err := devops.GetSCMOrg(scmId, req.Request) if err != nil { @@ -168,8 +168,8 @@ func GetSCMOrg(req *restful.Request, resp *restful.Response) { } func GetOrgRepo(req *restful.Request, resp *restful.Response) { - scmId := req.PathParameter("scmId") - organizationId := req.PathParameter("organizationId") + scmId := req.PathParameter("scm") + organizationId := req.PathParameter("organization") res, err := devops.GetOrgRepo(scmId, organizationId, req.Request) if err != nil { @@ -182,10 +182,10 @@ func GetOrgRepo(req *restful.Request, resp *restful.Response) { } func StopBranchPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.StopBranchPipeline(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -198,9 +198,9 @@ func StopBranchPipeline(req *restful.Request, resp *restful.Response) { } func StopPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.StopPipeline(projectName, pipelineName, runId, req.Request) if err != nil { @@ -213,10 +213,10 @@ func StopPipeline(req *restful.Request, resp *restful.Response) { } func ReplayBranchPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.ReplayBranchPipeline(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -229,9 +229,9 @@ func ReplayBranchPipeline(req *restful.Request, resp *restful.Response) { } func ReplayPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.ReplayPipeline(projectName, pipelineName, runId, req.Request) if err != nil { @@ -244,10 +244,10 @@ func ReplayPipeline(req *restful.Request, resp *restful.Response) { } func GetBranchRunLog(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.GetBranchRunLog(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -259,9 +259,9 @@ func GetBranchRunLog(req *restful.Request, resp *restful.Response) { } func GetRunLog(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.GetRunLog(projectName, pipelineName, runId, req.Request) if err != nil { @@ -273,10 +273,10 @@ func GetRunLog(req *restful.Request, resp *restful.Response) { } func GetBranchArtifacts(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.GetBranchArtifacts(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -288,9 +288,9 @@ func GetBranchArtifacts(req *restful.Request, resp *restful.Response) { } func GetArtifacts(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.GetArtifacts(projectName, pipelineName, runId, req.Request) if err != nil { @@ -302,8 +302,8 @@ func GetArtifacts(req *restful.Request, resp *restful.Response) { } func GetPipeBranch(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") res, err := devops.GetPipeBranch(projectName, pipelineName, req.Request) if err != nil { @@ -315,12 +315,12 @@ func GetPipeBranch(req *restful.Request, resp *restful.Response) { } func CheckBranchPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - stepId := req.PathParameter("stepId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") + stepId := req.PathParameter("step") res, err := devops.CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId, req.Request) if err != nil { @@ -332,11 +332,11 @@ func CheckBranchPipeline(req *restful.Request, resp *restful.Response) { } func CheckPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - stepId := req.PathParameter("stepId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") + stepId := req.PathParameter("step") res, err := devops.CheckPipeline(projectName, pipelineName, runId, nodeId, stepId, req.Request) if err != nil { @@ -348,8 +348,8 @@ func CheckPipeline(req *restful.Request, resp *restful.Response) { } func GetConsoleLog(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") res, err := devops.GetConsoleLog(projectName, pipelineName, req.Request) if err != nil { @@ -361,8 +361,8 @@ func GetConsoleLog(req *restful.Request, resp *restful.Response) { } func ScanBranch(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") res, err := devops.ScanBranch(projectName, pipelineName, req.Request) if err != nil { @@ -374,9 +374,9 @@ func ScanBranch(req *restful.Request, resp *restful.Response) { } func RunBranchPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") res, err := devops.RunBranchPipeline(projectName, pipelineName, branchName, req.Request) if err != nil { @@ -389,8 +389,8 @@ func RunBranchPipeline(req *restful.Request, resp *restful.Response) { } func RunPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") res, err := devops.RunPipeline(projectName, pipelineName, req.Request) if err != nil { @@ -402,39 +402,6 @@ func RunPipeline(req *restful.Request, resp *restful.Response) { resp.Write(res) } -func GetBranchStepsStatus(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - - res, err := devops.GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId, req.Request) - if err != nil { - parseErr(err, resp) - return - } - - resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON) - resp.Write(res) -} - -func GetStepsStatus(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") - - res, err := devops.GetStepsStatus(projectName, pipelineName, runId, nodeId, req.Request) - if err != nil { - parseErr(err, resp) - return - } - - resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON) - resp.Write(res) -} - func GetCrumb(req *restful.Request, resp *restful.Response) { res, err := devops.GetCrumb(req.Request) if err != nil { @@ -482,9 +449,9 @@ func CheckCron(req *restful.Request, resp *restful.Response) { } func GetPipelineRun(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.GetPipelineRun(projectName, pipelineName, runId, req.Request) if err != nil { @@ -497,9 +464,9 @@ func GetPipelineRun(req *restful.Request, resp *restful.Response) { } func GetBranchPipeline(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") res, err := devops.GetBranchPipeline(projectName, pipelineName, branchName, req.Request) if err != nil { @@ -512,9 +479,9 @@ func GetBranchPipeline(req *restful.Request, resp *restful.Response) { } func GetPipelineRunNodes(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.GetPipelineRunNodes(projectName, pipelineName, runId, req.Request) if err != nil { @@ -526,11 +493,11 @@ func GetPipelineRunNodes(req *restful.Request, resp *restful.Response) { } func GetBranchNodeSteps(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") res, err := devops.GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId, req.Request) if err != nil { @@ -542,10 +509,10 @@ func GetBranchNodeSteps(req *restful.Request, resp *restful.Response) { } func GetNodeSteps(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") - nodeId := req.PathParameter("nodeId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") + nodeId := req.PathParameter("node") res, err := devops.GetNodeSteps(projectName, pipelineName, runId, nodeId, req.Request) if err != nil { @@ -603,10 +570,10 @@ func GithubWebhook(req *restful.Request, resp *restful.Response) { } func GetBranchNodesDetail(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - branchName := req.PathParameter("branchName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + branchName := req.PathParameter("branch") + runId := req.PathParameter("run") res, err := devops.GetBranchNodesDetail(projectName, pipelineName, branchName, runId, req.Request) if err != nil { @@ -617,9 +584,9 @@ func GetBranchNodesDetail(req *restful.Request, resp *restful.Response) { } func GetNodesDetail(req *restful.Request, resp *restful.Response) { - projectName := req.PathParameter("projectName") - pipelineName := req.PathParameter("pipelineName") - runId := req.PathParameter("runId") + projectName := req.PathParameter("devops") + pipelineName := req.PathParameter("pipeline") + runId := req.PathParameter("run") res, err := devops.GetNodesDetail(projectName, pipelineName, runId, req.Request) if err != nil { diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index bad0c3f87..308e86cc8 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -138,6 +138,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId) log.Info("Jenkins-url: " + baseUrl) + req.Method = http.MethodPut resBody, err := sendJenkinsRequest(baseUrl, req) if err != nil { log.Error(err) @@ -177,6 +178,7 @@ func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req baseUrl := fmt.Sprintf(jenkins.Server+StopBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId) log.Info("Jenkins-url: " + baseUrl) + req.Method = http.MethodPut res, err := sendJenkinsRequest(baseUrl, req) if err != nil { log.Error(err) @@ -190,6 +192,7 @@ func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([ baseUrl := fmt.Sprintf(jenkins.Server+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId) log.Info("Jenkins-url: " + baseUrl) + req.Method = http.MethodPut res, err := sendJenkinsRequest(baseUrl, req) if err != nil { log.Error(err) @@ -368,32 +371,6 @@ func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, e return res, err } -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.Info("Jenkins-url: " + baseUrl) - - res, err := sendJenkinsRequest(baseUrl, req) - if err != nil { - log.Error(err) - return nil, err - } - - return res, err -} - -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.Info("Jenkins-url: " + baseUrl) - - res, err := sendJenkinsRequest(baseUrl, req) - if err != nil { - log.Error(err) - return nil, err - } - - return res, err -} - func GetCrumb(req *http.Request) ([]byte, error) { baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl) log.Info("Jenkins-url: " + baseUrl) diff --git a/pkg/models/devops/urlconfig.go b/pkg/models/devops/urlconfig.go index 05a9355eb..5255040c3 100644 --- a/pkg/models/devops/urlconfig.go +++ b/pkg/models/devops/urlconfig.go @@ -40,10 +40,6 @@ const ( ReplayPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/replay/" GetBranchArtifactsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/artifacts/?" GetArtifactsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/artifacts/?" - GetBranchStepsStatusUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?" - - GetStepsStatusUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/?" - CheckBranchPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/%s/" CheckPipelineUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/runs/%s/nodes/%s/steps/%s/" GetBranchNodeStepsUrl = "/blue/rest/organizations/jenkins/pipelines/%s/pipelines/%s/branches/%s/runs/%s/nodes/%s/steps/?"