Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 901b10c

Browse files
committed
Deprecate boot2docker-cli officially
1 parent 8fdc6f5 commit 901b10c

4 files changed

Lines changed: 23 additions & 65 deletions

File tree

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# Pending Deprecation
1+
# Deprecated
22

3-
This project is officially in bug fixing/maintenance mode in favor of all
4-
concerted effort going towards [Docker
5-
Machine](https://github.com/docker/machine) instead. Merging of complex
6-
features will require some pretty strong convincing as to why they should exist
7-
here, and not instead be proposed for Docker Machine.
3+
This project is officially deprecated in favor of [Docker Machine](https://docs.docker.com/machine/). The code and documentation here only exist as a reference for users who have not yet switched over (but please do soon).
84

95
# boot2docker command line management tool
106

cmds.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"io/ioutil"
7-
"net/http"
87
"os"
98
"os/exec"
109
"path/filepath"
@@ -357,16 +356,6 @@ func cmdPoweroff() error {
357356

358357
// Upgrade the boot2docker ISO - preserving server state
359358
func cmdUpgrade() error {
360-
if runtime.GOOS == "darwin" || runtime.GOOS == "linux" {
361-
if B2D.Clobber {
362-
err := upgradeDockerClientBinary()
363-
if err != nil {
364-
return err
365-
}
366-
} else {
367-
fmt.Println("Skipping client binary download, use --clobber=true to enable...")
368-
}
369-
}
370359
if err := upgradeBoot2DockerBinary(); err != nil {
371360
return fmt.Errorf("Error upgrading boot2docker binary: %s", err)
372361
}
@@ -422,46 +411,6 @@ func upgradeBoot2DockerBinary() error {
422411
return nil
423412
}
424413

425-
func upgradeDockerClientBinary() error {
426-
var (
427-
clientOs, clientArch string
428-
)
429-
resp, err := http.Get("https://get.docker.com/latest")
430-
if err != nil {
431-
return fmt.Errorf("Error checking the latest version of Docker: %s", err)
432-
}
433-
defer resp.Body.Close()
434-
latestVersionBytes, err := ioutil.ReadAll(resp.Body)
435-
if err != nil {
436-
return fmt.Errorf("Error reading response body on latest version of Docker call: %s", err)
437-
}
438-
latestVersion := strings.TrimSpace(string(latestVersionBytes))
439-
localClientVersion, err := getLocalClientVersion()
440-
if err != nil {
441-
return fmt.Errorf("Error getting local Docker client version: %s", err)
442-
}
443-
switch runtime.GOARCH {
444-
case "amd64":
445-
clientArch = "x86_64"
446-
default:
447-
return fmt.Errorf("Architecture not supported")
448-
}
449-
450-
switch runtime.GOOS {
451-
case "darwin":
452-
clientOs = "Darwin"
453-
case "linux":
454-
clientOs = "Linux"
455-
default:
456-
return fmt.Errorf("Operating system not supported")
457-
}
458-
binaryUrl := fmt.Sprintf("https://get.docker.com/builds/%s/%s/docker-latest", clientOs, clientArch)
459-
if err := attemptUpgrade(binaryUrl, "docker", latestVersion, localClientVersion); err != nil {
460-
return fmt.Errorf("Error attempting upgrade: %s", err)
461-
}
462-
return nil
463-
}
464-
465414
func attemptUpgrade(binaryUrl, binaryName, latestVersion, localVersion string) error {
466415
if (latestVersion != localVersion && !strings.Contains(latestVersion, "rc")) || B2D.ForceUpgradeDownload {
467416
if err := backupAndDownload(binaryUrl, binaryName, localVersion); err != nil {

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
)
78

89
// The following vars will be injected during the build process.
@@ -20,6 +21,8 @@ func (e unknownCommandError) Error() string {
2021
}
2122

2223
func main() {
24+
fmt.Fprintf(os.Stderr, "\n WARNING: the %q command is officially deprecated.\n Please switch to Docker Machine (https://docs.docker.com/machine/)\n as soon as possible.\n\n", filepath.Base(os.Args[0]))
25+
2326
// os.Exit will terminate the program at the place of call without running
2427
// any deferred cleanup statements. It might cause unintended effects. To
2528
// be safe, we wrap the program in run() and only os.Exit() outside the

util.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ func getLatestReleaseName(url string) (string, error) {
110110
defer rsp.Body.Close()
111111

112112
var t []struct {
113-
Name string `json:"name"`
114-
TagName string `json:"tag_name"`
113+
// ".../tags" endpoints
114+
Name string `json:"name"`
115+
116+
// ".../releases" endpoints
117+
TagName string `json:"tag_name"`
118+
Prerelease bool `json:"prerelease"`
115119
}
116120
body, err := ioutil.ReadAll(rsp.Body)
117121
if err != nil {
@@ -129,19 +133,25 @@ func getLatestReleaseName(url string) (string, error) {
129133
return "", fmt.Errorf("Error getting releases: %s\n see %s", e.Message, e.DocumentationUrl)
130134
}
131135
if len(t) == 0 {
132-
return "", fmt.Errorf("no releases found")
136+
return "", fmt.Errorf("no releases found at %q", url)
133137
}
134138

135139
// Looking up by tag instead of release.
136140
// Github API call for docker releases yields nothing,
137141
// so we use tags API call in this case.
138-
name := ""
139142
if strings.Contains(url, "tags") {
140-
name = t[0].Name
141-
} else {
142-
name = t[0].TagName
143+
return t[0].Name, nil
144+
}
145+
146+
for _, rel := range t {
147+
if rel.Prerelease {
148+
// skip "pre-releases" (RCs, etc) entirely
149+
continue
150+
}
151+
return rel.TagName, nil
143152
}
144-
return name, nil
153+
154+
return "", fmt.Errorf("no non-prerelease releases found at %q", url)
145155
}
146156

147157
func getLocalClientVersion() (string, error) {

0 commit comments

Comments
 (0)