LoadBridge instantiate a new bridge from a repo configuration
(repo *cache.RepoCache, name string)
| 107 | |
| 108 | // LoadBridge instantiate a new bridge from a repo configuration |
| 109 | func LoadBridge(repo *cache.RepoCache, name string) (*Bridge, error) { |
| 110 | conf, err := loadConfig(repo, name) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | |
| 115 | target := conf[ConfigKeyTarget] |
| 116 | bridge, err := NewBridge(repo, target, name) |
| 117 | if err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | |
| 121 | err = bridge.impl.ValidateConfig(conf) |
| 122 | if err != nil { |
| 123 | return nil, errors.Wrap(err, "invalid configuration") |
| 124 | } |
| 125 | |
| 126 | // will avoid reloading configuration before an export or import call |
| 127 | bridge.conf = conf |
| 128 | return bridge, nil |
| 129 | } |
| 130 | |
| 131 | // Attempt to retrieve a default bridge for the given repo. If zero or multiple |
| 132 | // bridge exist, it fails. |
no test coverage detected