From 0e6223b6f8f49d83f678a9f583b38b51cd70058f Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 22 Dec 2022 14:48:58 +0100 Subject: [PATCH 1/4] do not confirm deleting zero nodes close #603 Signed-off-by: Christian Goll --- internal/app/wwctl/node/delete/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/app/wwctl/node/delete/main.go b/internal/app/wwctl/node/delete/main.go index b5a58308..0cf23218 100644 --- a/internal/app/wwctl/node/delete/main.go +++ b/internal/app/wwctl/node/delete/main.go @@ -25,6 +25,9 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { if err != nil { return } + if len(nodeList) == 0 { + return + } yes := util.ConfirmationPrompt(fmt.Sprintf("Are you sure you want to delete %d nodes(s)", len(nodeList))) if !yes { return From 9539e20a4ef27e029faa1dbd6e139cac46296960 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 22 Dec 2022 14:54:42 +0100 Subject: [PATCH 2/4] add `-y` flag to `wwctl profile add` close #610 Signed-off-by: Christian Goll --- internal/app/wwctl/profile/add/root.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/app/wwctl/profile/add/root.go b/internal/app/wwctl/profile/add/root.go index 14694477..e3ad6d24 100644 --- a/internal/app/wwctl/profile/add/root.go +++ b/internal/app/wwctl/profile/add/root.go @@ -58,6 +58,7 @@ func GetCommand() *cobra.Command { }); err != nil { log.Println(err) } + baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked") return baseCmd } From 718064e67145b1decf7b128fcf497efa78a8c55f Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 22 Dec 2022 15:00:12 +0100 Subject: [PATCH 3/4] add confirmation for `wwctl container delete` close #606 Signed-off-by: Christian Goll --- internal/app/wwctl/container/delete/main.go | 11 ++++++++++- internal/app/wwctl/container/delete/root.go | 11 ++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/internal/app/wwctl/container/delete/main.go b/internal/app/wwctl/container/delete/main.go index 0f9c57af..250b5ac2 100644 --- a/internal/app/wwctl/container/delete/main.go +++ b/internal/app/wwctl/container/delete/main.go @@ -1,15 +1,24 @@ package delete import ( + "fmt" + "github.com/hpcng/warewulf/internal/pkg/api/container" "github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1" + "github.com/hpcng/warewulf/internal/pkg/api/util" "github.com/spf13/cobra" ) func CobraRunE(cmd *cobra.Command, args []string) (err error) { - cdp := &wwapiv1.ContainerDeleteParameter{ ContainerNames: args, } + if !SetYes { + yes := util.ConfirmationPrompt(fmt.Sprintf("Are you sure you want to container %s", args)) + if !yes { + return + } + + } return container.ContainerDelete(cdp) } diff --git a/internal/app/wwctl/container/delete/root.go b/internal/app/wwctl/container/delete/root.go index 64e909ba..787353b0 100644 --- a/internal/app/wwctl/container/delete/root.go +++ b/internal/app/wwctl/container/delete/root.go @@ -8,10 +8,10 @@ import ( var ( baseCmd = &cobra.Command{ DisableFlagsInUseLine: true, - Use: "delete [OPTIONS] CONTAINER [...]", - Short: "Delete an imported container", - Long: "This command will delete CONTAINERs that have been imported into Warewulf.", - RunE: CobraRunE, + Use: "delete [OPTIONS] CONTAINER [...]", + Short: "Delete an imported container", + Long: "This command will delete CONTAINERs that have been imported into Warewulf.", + RunE: CobraRunE, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { if len(args) != 0 { return nil, cobra.ShellCompDirectiveNoFileComp @@ -20,10 +20,11 @@ var ( return list, cobra.ShellCompDirectiveNoFileComp }, } + SetYes bool ) func init() { - + baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked") } // GetRootCommand returns the root cobra.Command for the application. From 3baf4f57afc59103db04aaf9c1c5181e0d414f12 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 22 Dec 2022 15:13:19 +0100 Subject: [PATCH 4/4] update to 0.4..4rc3 Signed-off-by: Christian Goll --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8201a0e..e9b6109e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ VARLIST := OS # Project Information VARLIST += WAREWULF VERSION RELEASE WAREWULF ?= warewulf -VERSION ?= 4.4.0rc2 +VERSION ?= 4.4.0rc3 GIT_TAG := $(shell test -e .git && git log -1 --format="%h") ifdef GIT_TAG