This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pipelines doesnt get deleted while removing a space which leaves dangling pipelines in OpenShift. This patch deletes the pipelines while removing a space Patch adds - REST API to delete pipeline by space label - Test cases for delete pipeline(buildconfig) function - Delete BuildConfig API in OpenShift client - Test cases for delete BuildConfig API - Refactors kubernetes_client to get client objects - Fixes delete OpenShift resources tests Fixes -openshiftio/openshift.io#3802
- Loading branch information
Showing
15 changed files
with
970 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package controller | ||
|
||
import ( | ||
"github.com/goadesign/goa" | ||
errs "github.com/pkg/errors" | ||
"github.com/fabric8-services/fabric8-wit/configuration" | ||
"github.com/fabric8-services/fabric8-wit/app" | ||
"github.com/fabric8-services/fabric8-wit/jsonapi" | ||
"github.com/fabric8-services/fabric8-wit/log" | ||
"github.com/fabric8-services/fabric8-wit/errors" | ||
) | ||
|
||
// pipeline implements the pipeline resource. | ||
type PipelinesController struct { | ||
*goa.Controller | ||
Config *configuration.Registry | ||
ClientGetter | ||
} | ||
|
||
func NewPipelineController(service *goa.Service, config *configuration.Registry) *PipelinesController { | ||
return &PipelinesController{ | ||
Controller: service.NewController("PipelinesController"), | ||
Config: config, | ||
ClientGetter: &defaultClientGetter{ | ||
config: config, | ||
}, | ||
} | ||
} | ||
|
||
// Delete a pipelines from given space | ||
func (c *PipelinesController) Delete(ctx *app.DeletePipelinesContext) error { | ||
|
||
osioClient, err := c.GetAndCheckOSIOClient(ctx) | ||
if err != nil { | ||
return jsonapi.JSONErrorResponse(ctx, err) | ||
} | ||
|
||
k8sSpace, err := osioClient.GetNamespaceByType(ctx, nil, "user") | ||
if err != nil { | ||
return jsonapi.JSONErrorResponse(ctx, errs.Wrap(err, "unable to retrieve 'user' namespace")) | ||
} | ||
if k8sSpace == nil { | ||
return jsonapi.JSONErrorResponse(ctx, errors.NewNotFoundError("namespace", "user")) | ||
} | ||
|
||
osc, err := c.GetOSClient(ctx) | ||
if err != nil { | ||
return jsonapi.JSONErrorResponse(ctx, err) | ||
} | ||
|
||
userNS := *k8sSpace.Name | ||
resp, err := osc.DeleteBuildConfig(userNS, map[string]string{"space": ctx.Space}) | ||
if err != nil { | ||
log.Error(ctx, map[string]interface{}{ | ||
"err": err, | ||
"space_name": ctx.Space, | ||
}, "error occurred while deleting pipeline") | ||
return jsonapi.JSONErrorResponse(ctx, err) | ||
} | ||
|
||
log.Info(ctx, map[string]interface{}{"response": resp}, "deleted pipelines :") | ||
|
||
return ctx.OK([]byte{}) | ||
} |
Oops, something went wrong.