forked from rancher/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
none.go
128 lines (100 loc) · 2.35 KB
/
none.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package none
import (
"fmt"
neturl "net/url"
"github.com/codegangsta/cli"
"github.com/docker/machine/drivers"
"github.com/docker/machine/state"
)
// 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 {
IPAddress string
URL string
}
func init() {
drivers.Register("none", &drivers.RegisteredDriver{
New: NewDriver,
GetCreateFlags: GetCreateFlags,
})
}
func GetCreateFlags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "url",
Usage: "URL of host when no driver is selected",
Value: "",
},
}
}
func NewDriver(machineName string, storePath string, caCert string, privateKey string) (drivers.Driver, error) {
return &Driver{}, nil
}
func (d *Driver) AuthorizePort(ports []*drivers.Port) error {
return nil
}
func (d *Driver) Create() error {
return nil
}
func (d *Driver) DeauthorizePort(ports []*drivers.Port) error {
return nil
}
func (d *Driver) DriverName() string {
return "none"
}
func (d *Driver) GetIP() (string, error) {
return d.IPAddress, nil
}
func (d *Driver) GetMachineName() string {
return ""
}
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.None, nil
}
func (d *Driver) Kill() error {
return fmt.Errorf("hosts without a driver cannot be killed")
}
func (d *Driver) PreCreateCheck() error {
return nil
}
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")
}