代码拉取完成,页面将自动刷新
package app
import (
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
func addMachineDrivers(management *config.ManagementContext) error {
if err := addMachineDriver("amazonec2", "local://", "", true, true, management); err != nil {
return err
}
if err := addMachineDriver("digitalocean", "local://", "", true, true, management); err != nil {
return err
}
if err := addMachineDriver("exoscale", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("openstack", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("otc", "https://obs.otc.t-systems.com/dockermachinedriver/docker-machine-driver-otc",
"e98f246f625ca46f5e037dc29bdf00fe", false, false, management); err != nil {
return err
}
if err := addMachineDriver("packet", "https://github.com/packethost/docker-machine-driver-packet/releases/download/v0.1.5/docker-machine-driver-packet_linux-amd64.zip",
"8231136e899311d54eca0b560b1feb96", false, false, management); err != nil {
return err
}
if err := addMachineDriver("rackspace", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("softlayer", "local://", "", false, true, management); err != nil {
return err
}
return addMachineDriver("vmwarevsphere", "local://", "", true, true, management)
}
func addMachineDriver(name, url, checksum string, active, builtin bool, management *config.ManagementContext) error {
lister := management.Management.NodeDrivers("").Controller().Lister()
cli := management.Management.NodeDrivers("")
m, _ := lister.Get("", name)
if m != nil {
if m.Spec.Builtin != builtin || m.Spec.URL != url || m.Spec.Checksum != checksum || m.Spec.DisplayName != name {
logrus.Infof("Updating node driver %v", name)
m.Spec.Builtin = builtin
m.Spec.URL = url
m.Spec.Checksum = checksum
m.Spec.DisplayName = name
_, err := cli.Update(m)
return err
}
return nil
}
logrus.Infof("Creating node driver %v", name)
_, err := cli.Create(&v3.NodeDriver{
ObjectMeta: v1.ObjectMeta{
Name: name,
},
Spec: v3.NodeDriverSpec{
Active: active,
Builtin: builtin,
URL: url,
DisplayName: name,
Checksum: checksum,
},
})
return err
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。