当前位置: 首页>>代码示例>>Golang>>正文


Golang environs.RegisterProvider函数代码示例

本文整理汇总了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})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:credentials_test.go

示例2: init

func init() {
	environs.RegisterProvider(providerType, azureEnvironProvider{})

	// Register the Azure storage provider.
	registry.RegisterProvider(storageProviderType, &azureStorageProvider{})
	registry.RegisterEnvironStorageProviders(providerType, storageProviderType)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:init.go

示例3: init

func init() {
	environs.RegisterProvider(providerType, maasEnvironProvider{})

	//Register the MAAS specific storage providers.
	registry.RegisterProvider(maasStorageProviderType, &maasStorageProvider{})

	registry.RegisterEnvironStorageProviders(providerType, maasStorageProviderType)
}
开发者ID:imoapps,项目名称:juju,代码行数:8,代码来源:init.go

示例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)
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:provider.go

示例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 {
		}
	}()
}
开发者ID:xushiwei,项目名称:juju,代码行数:10,代码来源:environs.go

示例6: init

func init() {
	osProvider := openstack.EnvironProvider{
		Credentials{},
		&rackspaceConfigurator{},
		&firewallerFactory{},
	}
	providerInstance = &environProvider{
		osProvider,
	}
	environs.RegisterProvider(providerType, providerInstance)
}
开发者ID:bac,项目名称:juju,代码行数:11,代码来源:init.go

示例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"))
}
开发者ID:klyachin,项目名称:juju,代码行数:16,代码来源:environs.go

示例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)
			}
		}
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:82,代码来源:config_test.go

示例9: SetUpSuite

func (s *listCredentialsSuite) SetUpSuite(c *gc.C) {
	s.BaseSuite.SetUpSuite(c)
	environs.RegisterProvider("test-provider", &mockProvider{})
}
开发者ID:kat-co,项目名称:juju,代码行数:4,代码来源:listcredentials_test.go

示例10: init

func init() {
	environs.RegisterProvider("maas", maasEnvironProvider{})
}
开发者ID:klyachin,项目名称:juju,代码行数:3,代码来源:environprovider.go

示例11: SetUpSuite

func (s *AddresserSuite) SetUpSuite(c *gc.C) {
	s.BaseSuite.SetUpSuite(c)
	environs.RegisterProvider("mock", mockEnvironProvider{})
}
开发者ID:exekias,项目名称:juju,代码行数:4,代码来源:addresser_test.go

示例12: SetUpSuite

func (s *detectCredentialsSuite) SetUpSuite(c *gc.C) {
	environs.RegisterProvider("mock-provider", &mockProvider{detectedCreds: &s.aCredential})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:3,代码来源:detectcredentials_test.go

示例13: init

func init() {
	environs.RegisterProvider(provider.Local, providerInstance)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:3,代码来源:environprovider.go

示例14: init

func init() {
	environs.RegisterProvider("sshinit_test", &testProvider{})
}
开发者ID:Pankov404,项目名称:juju,代码行数:3,代码来源:renderscript_test.go

示例15: init

func init() {
	provider := mockEnvironProvider{}
	environs.RegisterProvider("mock", provider)
}
开发者ID:exekias,项目名称:juju,代码行数:4,代码来源:package_test.go


注:本文中的github.com/juju/juju/environs.RegisterProvider函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。