diff --git a/pkg/apiserver/devops/member.go b/pkg/apiserver/devops/member.go index 382bafd3f66ed01e6fa1a21fa02e9696d62173bc..8e14793679f2ec09d9acc16a6118c8b5ee8ed907 100644 --- a/pkg/apiserver/devops/member.go +++ b/pkg/apiserver/devops/member.go @@ -1,3 +1,17 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + package devops import ( @@ -13,18 +27,6 @@ import ( "net/http" ) -/* -Copyright 2018 The KubeSphere Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ func GetDevOpsProjectMembersHandler(request *restful.Request, resp *restful.Response) { diff --git a/pkg/apiserver/devops/project.go b/pkg/apiserver/devops/project.go index 630fd8eb1d7c6468baea3f8299a351cf20c939c1..bf487b96889f06e2bf748dab99734002d21129c5 100644 --- a/pkg/apiserver/devops/project.go +++ b/pkg/apiserver/devops/project.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/apiserver/devops/project_credential.go b/pkg/apiserver/devops/project_credential.go index a40d07b085b95196af5a3aa161d9dfa5e7ceb596..157379840ce36af272da99794b0c4c03545591dc 100644 --- a/pkg/apiserver/devops/project_credential.go +++ b/pkg/apiserver/devops/project_credential.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/apiserver/devops/project_pipeline.go b/pkg/apiserver/devops/project_pipeline.go index 3e04601512bbd27a38cd2002d03930fe6e947054..8d8c08a0969695c7c7406a9c1e9d235262ae6fa0 100644 --- a/pkg/apiserver/devops/project_pipeline.go +++ b/pkg/apiserver/devops/project_pipeline.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/common.go b/pkg/models/devops/common.go index 2721f165163551f011a3e4b784fe241d5044ba0a..2419945e3f56d9c9bf200d2da1389a152acae4e1 100644 --- a/pkg/models/devops/common.go +++ b/pkg/models/devops/common.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/membership.go b/pkg/models/devops/membership.go index 05dae0a54f3acdec760a909d30712d6419aae4ed..cbce69e31a4370b9f562cb3c0990fcc038fd777d 100644 --- a/pkg/models/devops/membership.go +++ b/pkg/models/devops/membership.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops const ( diff --git a/pkg/models/devops/project.go b/pkg/models/devops/project.go index f8b81c03e218af656fa1d0949df1ff294805ef16..877151c1702cd7cf83abd7f47e644f741490a3bd 100644 --- a/pkg/models/devops/project.go +++ b/pkg/models/devops/project.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_credential.go b/pkg/models/devops/project_credential.go index 4d3710ec118656a0bc5962180cc9e3395ea1e446..36c614b7419cd1c8c2736c2f638bfe0967def2b0 100644 --- a/pkg/models/devops/project_credential.go +++ b/pkg/models/devops/project_credential.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_credential_handler.go b/pkg/models/devops/project_credential_handler.go index de55e52f6dd5f9e301b0fe3484a2ec99f195e72d..066b1742901a840fbfcb3770ece8383d4031b50a 100644 --- a/pkg/models/devops/project_credential_handler.go +++ b/pkg/models/devops/project_credential_handler.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_handler.go b/pkg/models/devops/project_handler.go index 4dc6c7a67418efe092f5af98b513911e26d6a169..575afdaf5439a71aff85cf8cf08b94bf1f4bccb1 100644 --- a/pkg/models/devops/project_handler.go +++ b/pkg/models/devops/project_handler.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_member_handler.go b/pkg/models/devops/project_member_handler.go index cde8e0e1affafab0f7ac3ccf50305b88f420c0e9..8ce5fe5103634615829f95536fed717716f6b984 100644 --- a/pkg/models/devops/project_member_handler.go +++ b/pkg/models/devops/project_member_handler.go @@ -1,3 +1,15 @@ +/* +Copyright 2018 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package devops import ( @@ -16,18 +28,7 @@ import ( "kubesphere.io/kubesphere/pkg/simple/client/devops_mysql" ) -/* -Copyright 2018 The KubeSphere Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ + func GetProjectMembers(projectId string, conditions *params.Conditions, orderBy string, reverse bool, limit int, offset int) (*models.PageableResponse, error) { dbconn := devops_mysql.OpenDatabase() @@ -111,6 +112,7 @@ func AddProjectMember(projectId, operator string, member *DevOpsProjectMembershi glog.Errorf("%+v", err) return nil, restful.NewError(http.StatusInternalServerError, err.Error()) } + // if user could be founded in db, user have been added to project if err != db.ErrNotFound { err = fmt.Errorf("user [%s] have been added to project", member.Username) glog.Errorf("%+v", err) @@ -163,6 +165,16 @@ func AddProjectMember(projectId, operator string, member *DevOpsProjectMembershi Record(projectMembership).Exec() if err != nil { glog.Errorf("%+v", err) + err = projectRole.UnAssignRole(member.Username) + if err != nil { + glog.Errorf("%+v", err) + return nil, restful.NewError(utils.GetJenkinsStatusCode(err), err.Error()) + } + err = pipelineRole.UnAssignRole(member.Username) + if err != nil { + glog.Errorf("%+v", err) + return nil, restful.NewError(utils.GetJenkinsStatusCode(err), err.Error()) + } return nil, restful.NewError(http.StatusInternalServerError, err.Error()) } return projectMembership, nil diff --git a/pkg/models/devops/project_pipeline.go b/pkg/models/devops/project_pipeline.go index b775f023a7d152364e1d6d8e7944a892efda69e2..1b82193cfb01a20f730e5fbcc43ee22ad9f0a266 100644 --- a/pkg/models/devops/project_pipeline.go +++ b/pkg/models/devops/project_pipeline.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_pipeline_handler.go b/pkg/models/devops/project_pipeline_handler.go index cdd7ac184739050299e5989d2e8f08a07ec48d24..d5f013f43a39a8d7502f5bf50b81fefa884ba2de 100644 --- a/pkg/models/devops/project_pipeline_handler.go +++ b/pkg/models/devops/project_pipeline_handler.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/models/devops/project_pipeline_test.go b/pkg/models/devops/project_pipeline_test.go index 516d2d7a1c5745fa5b8b8ed84869b1fbc6d59146..0af6d9e67e3441b43dd0225bfc6793d42cc1805e 100644 --- a/pkg/models/devops/project_pipeline_test.go +++ b/pkg/models/devops/project_pipeline_test.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package devops import ( diff --git a/pkg/simple/client/admin_jenkins/jenkins.go b/pkg/simple/client/admin_jenkins/jenkins.go index 9609af0feead7714f3637d4c500e9849389aca7b..cd147b5ba8d739cb274625c9667d9284a5f0802a 100644 --- a/pkg/simple/client/admin_jenkins/jenkins.go +++ b/pkg/simple/client/admin_jenkins/jenkins.go @@ -1,3 +1,16 @@ +/* +Copyright 2018 The KubeSphere Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package admin_jenkins import (