MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / PromptForProxy

Function PromptForProxy

pkg/machinescommon/proxy.go:19–35  ·  view source on GitHub ↗
(opts *CreateTargetProxyOptions, flags *CreateTargetProxyFlags, description string)

Source from the content-addressed store, hash-verified

17type GetAllProxiesCallback func() ([]*proxies.Proxy, error)
18
19func PromptForProxy(opts *CreateTargetProxyOptions, flags *CreateTargetProxyFlags, description string) error {
20 if flags.Proxy.Value == "" {
21 directConnection := true
22 opts.Ask(&survey.Confirm{
23 Message: fmt.Sprintf("Should the connection to the %s be direct?", description),
24 Default: true,
25 }, &directConnection)
26 if !directConnection {
27 selectedOption, err := selectors.Select(opts.Ask, "Select the proxy to use", opts.GetAllProxiesCallback, func(p *proxies.Proxy) string { return p.GetName() })
28 if err != nil {
29 return err
30 }
31 flags.Proxy.Value = selectedOption.GetName()
32 }
33 }
34 return nil
35}
36
37type CreateTargetProxyFlags struct {
38 Proxy *flag.Flag[string]

Callers 5

PromptMissingFunction · 0.92
PromptMissingFunction · 0.92

Calls 3

SelectFunction · 0.92
AskMethod · 0.65
GetNameMethod · 0.65