(pattern string)
| 167 | } |
| 168 | |
| 169 | func NormalizeConfigPattern(pattern string) string { |
| 170 | userName, err := WaveSshConfigUserSettings().GetStrict(pattern, "User") |
| 171 | if err != nil || userName == "" { |
| 172 | log.Printf("warning: error parsing username of %s for conn dropdown: %v", pattern, err) |
| 173 | localUser, err := user.Current() |
| 174 | if err == nil { |
| 175 | userName = localUser.Username |
| 176 | } |
| 177 | } |
| 178 | port, err := WaveSshConfigUserSettings().GetStrict(pattern, "Port") |
| 179 | if err != nil { |
| 180 | port = "22" |
| 181 | } |
| 182 | if userName != "" { |
| 183 | userName += "@" |
| 184 | } |
| 185 | if port == "22" { |
| 186 | port = "" |
| 187 | } else { |
| 188 | port = ":" + port |
| 189 | } |
| 190 | return fmt.Sprintf("%s%s%s", userName, pattern, port) |
| 191 | } |
| 192 | |
| 193 | func ParseProfiles() []string { |
| 194 | connfile, cerrs := wconfig.ReadWaveHomeConfigFile(wconfig.ProfilesFile) |
no test coverage detected