forked from docker/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_provisioner.go
110 lines (87 loc) · 3.11 KB
/
fake_provisioner.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
package provision
import (
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/provision/pkgaction"
"github.com/docker/machine/libmachine/provision/serviceaction"
"github.com/docker/machine/libmachine/swarm"
)
type FakeDetector struct {
Provisioner
}
func (fd *FakeDetector) DetectProvisioner(d drivers.Driver) (Provisioner, error) {
return fd.Provisioner, nil
}
type FakeProvisioner struct{}
func NewFakeProvisioner(d drivers.Driver) Provisioner {
return &FakeProvisioner{}
}
func (fp *FakeProvisioner) SSHCommand(args string) (string, error) {
return "", nil
}
func (fp *FakeProvisioner) String() string {
return "fakeprovisioner"
}
func (fp *FakeProvisioner) GenerateDockerOptions(dockerPort int) (*DockerOptions, error) {
return nil, nil
}
func (fp *FakeProvisioner) GetDockerOptionsDir() string {
return ""
}
func (fp *FakeProvisioner) GetAuthOptions() auth.Options {
return auth.Options{}
}
func (fp *FakeProvisioner) GetSwarmOptions() swarm.Options {
return swarm.Options{}
}
func (fp *FakeProvisioner) Package(name string, action pkgaction.PackageAction) error {
return nil
}
func (fp *FakeProvisioner) Hostname() (string, error) {
return "", nil
}
func (fp *FakeProvisioner) SetHostname(hostname string) error {
return nil
}
func (fp *FakeProvisioner) CompatibleWithHost() bool {
return true
}
func (fp *FakeProvisioner) Provision(swarmOptions swarm.Options, authOptions auth.Options, engineOptions engine.Options) error {
return nil
}
func (fp *FakeProvisioner) Service(name string, action serviceaction.ServiceAction) error {
return nil
}
func (fp *FakeProvisioner) GetDriver() drivers.Driver {
return nil
}
func (fp *FakeProvisioner) SetOsReleaseInfo(info *OsRelease) {}
func (fp *FakeProvisioner) GetOsReleaseInfo() (*OsRelease, error) {
return nil, nil
}
type NetstatProvisioner struct {
*FakeProvisioner
}
func (p *NetstatProvisioner) SSHCommand(args string) (string, error) {
return `Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 72 192.168.25.141:ssh 192.168.25.1:63235 ESTABLISHED
tcp 0 0 :::2376 :::* LISTEN
tcp 0 0 :::ssh :::* LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 17990 /var/run/acpid.socket
unix 2 [ ACC ] SEQPACKET LISTENING 14233 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 19365 /var/run/docker.sock
unix 3 [ ] STREAM CONNECTED 19774
unix 3 [ ] STREAM CONNECTED 19775
unix 3 [ ] DGRAM 14243
unix 3 [ ] DGRAM 14242`, nil
}
func NewNetstatProvisioner() Provisioner {
return &NetstatProvisioner{
&FakeProvisioner{},
}
}