1 Star 0 Fork 0

golang/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vsphere.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
galal-hussein 提交于 2018-06-06 19:11 . Refactor cloud provider support
package vsphere
import (
"fmt"
"github.com/rancher/rke/templates"
"github.com/rancher/types/apis/management.cattle.io/v3"
)
const (
VsphereCloudProviderName = "vsphere"
VsphereConfig = "VsphereConfig"
)
type CloudProvider struct {
Config *v3.VsphereCloudProvider
Name string
}
func GetInstance() *CloudProvider {
return &CloudProvider{}
}
func (p *CloudProvider) Init(cloudProviderConfig v3.CloudProvider) error {
if cloudProviderConfig.VsphereCloudProvider == nil {
return fmt.Errorf("Vsphere Cloud Provider Config is empty")
}
p.Name = VsphereCloudProviderName
if cloudProviderConfig.Name != "" {
p.Name = cloudProviderConfig.Name
}
p.Config = cloudProviderConfig.VsphereCloudProvider
return nil
}
func (p *CloudProvider) GetName() string {
return p.Name
}
func (p *CloudProvider) GenerateCloudConfigFile() (string, error) {
// Generate INI style configuration from template https://github.com/go-ini/ini/issues/84
VsphereConfig := map[string]v3.VsphereCloudProvider{
VsphereConfig: *p.Config,
}
return templates.CompileTemplateFromMap(templates.VsphereCloudProviderTemplate, VsphereConfig)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gober/rke.git
git@gitee.com:gober/rke.git
gober
rke
rke
v0.2.11

搜索帮助