Fix ApplicationRequestUpdate service binding deletion
@@ -108,7 +108,7 @@ func (hc Controller) Update(c *gin.Context) apierror.APIErrors { // nolint:gocyc
}
}
- if len(updateRequest.Services) > 0 {
+ if updateRequest.Services != nil {
// Take old state
oldBound, err := application.BoundServiceNameSet(ctx, cluster, app.Meta)
if err != nil {
@@ -118,6 +118,7 @@ func (hc Controller) Update(c *gin.Context) apierror.APIErrors { // nolint:gocyc
var theIssues []apierror.APIError
var okToBind []string
+ if len(updateRequest.Services) > 0 {
for _, serviceName := range updateRequest.Services {
_, err := services.Lookup(ctx, cluster, namespace, serviceName)
if err != nil {
@@ -138,6 +139,13 @@ func (hc Controller) Update(c *gin.Context) apierror.APIErrors { // nolint:gocyc
theIssues = append([]apierror.APIError{apierror.InternalError(err)}, theIssues...)
return apierror.NewMultiError(theIssues)
}
+ } else {
+ // remove all bound services
+ err = application.BoundServicesSet(ctx, cluster, app.Meta, []string{}, true)
+ if err != nil {
+ return apierror.InternalError(err)
+ }
+ }
// Restart workload, if any
if app.Workload != nil {
