mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 21:54:54 +08:00
add force flag to host/node delete (#2548)
* add force flag to host/node delete * review comments --------- Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com>
This commit is contained in:
parent
5074e56e6a
commit
823182cf09
4 changed files with 12 additions and 6 deletions
|
@ -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,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")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue