本文整理汇总了Golang中github.com/juju/juju/environs.RegisterProvider函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterProvider函数的具体用法?Golang RegisterProvider怎么用?Golang RegisterProvider使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegisterProvider函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
dummyProvider, err := environs.Provider("dummy")
if err != nil {
panic(err)
}
environs.RegisterProvider("fake", mockProvider{dummyProvider})
}
示例2: init
func init() {
environs.RegisterProvider(providerType, azureEnvironProvider{})
// Register the Azure storage provider.
registry.RegisterProvider(storageProviderType, &azureStorageProvider{})
registry.RegisterEnvironStorageProviders(providerType, storageProviderType)
}
示例3: init
func init() {
environs.RegisterProvider(providerType, maasEnvironProvider{})
//Register the MAAS specific storage providers.
registry.RegisterProvider(maasStorageProviderType, &maasStorageProvider{})
registry.RegisterEnvironStorageProviders(providerType, maasStorageProviderType)
}
示例4: init
func init() {
// This will only happen in binaries that actually import this provider
// somewhere. To enable a provider, import it in the "providers/all"
// package; please do *not* import individual providers anywhere else,
// except in direct tests for that provider.
environs.RegisterProvider("cloudsigma", providerInstance)
environs.RegisterImageDataSourceFunc("cloud sigma image source", getImageSource)
}
示例5: init
func init() {
environs.RegisterProvider("dummy", &dummy)
// Prime the first ops channel, so that naive clients can use
// the testing environment by simply importing it.
go func() {
for _ = range discardOperations {
}
}()
}
示例6: init
func init() {
osProvider := openstack.EnvironProvider{
Credentials{},
&rackspaceConfigurator{},
&firewallerFactory{},
}
providerInstance = &environProvider{
osProvider,
}
environs.RegisterProvider(providerType, providerInstance)
}
示例7: init
func init() {
environs.RegisterProvider("dummy", &providerInstance)
// Prime the first ops channel, so that naive clients can use
// the testing environment by simply importing it.
c := make(chan Operation)
go func() {
for _ = range c {
}
}()
discardOperations = c
Reset()
// parse errors are ignored
providerDelay, _ = time.ParseDuration(os.Getenv("JUJU_DUMMY_DELAY"))
}
示例8: TestRegisterProvider
func (s *suite) TestRegisterProvider(c *gc.C) {
s.PatchValue(environs.Providers, make(map[string]environs.EnvironProvider))
s.PatchValue(environs.ProviderAliases, make(map[string]string))
type step struct {
name string
aliases []string
err string
}
type test []step
tests := []test{
[]step{{
name: "providerName",
}},
[]step{{
name: "providerName",
aliases: []string{"providerName"},
err: "juju: duplicate provider alias \"providerName\"",
}},
[]step{{
name: "providerName",
aliases: []string{"providerAlias", "providerAlias"},
err: "juju: duplicate provider alias \"providerAlias\"",
}},
[]step{{
name: "providerName",
aliases: []string{"providerAlias1", "providerAlias2"},
}},
[]step{{
name: "providerName",
}, {
name: "providerName",
err: "juju: duplicate provider name \"providerName\"",
}},
[]step{{
name: "providerName1",
}, {
name: "providerName2",
aliases: []string{"providerName"},
}},
[]step{{
name: "providerName1",
}, {
name: "providerName2",
aliases: []string{"providerName1"},
err: "juju: duplicate provider alias \"providerName1\"",
}},
}
registerProvider := func(name string, aliases []string) (err error) {
defer func() { err, _ = recover().(error) }()
registered := &dummyProvider{}
environs.RegisterProvider(name, registered, aliases...)
p, err := environs.Provider(name)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, gc.Equals, registered)
for _, alias := range aliases {
p, err := environs.Provider(alias)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, gc.Equals, registered)
c.Assert(p, gc.Equals, registered)
}
return nil
}
for i, test := range tests {
c.Logf("test %d: %v", i, test)
for k := range *environs.Providers {
delete(*environs.Providers, k)
}
for k := range *environs.ProviderAliases {
delete(*environs.ProviderAliases, k)
}
for _, step := range test {
err := registerProvider(step.name, step.aliases)
if step.err == "" {
c.Assert(err, jc.ErrorIsNil)
} else {
c.Assert(err, gc.ErrorMatches, step.err)
}
}
}
}
示例9: SetUpSuite
func (s *listCredentialsSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
environs.RegisterProvider("test-provider", &mockProvider{})
}
示例10: init
func init() {
environs.RegisterProvider("maas", maasEnvironProvider{})
}
示例11: SetUpSuite
func (s *AddresserSuite) SetUpSuite(c *gc.C) {
s.BaseSuite.SetUpSuite(c)
environs.RegisterProvider("mock", mockEnvironProvider{})
}
示例12: SetUpSuite
func (s *detectCredentialsSuite) SetUpSuite(c *gc.C) {
environs.RegisterProvider("mock-provider", &mockProvider{detectedCreds: &s.aCredential})
}
示例13: init
func init() {
environs.RegisterProvider(provider.Local, providerInstance)
}
示例14: init
func init() {
environs.RegisterProvider("sshinit_test", &testProvider{})
}
示例15: init
func init() {
provider := mockEnvironProvider{}
environs.RegisterProvider("mock", provider)
}