Skip to content

Commit a2be2bc

Browse files
authored
Add boot2docker url as a flag to the start command (#179) (#180)
* added boot2docker url as a parameter to the start command * added nolint comments for gosec linter errors
1 parent 169de82 commit a2be2bc

20 files changed

Lines changed: 85 additions & 77 deletions

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ func main() {
6868
app.Commands = append(app.Commands, (&commands.Dev{}).Commands()...)
6969
app.Commands = append(app.Commands, (&commands.SSH{}).Commands()...)
7070

71-
app.Run(os.Args)
71+
app.Run(os.Args) // nolint: gosec
7272
}

commands/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (cmd *BaseCommand) Before(c *cli.Context) error {
2929
cmd.out = util.Logger()
3030
cmd.machine = Machine{Name: c.GlobalString("name"), out: util.Logger()}
3131

32-
util.NotifyInit(fmt.Sprintf("Outrigger (rig) %s", c.App.Version))
32+
util.NotifyInit(fmt.Sprintf("Outrigger (rig) %s", c.App.Version)) // nolint: gosec
3333

3434
// Hold onto Context so that we can use it later without having to pass it around everywhere
3535
cmd.context = c
@@ -62,7 +62,7 @@ func (cmd *BaseCommand) Failure(message string, errorName string, exitCode int)
6262
}
6363

6464
// Handle error messaging.
65-
util.NotifyError(cmd.context, message)
65+
util.NotifyError(cmd.context, message) // nolint: gosec
6666
// Print expanded troubleshooting guidance.
6767
if !cmd.context.GlobalBool("power-user") {
6868
util.PrintDebugHelp(message, errorName, exitCode)

commands/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ func (cmd *Config) Run(c *cli.Context) error {
3636
if !util.IsMac() {
3737
// Add stuff to PATH only once
3838
path := os.Getenv("PATH")
39-
dir, _ := util.GetExecutableDir()
39+
dir, _ := util.GetExecutableDir() // nolint: gosec
4040
if !strings.Contains(path, dir) {
4141
fmt.Printf("export PATH=%s%c$PATH\n", dir, os.PathListSeparator)
4242
}
4343
}
4444

4545
// Clear out any previous environment variables
4646
if output, err := util.Command("docker-machine", "env", "-u").Output(); err == nil {
47-
os.Stdout.Write(output)
47+
os.Stdout.Write(output) // nolint: gosec
4848
}
4949

5050
if cmd.machine.Exists() {
5151
// Setup new values if machine is running
5252
if output, err := util.Command("docker-machine", "env", cmd.machine.Name).Output(); err == nil {
53-
os.Stdout.Write(output)
53+
os.Stdout.Write(output) // nolint: gosec
5454
}
5555
} else {
5656
return cmd.Failure(fmt.Sprintf("No machine named '%s' exists.", cmd.machine.Name), "MACHINE-NOT-FOUND", 12)

commands/dashboard.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (cmd *Dashboard) LaunchDashboard(machine Machine) error {
6565
cmd.out.Verbose("Successfully updated dashboard.")
6666
}
6767

68-
dockerAPIVersion, _ := util.GetDockerServerAPIVersion()
68+
dockerAPIVersion, _ := util.GetDockerServerAPIVersion() // nolint: gosec
6969
args := []string{
7070
"run",
7171
"-d",
@@ -78,11 +78,11 @@ func (cmd *Dashboard) LaunchDashboard(machine Machine) error {
7878
dashboardImageName,
7979
}
8080

81-
util.ForceStreamCommand("docker", args...)
81+
util.ForceStreamCommand("docker", args...) // nolint: gosec
8282
if util.IsMac() {
83-
util.Command("open", "http://dashboard.outrigger.vm").Run()
83+
util.Command("open", "http://dashboard.outrigger.vm").Run() // nolint: gosec
8484
} else if util.IsWindows() {
85-
util.Command("start", "http://dashboard.outrigger.vm").Run()
85+
util.Command("start", "http://dashboard.outrigger.vm").Run() // nolint: gosec
8686
} else {
8787
cmd.out.Info("Outrigger Dashboard is now available at http://dashboard.outrigger.vm")
8888
}
@@ -92,6 +92,6 @@ func (cmd *Dashboard) LaunchDashboard(machine Machine) error {
9292

9393
// StopDashboard stops and removes the dashboard container
9494
func (cmd *Dashboard) StopDashboard() {
95-
util.Command("docker", "stop", dashboardContainerName).Run()
96-
util.Command("docker", "rm", dashboardContainerName).Run()
95+
util.Command("docker", "stop", dashboardContainerName).Run() // nolint: gosec
96+
util.Command("docker", "rm", dashboardContainerName).Run() // nolint: gosec
9797
}

commands/dns-records.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (cmd *DNSRecords) LoadRecords() ([]map[string]interface{}, error) {
7373
return nil, fmt.Errorf("failed to parse dnsdock JSON: %s", err)
7474
}
7575

76-
dnsdockMap, _ := js.Map()
76+
dnsdockMap, _ := js.Map() // nolint: gosec
7777
records := []map[string]interface{}{}
7878
for id, value := range dnsdockMap {
7979
record := value.(map[string]interface{})

commands/dns.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ func (cmd *DNS) configureMacRoutes(machine Machine) {
7474
if machine.IsXhyve() {
7575
cmd.removeHostFilter(machineIP)
7676
}
77-
util.Command("sudo", "route", "-n", "delete", "-net", "172.17.0.0").Run()
78-
util.StreamCommand("sudo", "route", "-n", "add", "172.17.0.0/16", machineIP)
77+
util.Command("sudo", "route", "-n", "delete", "-net", "172.17.0.0").Run() // nolint: gosec
78+
util.StreamCommand("sudo", "route", "-n", "add", "172.17.0.0/16", machineIP) // nolint: gosec
7979
if _, err := os.Stat("/usr/sbin/discoveryutil"); err == nil {
8080
// Put this here for people running OS X 10.10.0 to 10.10.3 (oy vey.)
8181
cmd.out.Verbose("Restarting discoveryutil to flush DNS caches")
82-
util.StreamCommand("sudo", "launchctl", "unload", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist")
83-
util.StreamCommand("sudo", "launchctl", "load", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist")
82+
util.StreamCommand("sudo", "launchctl", "unload", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist") // nolint: gosec
83+
util.StreamCommand("sudo", "launchctl", "load", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist") // nolint: gosec
8484
} else {
8585
// Reset DNS cache. We have seen this suddenly make /etc/resolver/vm work.
8686
cmd.out.Verbose("Restarting mDNSResponder to flush DNS caches")
87-
util.StreamCommand("sudo", "killall", "-HUP", "mDNSResponder")
87+
util.StreamCommand("sudo", "killall", "-HUP", "mDNSResponder") // nolint: gosec
8888
}
8989
}
9090

@@ -109,13 +109,13 @@ func (cmd *DNS) removeHostFilter(ipAddr string) {
109109
member := memberRegexp.FindStringSubmatch(string(ifaceData))[1]
110110

111111
// #4: ifconfig <bridge> -hostfilter <member>
112-
util.StreamCommand("sudo", "ifconfig", iface, "-hostfilter", member)
112+
util.StreamCommand("sudo", "ifconfig", iface, "-hostfilter", member) // nolint: gosec
113113
}
114114

115115
// ConfigureWindowsRoutes configures network routing
116116
func (cmd *DNS) configureWindowsRoutes(machine Machine) {
117-
util.Command("runas", "/noprofile", "/user:Administrator", "route", "DELETE", "172.17.0.0").Run()
118-
util.StreamCommand("runas", "/noprofile", "/user:Administrator", "route", "-p", "ADD", "172.17.0.0/16", machine.GetIP())
117+
util.Command("runas", "/noprofile", "/user:Administrator", "route", "DELETE", "172.17.0.0").Run() // nolint: gosec
118+
util.StreamCommand("runas", "/noprofile", "/user:Administrator", "route", "-p", "ADD", "172.17.0.0/16", machine.GetIP()) // nolint: gosec
119119
}
120120

121121
// StartDNS will start the dnsdock service
@@ -152,7 +152,7 @@ func (cmd *DNS) StartDNS(machine Machine, nameservers string) error {
152152
args = append(args, "--nameserver="+server)
153153
}
154154

155-
util.StreamCommand("docker", args...)
155+
util.StreamCommand("docker", args...) // nolint: gosec
156156
// Configure the resolvers based on platform
157157
var resolverReturn error
158158
if util.IsMac() {
@@ -181,12 +181,12 @@ func (cmd *DNS) configureMacResolver(machine Machine) error {
181181
if _, err := os.Stat("/usr/sbin/discoveryutil"); err == nil {
182182
// Put this here for people running OS X 10.10.0 to 10.10.3 (oy vey.)
183183
cmd.out.Verbose("Restarting discoveryutil to flush DNS caches")
184-
util.StreamCommand("sudo", "launchctl", "unload", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist")
185-
util.StreamCommand("sudo", "launchctl", "load", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist")
184+
util.StreamCommand("sudo", "launchctl", "unload", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist") // nolint: gosec
185+
util.StreamCommand("sudo", "launchctl", "load", "-w", "/System/Library/LaunchDaemons/com.apple.discoveryd.plist") // nolint: gosec
186186
} else {
187187
// Reset DNS cache. We have seen this suddenly make /etc/resolver/vm work.
188188
cmd.out.Verbose("Restarting mDNSResponder to flush DNS caches")
189-
util.StreamCommand("sudo", "killall", "-HUP", "mDNSResponder")
189+
util.StreamCommand("sudo", "killall", "-HUP", "mDNSResponder") // nolint: gosec
190190
}
191191
return nil
192192
}
@@ -202,18 +202,18 @@ func (cmd *DNS) configureLinuxResolver() error {
202202
// Is NetworkManager in use
203203
if _, err := os.Stat("/etc/NetworkManager/dnsmasq.d"); err == nil {
204204
// Install for NetworkManager/dnsmasq connection to dnsdock
205-
util.StreamCommand("bash", "-c", fmt.Sprintf("echo 'server=/vm/%s' | sudo tee /etc/NetworkManager/dnsmasq.d/dnsdock.conf", bridgeIP))
205+
util.StreamCommand("bash", "-c", fmt.Sprintf("echo 'server=/vm/%s' | sudo tee /etc/NetworkManager/dnsmasq.d/dnsdock.conf", bridgeIP)) // nolint: gosec
206206

207207
// Restart NetworkManager if it is running
208208
if err := util.Command("systemctl", "is-active", "NetworkManager").Run(); err != nil {
209-
util.StreamCommand("sudo", "systemctl", "restart", "NetworkManager")
209+
util.StreamCommand("sudo", "systemctl", "restart", "NetworkManager") // nolint: gosec
210210
}
211211
}
212212

213213
// Is libnss-resolver in use
214214
if _, err := os.Stat("/etc/resolver"); err == nil {
215215
// Install for libnss-resolver connection to dnsdock
216-
util.Command("bash", "-c", fmt.Sprintf("echo 'nameserver %s:53' | sudo tee /etc/resolver/vm", bridgeIP)).Run()
216+
util.Command("bash", "-c", fmt.Sprintf("echo 'nameserver %s:53' | sudo tee /etc/resolver/vm", bridgeIP)).Run() // nolint: gosec
217217
}
218218

219219
return nil
@@ -228,6 +228,6 @@ func (cmd *DNS) configureWindowsResolver(machine Machine) error {
228228

229229
// StopDNS stops the dnsdock service and cleans up
230230
func (cmd *DNS) StopDNS() {
231-
util.Command("docker", "stop", "dnsdock").Run()
232-
util.Command("docker", "rm", "dnsdock").Run()
231+
util.Command("docker", "stop", "dnsdock").Run() // nolint: gosec
232+
util.Command("docker", "rm", "dnsdock").Run() // nolint: gosec
233233
}

commands/doctor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
105105
cmd.out.Spin("Checking Docker version...")
106106
clientAPIVersion := util.GetDockerClientAPIVersion()
107107
serverAPIVersion, err := util.GetDockerServerAPIVersion()
108-
serverMinAPIVersion, _ := util.GetDockerServerMinAPIVersion()
108+
serverMinAPIVersion, _ := util.GetDockerServerMinAPIVersion() // nolint: gosec
109109

110110
// Older clients can talk to newer servers, and when you ask a newer server
111111
// it's version in the presence of an older server it will downgrade it's
@@ -116,7 +116,7 @@ func (cmd *Doctor) Run(c *cli.Context) error {
116116
if serverMinAPIVersion != nil {
117117
constraintString = fmt.Sprintf(">= %s", serverMinAPIVersion)
118118
}
119-
apiConstraint, _ := version.NewConstraint(constraintString)
119+
apiConstraint, _ := version.NewConstraint(constraintString) // nolint: gosec
120120

121121
if err != nil {
122122
cmd.out.Error("Could not determine Docker Machine Docker versions: ", err)

commands/kill.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ func (cmd *Kill) Run(c *cli.Context) error {
4141
}
4242

4343
cmd.out.Spin(fmt.Sprintf("Killing machine '%s'...", cmd.machine.Name))
44-
util.StreamCommand("docker-machine", "kill", cmd.machine.Name)
44+
util.StreamCommand("docker-machine", "kill", cmd.machine.Name) // nolint: gosec
4545

4646
// Ensure the underlying virtualization has stopped
4747
driver := cmd.machine.GetDriver()
4848
switch driver {
4949
case util.VirtualBox:
50-
util.StreamCommand("controlvm", cmd.machine.Name, "poweroff")
50+
util.StreamCommand("controlvm", cmd.machine.Name, "poweroff") // nolint: gosec
5151
case util.VMWare:
5252
cmd.out.Warning("Add vmrun suspend command.")
5353
case util.Xhyve:

commands/machine.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ type Machine struct {
2121
}
2222

2323
// Create will generate a new Docker Machine configured according to user specification
24-
func (m *Machine) Create(driver string, cpuCount string, memSize string, diskSize string) error {
24+
func (m *Machine) Create(driver string, cpuCount string, memSize string, diskSize string, isoURL string) error {
2525
m.out.Info("Creating a %s machine named '%s' with CPU(%s) MEM(%s) DISK(%s)...", driver, m.Name, cpuCount, memSize, diskSize)
2626

27-
boot2dockerURL := "https://github.com/boot2docker/boot2docker/releases/download/v" + util.GetRawCurrentDockerVersion() + "/boot2docker.iso"
27+
boot2dockerURL := isoURL
28+
if boot2dockerURL == "" {
29+
boot2dockerURL = "https://github.com/boot2docker/boot2docker/releases/download/v" + util.GetRawCurrentDockerVersion() + "/boot2docker.iso"
30+
}
2831

2932
var create util.Executor
3033

@@ -144,19 +147,19 @@ func (m *Machine) SetEnv() {
144147
if js.Get("HostOptions").Get("EngineOptions").Get("TlsVerify").MustBool() {
145148
tlsVerify = 1
146149
}
147-
os.Setenv("DOCKER_TLS_VERIFY", fmt.Sprintf("%d", tlsVerify))
148-
os.Setenv("DOCKER_HOST", fmt.Sprintf("tcp://%s:2376", js.Get("Driver").Get("IPAddress").MustString()))
149-
os.Setenv("DOCKER_MACHINE_NAME", js.Get("Driver").Get("MachineName").MustString())
150-
os.Setenv("DOCKER_CERT_PATH", js.Get("HostOptions").Get("AuthOptions").Get("StorePath").MustString())
150+
os.Setenv("DOCKER_TLS_VERIFY", fmt.Sprintf("%d", tlsVerify)) // nolint: gosec
151+
os.Setenv("DOCKER_HOST", fmt.Sprintf("tcp://%s:2376", js.Get("Driver").Get("IPAddress").MustString())) // nolint: gosec
152+
os.Setenv("DOCKER_MACHINE_NAME", js.Get("Driver").Get("MachineName").MustString()) // nolint: gosec
153+
os.Setenv("DOCKER_CERT_PATH", js.Get("HostOptions").Get("AuthOptions").Get("StorePath").MustString()) // nolint: gosec
151154
}
152155
}
153156

154157
// UnsetEnv will remove the Docker proxy variables
155158
func (m *Machine) UnsetEnv() {
156-
os.Unsetenv("DOCKER_TLS_VERIFY")
157-
os.Unsetenv("DOCKER_HOST")
158-
os.Unsetenv("DOCKER_CERT_PATH")
159-
os.Unsetenv("DOCKER_MACHINE_NAME")
159+
os.Unsetenv("DOCKER_TLS_VERIFY") // nolint: gosec
160+
os.Unsetenv("DOCKER_HOST") // nolint: gosec
161+
os.Unsetenv("DOCKER_CERT_PATH") // nolint: gosec
162+
os.Unsetenv("DOCKER_MACHINE_NAME") // nolint: gosec
160163
}
161164

162165
// Exists determines if the Docker Machine exist

commands/project_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewProjectConfig() *ProjectConfig {
4444
projectConfigFile := os.Getenv("RIG_PROJECT_CONFIG_FILE")
4545

4646
if projectConfigFile == "" {
47-
projectConfigFile, _ = FindProjectConfigFilePath()
47+
projectConfigFile, _ = FindProjectConfigFilePath() // nolint: gosec
4848
}
4949

5050
if projectConfigFile != "" {
@@ -83,7 +83,7 @@ func FindProjectConfigFilePath() (string, error) {
8383
// nolint: gocyclo
8484
func NewProjectConfigFromFile(filename string) (*ProjectConfig, error) {
8585
logger := util.Logger()
86-
filepath, _ := filepath.Abs(filename)
86+
filepath, _ := filepath.Abs(filename) // nolint: gosec
8787
config := &ProjectConfig{
8888
File: filename,
8989
Path: filepath,

0 commit comments

Comments
 (0)