1 Star 0 Fork 0

powerpaas/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
aws.go 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
package aws
import (
"bytes"
"fmt"
"github.com/go-ini/ini"
"github.com/rancher/types/apis/management.cattle.io/v3"
)
const (
AWSCloudProviderName = "aws"
AWSConfig = "AWSConfig"
)
type CloudProvider struct {
Config *v3.AWSCloudProvider
Name string
}
func GetInstance() *CloudProvider {
return &CloudProvider{}
}
func (p *CloudProvider) Init(cloudProviderConfig v3.CloudProvider) error {
p.Name = AWSCloudProviderName
if cloudProviderConfig.AWSCloudProvider == nil {
return nil
}
p.Config = cloudProviderConfig.AWSCloudProvider
return nil
}
func (p *CloudProvider) GetName() string {
return p.Name
}
func (p *CloudProvider) GenerateCloudConfigFile() (string, error) {
if p.Config == nil {
return "", nil
}
// Generate INI style configuration
buf := new(bytes.Buffer)
cloudConfig, _ := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, []byte(""))
if err := ini.ReflectFrom(cloudConfig, p.Config); err != nil {
return "", fmt.Errorf("Failed to parse Openstack cloud config")
}
if _, err := cloudConfig.WriteTo(buf); err != nil {
return "", err
}
return buf.String(), nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/rke.git
git@gitee.com:powerpaas/rke.git
powerpaas
rke
rke
v0.3.0-rc1

搜索帮助