blob: 9d66fe178e054a9403625d367a346f137f569d5b [file] [log] [blame]
Samuel A. Falvo IIfd78c302013-06-25 16:35:32 -07001package gophercloud
2
3import (
4)
5
6type Provider struct {
Samuel A. Falvo II5d0d74c2013-06-25 17:23:18 -07007 AuthEndpoint string
Samuel A. Falvo IIfd78c302013-06-25 16:35:32 -07008}
9
10var providerMap = make(map[string]*Provider)
11
12func (c *Context) RegisterProvider(name string, p *Provider) error {
Samuel A. Falvo II5d0d74c2013-06-25 17:23:18 -070013 if p.AuthEndpoint == "" {
14 return ErrConfiguration
15 }
16
Samuel A. Falvo IIfd78c302013-06-25 16:35:32 -070017 c.providerMap[name] = p
18 return nil
19}
20
21func (c *Context) ProviderByName(name string) (p *Provider, err error) {
22 for provider, descriptor := range c.providerMap {
23 if name == provider {
24 return descriptor, nil
25 }
26 }
27 return nil, ErrProvider
28}