promptForInterpolatedVariables displays all variables and their values at once, then prompts for confirmation
(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, assumeYes bool, cmdEnvs []string)
| 127 | // promptForInterpolatedVariables displays all variables and their values at once, |
| 128 | // then prompts for confirmation |
| 129 | func promptForInterpolatedVariables(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, assumeYes bool, cmdEnvs []string) error { |
| 130 | if assumeYes { |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | varsInfo, noVariables, err := extractInterpolationVariablesFromModel(ctx, dockerCli, projectOptions, cmdEnvs) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | |
| 139 | if noVariables { |
| 140 | return nil |
| 141 | } |
| 142 | |
| 143 | displayInterpolationVariables(dockerCli.Out(), varsInfo) |
| 144 | |
| 145 | // Prompt for confirmation |
| 146 | userInput := prompt.NewPrompt(dockerCli.In(), dockerCli.Out()) |
| 147 | msg := "\nDo you want to proceed with these variables? [Y/n]: " |
| 148 | confirmed, err := userInput.Confirm(msg, true) |
| 149 | if err != nil { |
| 150 | return err |
| 151 | } |
| 152 | |
| 153 | if !confirmed { |
| 154 | return fmt.Errorf("operation cancelled by user") |
| 155 | } |
| 156 | |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | func extractInterpolationVariablesFromModel(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, cmdEnvs []string) ([]varInfo, bool, error) { |
| 161 | cmdEnvMap := extractEnvCLIDefined(cmdEnvs) |
no test coverage detected