1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
driver.go 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
Olivier Gambier 提交于 2015-11-05 18:04 . Another pass at linting
package none
import (
"fmt"
neturl "net/url"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/mcnflag"
"github.com/docker/machine/libmachine/state"
)
const driverName = "none"
// Driver is the driver used when no driver is selected. It is used to
// connect to existing Docker hosts by specifying the URL of the host as
// an option.
type Driver struct {
*drivers.BaseDriver
URL string
}
func NewDriver(hostName, storePath string) *Driver {
return &Driver{
BaseDriver: &drivers.BaseDriver{
MachineName: hostName,
StorePath: storePath,
},
}
}
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{
mcnflag.StringFlag{
Name: "url",
Usage: "URL of host when no driver is selected",
Value: "",
},
}
}
func (d *Driver) Create() error {
return nil
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return driverName
}
func (d *Driver) GetIP() (string, error) {
return d.IPAddress, 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) GetURL() (string, error) {
return d.URL, nil
}
func (d *Driver) GetState() (state.State, error) {
return state.Running, nil
}
func (d *Driver) Kill() error {
return fmt.Errorf("hosts without a driver cannot be killed")
}
func (d *Driver) Remove() error {
return nil
}
func (d *Driver) Restart() error {
return fmt.Errorf("hosts without a driver cannot be restarted")
}
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
url := flags.String("url")
if url == "" {
return fmt.Errorf("--url option is required when no driver is selected")
}
d.URL = url
u, err := neturl.Parse(url)
if err != nil {
return err
}
d.IPAddress = u.Host
return nil
}
func (d *Driver) Start() error {
return fmt.Errorf("hosts without a driver cannot be started")
}
func (d *Driver) Stop() error {
return fmt.Errorf("hosts without a driver cannot be stopped")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.15.0-rancher13

搜索帮助

0d507c66 1850385 C8b1a773 1850385