Skip to content

Commit

Permalink
Add behavior to print deleted instance name (openshift#1806)
Browse files Browse the repository at this point in the history
* Add behavior to print deleted instance name

1.) Slight refactor to output to make the method that prints deleted resource names
    more generic
2.) Added conditional to cmd/svcat/instance/deprovision_cmd.go to print deleted instance
    on success
3.) Updated README.md to convert the sample deprovision command to a console block with output

Closes: openshift#1805

* Missed refactor of parameter name in WriteDeletedResourceName refactor
  • Loading branch information
jeremyrickard authored and carolynvs committed Mar 13, 2018
1 parent 55505be commit 712dd4a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/svcat/binding/unbind_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *unbindCmd) Run() error {
func (c *unbindCmd) deleteBinding() error {
err := c.App.DeleteBinding(c.ns, c.bindingName)
if err == nil {
output.WriteDeletedBindingName(c.Output, c.bindingName)
output.WriteDeletedResourceName(c.Output, c.bindingName)
}
return err
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/svcat/instance/deprovision_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package instance

import (
"fmt"
"github.com/kubernetes-incubator/service-catalog/cmd/svcat/output"

"github.com/kubernetes-incubator/service-catalog/cmd/svcat/command"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -60,5 +61,9 @@ func (c *deprovisonCmd) Run() error {
}

func (c *deprovisonCmd) deprovision() error {
return c.App.Deprovision(c.ns, c.instanceName)
err := c.App.Deprovision(c.ns, c.instanceName)
if err == nil {
output.WriteDeletedResourceName(c.Output, c.instanceName)
}
return err
}
7 changes: 1 addition & 6 deletions cmd/svcat/output/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ func WriteAssociatedBindings(w io.Writer, bindings []v1beta1.ServiceBinding) {
// WriteDeletedBindingNames prints the names of a list of bindings
func WriteDeletedBindingNames(w io.Writer, bindings []v1beta1.ServiceBinding) {
for _, binding := range bindings {
WriteDeletedBindingName(w, binding.Name)
WriteDeletedResourceName(w, binding.Name)
}
}

// WriteDeletedBindingName prints the name of a binding
func WriteDeletedBindingName(w io.Writer, bindingName string) {
fmt.Fprintf(w, "deleted %s\n", bindingName)
}
6 changes: 6 additions & 0 deletions cmd/svcat/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package output

import (
"fmt"
"io"
"strings"

"github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1"
Expand Down Expand Up @@ -45,3 +46,8 @@ func formatStatusFull(condition string, conditionStatus v1beta1.ConditionStatus,
message = strings.TrimRight(message, ".")
return fmt.Sprintf("%s - %s @ %s", status, message, timestamp.UTC())
}

// WriteDeletedResourceName prints the name of a deleted resource
func WriteDeletedResourceName(w io.Writer, resourceName string) {
fmt.Fprintf(w, "deleted %s\n", resourceName)
}
5 changes: 3 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ deleted ups-binding
Deprovisioning is the process of preparing an instance to be removed, and then deleting it.
You must unbind delete all bindings before deprovisioning an instance.

```
svcat deprovision ups-instance
```console
$ svcat deprovision ups-instance
deleted ups-instance
```

0 comments on commit 712dd4a

Please sign in to comment.