MCPcopy
hub / github.com/docker/compose / promptForInterpolatedVariables

Function promptForInterpolatedVariables

cmd/compose/options.go:129–158  ·  cmd/compose/options.go::promptForInterpolatedVariables

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)

Source from the content-addressed store, hash-verified

127// promptForInterpolatedVariables displays all variables and their values at once,
128// then prompts for confirmation
129func 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
160func extractInterpolationVariablesFromModel(ctx context.Context, dockerCli command.Cli, projectOptions *ProjectOptions, cmdEnvs []string) ([]varInfo, bool, error) {
161 cmdEnvMap := extractEnvCLIDefined(cmdEnvs)

Callers 1

checksForRemoteStackFunction · 0.85

Calls 6

NewPromptFunction · 0.92
ConfirmMethod · 0.65
OutMethod · 0.45
InMethod · 0.45

Tested by

no test coverage detected