Skip to content

Commit b6836f3

Browse files
Correct arguments on ConfirmAction() (#561)
- Use os.Stdin instead of os.Stderr to read user input - Print question using the configured output instead of hardcoded os.Stdout Fixes #560 Signed-off-by: Youhei Sakurai <sakurai.youhei@gmail.com>
1 parent d704fcc commit b6836f3

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

cmd/deployment/resource/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var deleteCmd = &cobra.Command{
3939

4040
force, _ := cmd.Flags().GetBool("force")
4141
var msg = "This action will delete a deployment's resource kind and its configuration history. Do you want to continue? [y/n]: "
42-
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
42+
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
4343
return nil
4444
}
4545

cmd/deployment/resource/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var restoreCmd = &cobra.Command{
4343
var esKind = resKind == "elasticsearch"
4444
var dataLoss = esKind && !restoreSnapshot
4545
var msg = "This action restores an Elasticsearch resource without its snapshot which might incur data loss, do you want to continue? [y/n]: "
46-
if dataLoss && !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
46+
if dataLoss && !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
4747
return nil
4848
}
4949

cmd/deployment/resource/shutdown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var shutdownCmd = &cobra.Command{
4242

4343
force, _ := cmd.Flags().GetBool("force")
4444
var msg = "This action will shut down a deployment's resource kind. Do you want to continue? [y/n]: "
45-
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
45+
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
4646
return nil
4747
}
4848

cmd/deployment/resource/start-maintenance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var startMaintCmd = &cobra.Command{
4747
}
4848

4949
var msg = "This action will incur in downtime if used with the --all flag. Do you want to continue? [y/n]: "
50-
if all && !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
50+
if all && !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
5151
return nil
5252
}
5353

cmd/deployment/resource/stop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var stopCmd = &cobra.Command{
4747
}
4848

4949
var msg = "This action will incur in downtime if used with the --all flag. Do you want to continue? [y/n]: "
50-
if all && !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
50+
if all && !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
5151
return nil
5252
}
5353

cmd/deployment/shutdown.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var shutdownCmd = &cobra.Command{
3535
RunE: func(cmd *cobra.Command, args []string) error {
3636
force, _ := cmd.Flags().GetBool("force")
3737
var msg = "This action will delete the specified deployment ID and its associated sub-resources, do you want to continue? [y/n]: "
38-
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
38+
if !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
3939
return nil
4040
}
4141

cmd/deployment/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var updateCmd = &cobra.Command{
4747

4848
force, _ := cmd.Flags().GetBool("force")
4949
var msg = `setting --prune-orphans to "true" will cause any resources not specified in the update request to be removed from the deployment, do you want to continue? [y/n]: `
50-
if pruneOrphans && !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
50+
if pruneOrphans && !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
5151
return nil
5252
}
5353

cmd/platform/allocator/vacate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var vacateAllocatorCmd = &cobra.Command{
9999
overrideFailsafe, _ := cmd.Flags().GetBool("override-failsafe")
100100
force, _ := cmd.Flags().GetBool("force")
101101
var msg = "--override-failsafe has been flag specified. Are you sure you want to proceed? [y/N]: "
102-
if overrideFailsafe && !force && !sdkcmdutil.ConfirmAction(msg, os.Stderr, os.Stdout) {
102+
if overrideFailsafe && !force && !sdkcmdutil.ConfirmAction(msg, os.Stdin, ecctl.Get().Config.OutputDevice) {
103103
return nil
104104
}
105105

@@ -132,7 +132,7 @@ var vacateAllocatorCmd = &cobra.Command{
132132
}
133133

134134
skipTracking, _ := cmd.Flags().GetBool("skip-tracking")
135-
if !force && skipTracking && !sdkcmdutil.ConfirmAction("--skip-tracking flag specified. Are you sure you want to proceed? [y/N]: ", os.Stdin, os.Stderr) {
135+
if !force && skipTracking && !sdkcmdutil.ConfirmAction("--skip-tracking flag specified. Are you sure you want to proceed? [y/N]: ", os.Stdin, ecctl.Get().Config.OutputDevice) {
136136
return nil
137137
}
138138

0 commit comments

Comments
 (0)