1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
default_test_host.go 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
David Gageot 提交于 2015-11-12 17:23 . Remove unused code
package hosttest
import (
"github.com/docker/machine/drivers/none"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/libmachine/version"
)
const (
DefaultHostName = "test-host"
HostTestCaCert = "test-cert"
HostTestPrivateKey = "test-key"
)
type DriverOptionsMock struct {
Data map[string]interface{}
}
func (d DriverOptionsMock) String(key string) string {
return d.Data[key].(string)
}
func (d DriverOptionsMock) StringSlice(key string) []string {
return d.Data[key].([]string)
}
func (d DriverOptionsMock) Int(key string) int {
return d.Data[key].(int)
}
func (d DriverOptionsMock) Bool(key string) bool {
return d.Data[key].(bool)
}
func GetTestDriverFlags() *DriverOptionsMock {
flags := &DriverOptionsMock{
Data: map[string]interface{}{
"name": DefaultHostName,
"url": "unix:///var/run/docker.sock",
"swarm": false,
"swarm-host": "",
"swarm-master": false,
"swarm-discovery": "",
},
}
return flags
}
func GetDefaultTestHost() (*host.Host, error) {
hostOptions := &host.Options{
EngineOptions: &engine.Options{},
SwarmOptions: &swarm.Options{},
AuthOptions: &auth.Options{
CaCertPath: HostTestCaCert,
CaPrivateKeyPath: HostTestPrivateKey,
},
}
driver := none.NewDriver(DefaultHostName, "/tmp/artifacts")
host := &host.Host{
ConfigVersion: version.ConfigVersion,
Name: DefaultHostName,
Driver: driver,
DriverName: "none",
HostOptions: hostOptions,
}
flags := GetTestDriverFlags()
if err := host.Driver.SetConfigFromFlags(flags); err != nil {
return nil, err
}
return host, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.13.0-rancher5

搜索帮助

0d507c66 1850385 C8b1a773 1850385