1 Star 0 Fork 0

powerpaas/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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/machine.git
git@gitee.com:powerpaas/machine.git
powerpaas
machine
machine
v0.7.0-rc3

搜索帮助