MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / GetAll

Method GetAll

cli/pkg/ssh_config/config.go:380–412  ·  view source on GitHub ↗

GetAll returns all values in the configuration that match the alias and contains key, or nil if none are present.

(alias, key string)

Source from the content-addressed store, hash-verified

378// GetAll returns all values in the configuration that match the alias and
379// contains key, or nil if none are present.
380func (c *Config) GetAll(alias, key string) ([]string, error) {
381 lowerKey := strings.ToLower(key)
382 all := []string(nil)
383 for _, host := range c.Hosts {
384 if !host.Matches(alias) {
385 continue
386 }
387 for _, node := range host.Nodes {
388 switch t := node.(type) {
389 case *Empty:
390 continue
391 case *KV:
392 // "keys are case insensitive" per the spec
393 lkey := strings.ToLower(t.Key)
394 if lkey == "match" {
395 panic("can't handle Match directives")
396 }
397 if lkey == lowerKey {
398 all = append(all, t.Value)
399 }
400 case *Include:
401 val, _ := t.GetAll(alias, key)
402 if len(val) > 0 {
403 all = append(all, val...)
404 }
405 default:
406 return nil, fmt.Errorf("unknown Node type %v", t)
407 }
408 }
409 }
410
411 return all, nil
412}
413
414// String returns a string representation of the Config file.
415func (c Config) String() string {

Callers 3

findAllFunction · 0.45
GetAllFunction · 0.45
GetAllMethod · 0.45

Calls 1

MatchesMethod · 0.80

Tested by

no test coverage detected