37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clusterconfigcopier.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
Nathan Jenan 提交于 2018-11-28 08:29 . Adding pluggable driver support
package clusterconfigcopier
import (
"context"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
"k8s.io/apimachinery/pkg/runtime"
)
type controller struct {
}
func Register(ctx context.Context, management *config.ManagementContext) {
c := controller{}
management.Management.Clusters("").AddHandler(ctx, "clusterconfigcopier", c.sync)
}
func (c *controller) sync(key string, cluster *v3.Cluster) (runtime.Object, error) {
if key == "" {
return cluster, nil
}
if cluster.Spec.GenericEngineConfig != nil {
return cluster, nil
}
if cluster.Spec.AmazonElasticContainerServiceConfig != nil {
cluster.Spec.GenericEngineConfig = cluster.Spec.AmazonElasticContainerServiceConfig
(*cluster.Spec.GenericEngineConfig)["driverName"] = "amazonelasticcontainerservice"
}
if cluster.Spec.AzureKubernetesServiceConfig != nil {
cluster.Spec.GenericEngineConfig = cluster.Spec.AzureKubernetesServiceConfig
(*cluster.Spec.GenericEngineConfig)["driverName"] = "azurekubernetesservice"
}
if cluster.Spec.GoogleKubernetesEngineConfig != nil {
cluster.Spec.GenericEngineConfig = cluster.Spec.GoogleKubernetesEngineConfig
(*cluster.Spec.GenericEngineConfig)["driverName"] = "googlekubernetesengine"
}
return nil, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.0-alpha4

搜索帮助

0d507c66 1850385 C8b1a773 1850385