GetAllStrict retrieves zero or more directives for key for the given alias. If key has a default value and no matching configuration is found, the default will be returned. For more information on default values and the way patterns are matched, see the manpage for ssh_config. The returned error wi
(alias, key string)
| 228 | // or the system configuration file could not be parsed, and u.IgnoreErrors is |
| 229 | // false. |
| 230 | func (u *UserSettings) GetAllStrict(alias, key string) ([]string, error) { |
| 231 | u.doLoadConfigs() |
| 232 | //lint:ignore S1002 I prefer it this way |
| 233 | if u.onceErr != nil && u.IgnoreErrors == false { |
| 234 | return nil, u.onceErr |
| 235 | } |
| 236 | val, err := findAll(u.userConfig, alias, key) |
| 237 | if err != nil || val != nil { |
| 238 | return val, err |
| 239 | } |
| 240 | val2, err2 := findAll(u.systemConfig, alias, key) |
| 241 | if err2 != nil || val2 != nil { |
| 242 | return val2, err2 |
| 243 | } |
| 244 | // TODO: IdentityFile has multiple default values that we should return. |
| 245 | if def := Default(key); def != "" { |
| 246 | return []string{def}, nil |
| 247 | } |
| 248 | return []string{}, nil |
| 249 | } |
| 250 | |
| 251 | func (u *UserSettings) doLoadConfigs() { |
| 252 | u.loadConfigs.Do(func() { |
no test coverage detected