From c7b92c378fa194607d94631908c90f8963f44c2f Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Sat, 8 Aug 2020 16:24:43 +0300 Subject: [PATCH 1/6] adding skip-confirmation flag to move config Signed-off-by: Dinor Geler --- cmd/move_config.go | 15 ++++++++++----- completion.yaml | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/move_config.go b/cmd/move_config.go index fd08725..9b0a24d 100644 --- a/cmd/move_config.go +++ b/cmd/move_config.go @@ -41,7 +41,7 @@ func newMoveConfigCmd(out io.Writer) *cobra.Command { flags := cmd.Flags() settings.AddBaseFlags(flags) - + flags.BoolVar(&skipConfirmation, "skip-confirmation", false, "if set, skips confirmation message before performing move") return cmd } @@ -55,6 +55,9 @@ func runMove(cmd *cobra.Command, args []string) error { return Move(settings.DryRun) } +var err error +var doCleanup bool + // Moves/copies v2 configuration to v2 configuration. It copies repository config, // plugins and starters. It does not copy cache. func Move(dryRun bool) error { @@ -66,12 +69,14 @@ func Move(dryRun bool) error { log.Println("WARNING: Helm v3 configuration may be overwritten during this operation.") log.Println() - doCleanup, err := utils.AskConfirmation("Move Config", "move the v2 configuration") - if err != nil { - return err + if skipConfirmation { + log.Println("Skipping confirmation before performing move.") + doCleanup = true + } else { + doCleanup, err = utils.AskConfirmation("Move Config", "move the v2 configuration") } if !doCleanup { - log.Println("Move configuration will not proceed as the user didn't answer (Y|y) in order to continue.") + log.Println("Move will not proceed as the user didn't answer (Y|y) in order to continue.") return nil } diff --git a/completion.yaml b/completion.yaml index b01cdc1..cf8a59d 100644 --- a/completion.yaml +++ b/completion.yaml @@ -31,3 +31,4 @@ commands: - name: config flags: - dry-run + - skip-confirmation From 0adad7dca178877fc79071ad814a7271542ef9c7 Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Sun, 9 Aug 2020 11:32:46 +0300 Subject: [PATCH 2/6] Adding fixes for move config command Signed-off-by: Dinor Geler --- cmd/move_config.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/move_config.go b/cmd/move_config.go index 9b0a24d..e7eb315 100644 --- a/cmd/move_config.go +++ b/cmd/move_config.go @@ -55,12 +55,11 @@ func runMove(cmd *cobra.Command, args []string) error { return Move(settings.DryRun) } -var err error -var doCleanup bool - // Moves/copies v2 configuration to v2 configuration. It copies repository config, // plugins and starters. It does not copy cache. func Move(dryRun bool) error { + var err error + var doCleanup bool if dryRun { log.Println("NOTE: This is in dry-run mode, the following actions will not be executed.") log.Println("Run without --dry-run to take the actions described below:") @@ -70,10 +69,14 @@ func Move(dryRun bool) error { log.Println("WARNING: Helm v3 configuration may be overwritten during this operation.") log.Println() if skipConfirmation { + log.Println("Skipping confirmation before performing move.") doCleanup = true } else { doCleanup, err = utils.AskConfirmation("Move Config", "move the v2 configuration") + if err != nil { + return err + } } if !doCleanup { log.Println("Move will not proceed as the user didn't answer (Y|y) in order to continue.") From ab5f4687bb53c18d15f547df0483f51b310bdec8 Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Tue, 11 Aug 2020 16:59:51 +0300 Subject: [PATCH 3/6] cosmetics Signed-off-by: Dinor Geler --- README.md | 1 + cmd/move_config.go | 8 ++++---- plugin.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7deb1cd..a19d488 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ $ helm 2to3 move config [flags] Flags: --dry-run simulate a command + --skip-confirmation if set, skips confirmation message before performing move -h, --help help for move ``` diff --git a/cmd/move_config.go b/cmd/move_config.go index e7eb315..c21fdac 100644 --- a/cmd/move_config.go +++ b/cmd/move_config.go @@ -59,7 +59,7 @@ func runMove(cmd *cobra.Command, args []string) error { // plugins and starters. It does not copy cache. func Move(dryRun bool) error { var err error - var doCleanup bool + var doConfig bool if dryRun { log.Println("NOTE: This is in dry-run mode, the following actions will not be executed.") log.Println("Run without --dry-run to take the actions described below:") @@ -71,14 +71,14 @@ func Move(dryRun bool) error { if skipConfirmation { log.Println("Skipping confirmation before performing move.") - doCleanup = true + doConfig = true } else { - doCleanup, err = utils.AskConfirmation("Move Config", "move the v2 configuration") + doConfig, err = utils.AskConfirmation("Move Config", "move the v2 configuration") if err != nil { return err } } - if !doCleanup { + if !doConfig { log.Println("Move will not proceed as the user didn't answer (Y|y) in order to continue.") return nil } diff --git a/plugin.yaml b/plugin.yaml index d610e9f..4a51dba 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: "2to3" -version: "0.6.0" +version: "0.7.0" usage: "migrate and cleanup Helm v2 configuration and releases in-place to Helm v3" description: "migrate and cleanup Helm v2 configuration and releases in-place to Helm v3" command: "$HELM_PLUGIN_DIR/bin/2to3" From c5aa32e1ff9feedfde3d0fbcab3d285a81484c6c Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Sun, 6 Sep 2020 10:08:13 +0300 Subject: [PATCH 4/6] aligned flags Signed-off-by: Dinor Geler --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a19d488..2a91b2b 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ $ helm 2to3 move config [flags] Flags: --dry-run simulate a command - --skip-confirmation if set, skips confirmation message before performing move + --skip-confirmation if set, skips confirmation message before performing move -h, --help help for move ``` From fe9b374a476dfa23e78a984da1f1e6c00c4c40c8 Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Sun, 6 Sep 2020 10:09:31 +0300 Subject: [PATCH 5/6] aligned flags Signed-off-by: Dinor Geler From 62b6688a19f6d69bbb096c01b5945d6f8164fba9 Mon Sep 17 00:00:00 2001 From: Dinor Geler Date: Sat, 19 Sep 2020 17:34:37 +0300 Subject: [PATCH 6/6] semantic error fixing Signed-off-by: Dinor Geler --- cmd/move_config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/move_config.go b/cmd/move_config.go index c21fdac..944f947 100644 --- a/cmd/move_config.go +++ b/cmd/move_config.go @@ -70,10 +70,10 @@ func Move(dryRun bool) error { log.Println() if skipConfirmation { - log.Println("Skipping confirmation before performing move.") + log.Println("Skipping confirmation before performing move configuration.") doConfig = true } else { - doConfig, err = utils.AskConfirmation("Move Config", "move the v2 configuration") + doConfig, err = utils.AskConfirmation("Move config", "move the v2 configuration") if err != nil { return err }