Samuel A. Falvo II | fd78c30 | 2013-06-25 16:35:32 -0700 | [diff] [blame^] | 1 | package gophercloud |
| 2 | |
| 3 | import ( |
| 4 | ) |
| 5 | |
| 6 | type Provider struct { |
| 7 | // empty. |
| 8 | } |
| 9 | |
| 10 | var providerMap = make(map[string]*Provider) |
| 11 | |
| 12 | func (c *Context) RegisterProvider(name string, p *Provider) error { |
| 13 | c.providerMap[name] = p |
| 14 | return nil |
| 15 | } |
| 16 | |
| 17 | func (c *Context) ProviderByName(name string) (p *Provider, err error) { |
| 18 | for provider, descriptor := range c.providerMap { |
| 19 | if name == provider { |
| 20 | return descriptor, nil |
| 21 | } |
| 22 | } |
| 23 | return nil, ErrProvider |
| 24 | } |