Skip to content

Commit

Permalink
Merge branch 'master' into subacc-tech-access
Browse files Browse the repository at this point in the history
# Conflicts:
#	internal/cmd/broker/delete_broker.go
#	internal/cmd/broker/delete_broker_test.go
#	internal/cmd/broker/register_broker.go
#	internal/cmd/label/label.go
#	internal/cmd/label/label_test.go
#	internal/cmd/offering/list_offerings_test.go
#	internal/cmd/platform/delete_platform.go
#	internal/cmd/platform/delete_platform_test.go
#	internal/cmd/visibility/delete_visibility_test.go
#	pkg/smclient/client.go
#	pkg/smclient/client_test.go
#	pkg/smclient/smclientfakes/fake_client.go
  • Loading branch information
KirilKabakchiev committed Oct 9, 2019
2 parents 2c3d34b + f711cb5 commit 5121b38
Show file tree
Hide file tree
Showing 27 changed files with 915 additions and 338 deletions.
120 changes: 71 additions & 49 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ required = ["gopkg.in/fsnotify.v1"]

[[constraint]]
name = "github.com/Peripli/service-manager"
version = "0.4.3"
branch = "master"

# Refer to issue https://github.com/golang/dep/issues/1799
[[override]]
Expand Down
14 changes: 8 additions & 6 deletions internal/cmd/broker/delete_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import (
"fmt"
"io"
"net/http"
"strings"

"github.com/Peripli/service-manager-cli/internal/output"
"github.com/Peripli/service-manager-cli/pkg/errors"

"github.com/Peripli/service-manager-cli/internal/util"

"github.com/spf13/cobra"

"github.com/Peripli/service-manager-cli/internal/cmd"
Expand Down Expand Up @@ -59,12 +62,11 @@ func (dbc *DeleteBrokerCmd) Validate(args []string) error {
// Run runs the command's logic
func (dbc *DeleteBrokerCmd) Run() error {
dbc.Parameters.FieldQuery = append(dbc.Parameters.FieldQuery, fmt.Sprintf("name = %s", dbc.name))

err := dbc.Client.DeleteBrokers(&dbc.Parameters)
if respErr, ok := err.(errors.ResponseError); ok && respErr.StatusCode == http.StatusNotFound {
output.PrintMessage(dbc.Output, "Service Broker(s) not found.\n")
return nil
} else if err != nil {
if err := dbc.Client.DeleteBrokers(&dbc.Parameters); err != nil {
if strings.Contains(err.Error(), "StatusCode: 404") {
output.PrintMessage(dbc.Output, "Service Broker(s) not found.\n")
return nil
}
output.PrintMessage(dbc.Output, "Could not delete broker(s). Reason: ")
return err
}
Expand Down
9 changes: 6 additions & 3 deletions internal/cmd/broker/delete_broker_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package broker

import (
"github.com/Peripli/service-manager/pkg/util"
"io/ioutil"
"net/http"
"testing"

Expand All @@ -10,7 +12,6 @@ import (
"bytes"

"github.com/Peripli/service-manager-cli/internal/cmd"
"github.com/Peripli/service-manager-cli/pkg/errors"
"github.com/Peripli/service-manager-cli/pkg/smclient/smclientfakes"
"github.com/Peripli/service-manager-cli/pkg/types"
)
Expand Down Expand Up @@ -92,7 +93,8 @@ var _ = Describe("Delete brokers command test", func() {

Context("when non-existing brokers are being deleted", func() {
It("should return message", func() {
expectedError := errors.ResponseError{StatusCode: http.StatusNotFound}
body := ioutil.NopCloser(bytes.NewReader([]byte("")))
expectedError := util.HandleResponseError(&http.Response{Body: body, StatusCode: http.StatusNotFound})
client.DeleteBrokersReturns(expectedError)
err := executeWithArgs([]string{"non-existing-name", "-f"})

Expand All @@ -103,7 +105,8 @@ var _ = Describe("Delete brokers command test", func() {

Context("when SM returns error", func() {
It("should return error message", func() {
expectedError := errors.ResponseError{StatusCode: http.StatusInternalServerError}
body := ioutil.NopCloser(bytes.NewReader([]byte("")))
expectedError := util.HandleResponseError(&http.Response{Body: body, StatusCode: http.StatusInternalServerError})
client.DeleteBrokersReturns(expectedError)
err := executeWithArgs([]string{"name", "-f"})

Expand Down
Loading

0 comments on commit 5121b38

Please sign in to comment.