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

add force flag to host/node delete #2548

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion cli/cmd/host/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import (
"github.com/spf13/cobra"
)

var force bool

var hostDeleteCmd = &cobra.Command{
Use: "delete HostID",
Args: cobra.ExactArgs(1),
Short: "Delete a host",
Long: `Delete a host`,
Run: func(cmd *cobra.Command, args []string) {
functions.PrettyPrint(functions.DeleteHost(args[0]))
functions.PrettyPrint(functions.DeleteHost(args[0], force))
},
}

func init() {
rootCmd.AddCommand(hostDeleteCmd)
hostDeleteCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "delete even if part of network(s)")
}
5 changes: 4 additions & 1 deletion cli/cmd/node/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import (
"github.com/spf13/cobra"
)

var force bool

var nodeDeleteCmd = &cobra.Command{
Use: "delete [NETWORK NAME] [NODE ID]",
Args: cobra.ExactArgs(2),
Short: "Delete a Node",
Long: `Delete a Node`,
Run: func(cmd *cobra.Command, args []string) {
functions.PrettyPrint(functions.DeleteNode(args[0], args[1]))
functions.PrettyPrint(functions.DeleteNode(args[0], args[1], force))
},
}

func init() {
rootCmd.AddCommand(nodeDeleteCmd)
nodeDeleteCmd.PersistentFlags().BoolVarP(&force, "force", "f", false, "force delete a node")
}
4 changes: 2 additions & 2 deletions cli/functions/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func GetHosts() *[]models.ApiHost {
}

// DeleteHost - delete a host
func DeleteHost(hostID string) *models.ApiHost {
return request[models.ApiHost](http.MethodDelete, "/api/hosts/"+hostID, nil)
func DeleteHost(hostID string, force bool) *models.ApiHost {
return request[models.ApiHost](http.MethodDelete, fmt.Sprintf("/api/hosts/%s?force=%t", hostID, force), nil)
}

// UpdateHost - update a host
Expand Down
4 changes: 2 additions & 2 deletions cli/functions/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func UpdateNode(networkName, nodeID string, node *models.ApiNode) *models.ApiNod
}

// DeleteNode - delete a node
func DeleteNode(networkName, nodeID string) *models.SuccessResponse {
return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s", networkName, nodeID), nil)
func DeleteNode(networkName, nodeID string, force bool) *models.SuccessResponse {
return request[models.SuccessResponse](http.MethodDelete, fmt.Sprintf("/api/nodes/%s/%s?force=%t", networkName, nodeID, force), nil)
}

// CreateEgress - turn a node into an egress
Expand Down