ConfigScoped returns the repository config, merged with requested scope and lower. For example if, config.GlobalScope is given the local and global config are returned merged in one config value.
(scope config.Scope)
| 571 | // lower. For example if, config.GlobalScope is given the local and global config |
| 572 | // are returned merged in one config value. |
| 573 | func (r *Repository) ConfigScoped(scope config.Scope) (*config.Config, error) { |
| 574 | // TODO(mcuadros): v6, add this as ConfigOptions.Scoped |
| 575 | |
| 576 | var err error |
| 577 | system := config.NewConfig() |
| 578 | if scope >= config.SystemScope { |
| 579 | system, err = config.LoadConfig(config.SystemScope) |
| 580 | if err != nil { |
| 581 | return nil, err |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | global := config.NewConfig() |
| 586 | if scope >= config.GlobalScope { |
| 587 | global, err = config.LoadConfig(config.GlobalScope) |
| 588 | if err != nil { |
| 589 | return nil, err |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | local, err := r.Storer.Config() |
| 594 | if err != nil { |
| 595 | return nil, err |
| 596 | } |
| 597 | |
| 598 | _ = mergo.Merge(global, system) |
| 599 | _ = mergo.Merge(local, global) |
| 600 | return local, nil |
| 601 | } |
| 602 | |
| 603 | // Remote return a remote if exists |
| 604 | func (r *Repository) Remote(name string) (*Remote, error) { |