代码拉取完成,页面将自动刷新
package libmachinetest
import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/mcnerror"
"github.com/docker/machine/libmachine/state"
)
type FakeAPI struct {
Hosts []*host.Host
}
func (api *FakeAPI) NewPluginDriver(string, []byte) (drivers.Driver, error) {
return nil, nil
}
func (api *FakeAPI) Close() error {
return nil
}
func (api *FakeAPI) NewHost(driverName string, rawDriver []byte) (*host.Host, error) {
return nil, nil
}
func (api *FakeAPI) Create(h *host.Host) error {
return nil
}
func (api *FakeAPI) Exists(name string) (bool, error) {
for _, host := range api.Hosts {
if name == host.Name {
return true, nil
}
}
return false, nil
}
func (api *FakeAPI) List() ([]string, error) {
return []string{}, nil
}
func (api *FakeAPI) Load(name string) (*host.Host, error) {
for _, host := range api.Hosts {
if name == host.Name {
return host, nil
}
}
return nil, mcnerror.ErrHostDoesNotExist{
Name: name,
}
}
func (api *FakeAPI) Remove(name string) error {
newHosts := []*host.Host{}
for _, host := range api.Hosts {
if name != host.Name {
newHosts = append(newHosts, host)
}
}
api.Hosts = newHosts
return nil
}
func (api *FakeAPI) Save(host *host.Host) error {
return nil
}
func (api FakeAPI) GetMachinesDir() string {
return ""
}
func State(api libmachine.API, name string) state.State {
host, _ := api.Load(name)
machineState, _ := host.Driver.GetState()
return machineState
}
func Exists(api libmachine.API, name string) bool {
exists, _ := api.Exists(name)
return exists
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。