| 79 | } |
| 80 | |
| 81 | func PromptForSshEndpoint(opts *SshCommonOptions, flags *SshCommonFlags, entityType string) error { |
| 82 | if flags.HostName.Value == "" { |
| 83 | if err := opts.Ask(&survey.Input{ |
| 84 | Message: "Host", |
| 85 | Help: fmt.Sprintf("The hostname or IP address at which the %s can be reached.", entityType), |
| 86 | }, &flags.HostName.Value, survey.WithValidator(survey.Required)); err != nil { |
| 87 | return err |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if flags.Port.Value == 0 { |
| 92 | var port string |
| 93 | if err := opts.Ask(&survey.Input{ |
| 94 | Message: "Port", |
| 95 | Help: fmt.Sprintf("Port number to connect over SSH to the %s. Default is %d", entityType, DefaultPort), |
| 96 | Default: fmt.Sprintf("%d", DefaultPort), |
| 97 | }, &port); err != nil { |
| 98 | return err |
| 99 | } |
| 100 | |
| 101 | if port == "" { |
| 102 | port = fmt.Sprintf("%d", DefaultPort) |
| 103 | } |
| 104 | |
| 105 | if p, err := strconv.Atoi(port); err == nil { |
| 106 | flags.Port.Value = p |
| 107 | } else { |
| 108 | return err |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if flags.Fingerprint.Value == "" { |
| 113 | if err := opts.Ask(&survey.Input{ |
| 114 | Message: "Host fingerprint", |
| 115 | Help: fmt.Sprintf("The host fingerprint of the SSH %s.", entityType), |
| 116 | }, &flags.Fingerprint.Value, survey.WithValidator(survey.Required)); err != nil { |
| 117 | return err |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | func PromptForDotNetConfig(opts *SshCommonOptions, flags *SshCommonFlags, entityType string) error { |
| 125 | if flags.Runtime.Value == "" { |