1 Star 0 Fork 0

powerpaas/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cloudprovider.go 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
galal-hussein 提交于 2018-06-06 19:11 . Refactor cloud provider support
package cloudprovider
import (
"github.com/rancher/rke/cloudprovider/aws"
"github.com/rancher/rke/cloudprovider/azure"
"github.com/rancher/rke/cloudprovider/custom"
"github.com/rancher/rke/cloudprovider/openstack"
"github.com/rancher/rke/cloudprovider/vsphere"
"github.com/rancher/types/apis/management.cattle.io/v3"
)
type CloudProvider interface {
Init(cloudProviderConfig v3.CloudProvider) error
GenerateCloudConfigFile() (string, error)
GetName() string
}
func InitCloudProvider(cloudProviderConfig v3.CloudProvider) (CloudProvider, error) {
var p CloudProvider
if cloudProviderConfig.Name == aws.AWSCloudProviderName {
p = aws.GetInstance()
}
if cloudProviderConfig.AzureCloudProvider != nil || cloudProviderConfig.Name == azure.AzureCloudProviderName {
p = azure.GetInstance()
}
if cloudProviderConfig.OpenstackCloudProvider != nil || cloudProviderConfig.Name == openstack.OpenstackCloudProviderName {
p = openstack.GetInstance()
}
if cloudProviderConfig.VsphereCloudProvider != nil || cloudProviderConfig.Name == vsphere.VsphereCloudProviderName {
p = vsphere.GetInstance()
}
if cloudProviderConfig.CustomCloudProvider != "" {
p = custom.GetInstance()
}
if p != nil {
if err := p.Init(cloudProviderConfig); err != nil {
return nil, err
}
}
return p, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/rke.git
git@gitee.com:powerpaas/rke.git
powerpaas
rke
rke
v0.1.16

搜索帮助