1 Star 0 Fork 0

powerpaas/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fakedriver.go 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
Luther Monson 提交于 2019-11-15 16:06 . rancher-machine rename
package fakedriver
import (
"fmt"
"github.com/rancher/machine/libmachine/drivers"
"github.com/rancher/machine/libmachine/mcnflag"
"github.com/rancher/machine/libmachine/state"
)
type Driver struct {
*drivers.BaseDriver
MockState state.State
MockIP string
MockName string
}
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{}
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "Driver"
}
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return nil
}
func (d *Driver) GetURL() (string, error) {
ip, err := d.GetIP()
if err != nil {
return "", err
}
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
}
func (d *Driver) GetMachineName() string {
return d.MockName
}
func (d *Driver) GetIP() (string, error) {
if d.MockState == state.Error {
return "", fmt.Errorf("Unable to get ip")
}
if d.MockState == state.Timeout {
select {} // Loop forever
}
if d.MockState != state.Running {
return "", drivers.ErrHostIsNotRunning
}
return d.MockIP, nil
}
func (d *Driver) GetSSHHostname() (string, error) {
return "", nil
}
func (d *Driver) GetSSHKeyPath() string {
return ""
}
func (d *Driver) GetSSHPort() (int, error) {
return 0, nil
}
func (d *Driver) GetSSHUsername() string {
return ""
}
func (d *Driver) GetState() (state.State, error) {
return d.MockState, nil
}
func (d *Driver) Create() error {
return nil
}
func (d *Driver) Start() error {
d.MockState = state.Running
return nil
}
func (d *Driver) Stop() error {
d.MockState = state.Stopped
return nil
}
func (d *Driver) Restart() error {
d.MockState = state.Running
return nil
}
func (d *Driver) Kill() error {
d.MockState = state.Stopped
return nil
}
func (d *Driver) Remove() error {
return nil
}
func (d *Driver) Upgrade() error {
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/machine.git
git@gitee.com:powerpaas/machine.git
powerpaas
machine
machine
v0.15.0-rancher23

搜索帮助