diff --git a/pkg/apiserver/devops/member.go b/pkg/apiserver/devops/member.go index 382bafd3f..8e1479367 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 630fd8eb1..bf487b968 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 a40d07b08..157379840 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 3e0460151..8d8c08a09 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 2721f1651..2419945e3 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 05dae0a54..cbce69e31 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 f8b81c03e..877151c17 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 4d3710ec1..36c614b74 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 de55e52f6..066b17429 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 4dc6c7a67..575afdaf5 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 cde8e0e1a..8ce5fe510 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 b775f023a..1b82193cf 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 cdd7ac184..d5f013f43 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 516d2d7a1..0af6d9e67 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 9609af0fe..cd147b5ba 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 (