devops project api & devops members api

Signed-off-by: runzexia <runzexia@yunify.com>
This commit is contained in:
runzexia
2019-04-24 21:51:43 +08:00
parent 26c891642d
commit 2ab1ab7b98
10 changed files with 1039 additions and 307 deletions

View File

@@ -1,20 +1,21 @@
/*
Copyright 2019 The KubeSphere Authors.
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package install
import (
@@ -28,6 +29,6 @@ func init() {
Install(runtime.Container)
}
func Install(c *restful.Container) {
urlruntime.Must(devopsv1alpha2.AddToContainer(c))
func Install(container *restful.Container) {
urlruntime.Must(devopsv1alpha2.AddToContainer(container))
}

View File

@@ -15,14 +15,16 @@
limitations under the License.
*/
package v1alpha2
import (
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/devops"
devopsapi "kubesphere.io/kubesphere/pkg/apiserver/devops"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/models/devops"
)
const GroupName = "devops.kubesphere.io"
@@ -35,13 +37,63 @@ var (
)
func addWebService(c *restful.Container) error {
webservice := runtime.NewWebService(GroupVersion)
tags := []string{"devops"}
tags := []string{"DevOps"}
webservice.Route(webservice.GET("/devops/{devops}").
To(devopsapi.GetDevOpsProjectHandler).
Doc("get devops project").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Writes(&devops.DevOpsProject{}))
webservice.Route(webservice.PATCH("/devops/{devops}").
To(devopsapi.UpdateProjectHandler).
Doc("get devops project").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Writes(&devops.DevOpsProject{}))
webservice.Route(webservice.GET("/devops/{devops}/defaultroles").
To(devopsapi.GetDevOpsProjectDefaultRoles).
Doc("get devops project defaultroles").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&devops.DefaultRoles))
webservice.Route(webservice.GET("/devops/{devops}/members").
To(devopsapi.GetDevOpsProjectMembersHandler).
Doc("get devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&[]*devops.DevOpsProjectMembership{}))
webservice.Route(webservice.GET("/devops/{devops}/members/{members}").
To(devopsapi.GetDevOpsProjectMemberHandler).
Doc("get devops project member").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&devops.DevOpsProjectMembership{}))
webservice.Route(webservice.POST("/devops/{devops}/members").
To(devopsapi.AddDevOpsProjectMemberHandler).
Doc("add devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&devops.DevOpsProjectMembership{}))
webservice.Route(webservice.PATCH("/devops/{devops}/members/{members}").
To(devopsapi.UpdateDevOpsProjectMemberHandler).
Doc("update devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&devops.DevOpsProjectMembership{}))
webservice.Route(webservice.DELETE("/devops/{devops}/members/{members}").
To(devopsapi.DeleteDevOpsProjectMemberHandler).
Doc("delete devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&devops.DevOpsProjectMembership{}))
// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}"
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}").
To(devops.GetPipeline).
To(devopsapi.GetPipeline).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get DevOps Pipelines.").
Param(webservice.PathParameter("pipelineName", "pipeline name")).
@@ -49,7 +101,7 @@ func addWebService(c *restful.Container) error {
// match Jenkisn api: "jenkins_api/blue/rest/search"
webservice.Route(webservice.GET("/devops/search").
To(devops.SearchPipelines).
To(devopsapi.SearchPipelines).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Search DevOps resource.").
Param(webservice.QueryParameter("q", "query pipelines").
@@ -67,7 +119,7 @@ func addWebService(c *restful.Container) error {
// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/"
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs").
To(devops.SearchPipelineRuns).
To(devopsapi.SearchPipelineRuns).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Search DevOps Pipelines runs.").
Param(webservice.PathParameter("pipelineName", "pipeline name")).
@@ -81,7 +133,7 @@ func addWebService(c *restful.Container) error {
// 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}").
To(devops.GetPipelineRun).
To(devopsapi.GetPipelineRun).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get DevOps Pipelines run.").
Param(webservice.PathParameter("pipelineName", "pipeline name")).
@@ -91,7 +143,7 @@ func addWebService(c *restful.Container) error {
// 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").
To(devops.GetPipelineRunNodes).
To(devopsapi.GetPipelineRunNodes).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get node on DevOps Pipelines run.").
Param(webservice.PathParameter("projectName", "devops project name")).
@@ -105,7 +157,7 @@ func addWebService(c *restful.Container) error {
// 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").
To(devops.GetStepLog).
To(devopsapi.GetStepLog).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get Pipelines step log.").
Param(webservice.PathParameter("projectName", "devops project name")).
@@ -121,14 +173,14 @@ func addWebService(c *restful.Container) error {
// match "/blue/rest/organizations/jenkins/scm/github/validate/"
webservice.Route(webservice.PUT("/devops/scm/{scmId}/validate").
To(devops.Validate).
To(devopsapi.Validate).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Validate Github personal access token.").
Param(webservice.PathParameter("scmId", "SCM id")))
// match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/?credentialId=github"
webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations").
To(devops.GetOrgSCM).
To(devopsapi.GetOrgSCM).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("List organizations of SCM").
Param(webservice.PathParameter("scmId", "SCM id")).