Skip to content

Commit

Permalink
chore: add context in interactive message (scaleway#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Jun 9, 2020
1 parent 536c364 commit c77742f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/namespaces/autocomplete/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func InstallCommandRun(ctx context.Context, argsI interface{}) (i interface{}, e
defaultShellName := filepath.Base(os.Getenv("SHELL"))

promptedShell, err := interactive.PromptStringWithConfig(&interactive.PromptStringConfig{
Ctx: ctx,
Prompt: "What type of shell are you using",
DefaultValue: defaultShellName,
DefaultValueDoc: defaultShellName,
Expand Down Expand Up @@ -206,6 +207,7 @@ func InstallCommandRun(ctx context.Context, argsI interface{}) (i interface{}, e
// Early exit if user disagrees
_, _ = interactive.Println()
continueInstallation, err := interactive.PromptBoolWithConfig(&interactive.PromptBoolConfig{
Ctx: ctx,
Prompt: fmt.Sprintf("Do you want to proceed with these changes?"),
DefaultValue: true,
})
Expand Down
5 changes: 3 additions & 2 deletions internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ func serverTerminateCommand() *core.Command {
return nil, err
}

deleteBlockVolumes, err := shouldDeleteBlockVolumes(server, terminateServerArgs.WithBlock)
deleteBlockVolumes, err := shouldDeleteBlockVolumes(ctx, server, terminateServerArgs.WithBlock)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -960,7 +960,7 @@ func serverTerminateCommand() *core.Command {
}
}

func shouldDeleteBlockVolumes(server *instance.GetServerResponse, terminateWithBlock withBlock) (bool, error) {
func shouldDeleteBlockVolumes(ctx context.Context, server *instance.GetServerResponse, terminateWithBlock withBlock) (bool, error) {
switch terminateWithBlock {
case withBlockTrue:
return true, nil
Expand All @@ -976,6 +976,7 @@ func shouldDeleteBlockVolumes(server *instance.GetServerResponse, terminateWithB
return interactive.PromptBoolWithConfig(&interactive.PromptBoolConfig{
Prompt: "Do you also want to delete block volumes attached to this instance ?",
DefaultValue: false,
Ctx: ctx,
})
}
return false, nil
Expand Down
1 change: 1 addition & 0 deletions internal/namespaces/object/v1/custom_config_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func configInstallCommand() *core.Command {
// Ask whether to remove previous configuration file if it exists
if _, err := os.Stat(configPath); err == nil {
doIt, err := interactive.PromptBoolWithConfig(&interactive.PromptBoolConfig{
Ctx: ctx,
Prompt: "Do you want to overwrite the existing configuration file (" + configPath + ")?",
DefaultValue: false,
})
Expand Down

0 comments on commit c77742f

Please sign in to comment.