Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprovision.go #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions internal/cmd/instance/deprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewDeprovisionCmd(context *cmd.Context, input io.Reader) *DeprovisionCmd {
// Validate validates command's arguments
func (dbc *DeprovisionCmd) Validate(args []string) error {
if len(args) != 1 {
return fmt.Errorf("single [name] is required")
return fmt.Errorf("Only single [name] is allowed.")
}

dbc.name = args[0]
Expand All @@ -69,11 +69,11 @@ func (dbc *DeprovisionCmd) Run() error {
return err
}
if len(toDeprovision.ServiceInstances) < 1 {
output.PrintMessage(dbc.Output, "Service Instance not found.\n")
output.PrintMessage(dbc.Output, "Service instance not found.\n")
return nil
}
if len(toDeprovision.ServiceInstances) > 1 {
return fmt.Errorf("more than one service instance with name %s found. Use --id flag to specify id of the instance to be deleted", dbc.name)
return fmt.Errorf("More than one service instance with the specified name %s was found. Use --id flag to specify the ID of service instance you want to delete.", dbc.name)
}
dbc.id = toDeprovision.ServiceInstances[0].ID
}
Expand All @@ -85,14 +85,14 @@ func (dbc *DeprovisionCmd) Run() error {
}
location, err := dbc.Client.Deprovision(dbc.id, &dbc.Parameters)
if err != nil {
output.PrintMessage(dbc.Output, "Could not delete service instance. Reason: ")
output.PrintMessage(dbc.Output, "Could not delete the service instance. Reason: ")
return err
}
if len(location) != 0 {
cmd.CommonHandleAsyncExecution(dbc.Context, location, fmt.Sprintf("Service Instance %s successfully scheduled for deletion. To see status of the operation use:\n", dbc.name))
cmd.CommonHandleAsyncExecution(dbc.Context, location, fmt.Sprintf("Service instance %s successfully scheduled for deletion. To see the current status, use:\n", dbc.name))
return nil
}
output.PrintMessage(dbc.Output, "Service Instance successfully deleted.\n")
output.PrintMessage(dbc.Output, "Service instance successfully deleted.\n")
return nil
}

Expand All @@ -104,7 +104,7 @@ func (dbc *DeprovisionCmd) HideUsage() bool {
// AskForConfirmation asks the user to confirm deletion
func (dbc *DeprovisionCmd) AskForConfirmation() (bool, error) {
if !dbc.force {
message := fmt.Sprintf("Do you really want to delete instance with name [%s] (Y/n): ", dbc.name)
message := fmt.Sprintf("Do you really want to delete the instance with name [%s]? (y/n): ", dbc.name)
return cmd.CommonConfirmationPrompt(message, dbc.Context, dbc.input)
}
return true, nil
Expand All @@ -119,17 +119,17 @@ func (dbc *DeprovisionCmd) PrintDeclineMessage() {
func (dbc *DeprovisionCmd) Prepare(prepare cmd.PrepareFunc) *cobra.Command {
result := &cobra.Command{
Use: "deprovision [name]",
Short: "Deletes service instance",
Long: `Deletes service instance by name.`,
Short: "Deletes a service instance.",
Long: `Deletes service instance by the specified name. If more than one instance with the same name exists, use the --id flag instead.`,
PreRunE: prepare(dbc, dbc.Context),
RunE: cmd.RunE(dbc),
}

forceUsage := "Use this parameter to delete a resource without raising a confirmation message."
forceDeleteUsage := "Delete the service instance and all of its associated resources from the database, including all its service bindings. Use this parameter if the service instance cannot be properly deleted. This parameter can only be used by operators with technical access."
forceUsage := "Deletes a resource without a preconditioned confirmation message."
forceDeleteUsage := "Delete the service instance and all its associated resources from the database, including its service bindings. Use this parameter if the service instance cannot be properly deleted. Operators can only use this parameter with technical access."
result.Flags().BoolVarP(&dbc.force, "force", "f", false, forceUsage)
result.Flags().BoolVarP(&dbc.forceDelete, "force-delete", "", false, forceDeleteUsage)
result.Flags().StringVarP(&dbc.id, "id", "", "", "ID of the service instance. Required when name is ambiguous.")
result.Flags().StringVarP(&dbc.id, "id", "", "", "ID of the service instance. Required when service instance name is ambiguous.")
cmd.AddCommonQueryFlag(result.Flags(), &dbc.Parameters)
cmd.AddModeFlag(result.Flags(), "async")

Expand Down