1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
migrate_v0_v1.go 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
Olivier Gambier 提交于 2015-11-04 17:28 . Lint
package host
import (
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/swarm"
)
// In the 0.1.0 => 0.2.0 transition, the JSON representation of
// machines changed from a "flat" to a more "nested" structure
// for various options and configuration settings. To preserve
// compatibility with existing machines, these migration functions
// have been introduced. They preserve backwards compat at the expense
// of some duplicated information.
// MigrateHostV0ToHostV1 validates host config and modifies if needed
// this is used for configuration updates
func MigrateHostV0ToHostV1(hostV0 *V0) *V1 {
hostV1 := &V1{
Driver: hostV0.Driver,
DriverName: hostV0.DriverName,
}
hostV1.HostOptions = &OptionsV1{}
hostV1.HostOptions.EngineOptions = &engine.Options{
TLSVerify: true,
InstallURL: "https://get.docker.com",
}
hostV1.HostOptions.SwarmOptions = &swarm.Options{
Address: "",
Discovery: hostV0.SwarmDiscovery,
Host: hostV0.SwarmHost,
Master: hostV0.SwarmMaster,
}
hostV1.HostOptions.AuthOptions = &AuthOptionsV1{
StorePath: hostV0.StorePath,
CaCertPath: hostV0.CaCertPath,
CaCertRemotePath: "",
ServerCertPath: hostV0.ServerCertPath,
ServerKeyPath: hostV0.ServerKeyPath,
ClientKeyPath: hostV0.ClientKeyPath,
ServerCertRemotePath: "",
ServerKeyRemotePath: "",
PrivateKeyPath: hostV0.PrivateKeyPath,
ClientCertPath: hostV0.ClientCertPath,
}
return hostV1
}
// MigrateHostMetadataV0ToHostMetadataV1 fills nested host metadata and modifies if needed
// this is used for configuration updates
func MigrateHostMetadataV0ToHostMetadataV1(m *MetadataV0) *Metadata {
hostMetadata := &Metadata{}
hostMetadata.DriverName = m.DriverName
hostMetadata.HostOptions.EngineOptions = &engine.Options{}
hostMetadata.HostOptions.AuthOptions = &auth.Options{
StorePath: m.StorePath,
CaCertPath: m.CaCertPath,
CaCertRemotePath: "",
ServerCertPath: m.ServerCertPath,
ServerKeyPath: m.ServerKeyPath,
ClientKeyPath: "",
ServerCertRemotePath: "",
ServerKeyRemotePath: "",
CaPrivateKeyPath: m.PrivateKeyPath,
ClientCertPath: m.ClientCertPath,
}
hostMetadata.ConfigVersion = m.ConfigVersion
return hostMetadata
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.14.0-rancher4

搜索帮助