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

Commit 67c90c1

Browse files
committed
Merge pull request #377 from tianon/deprecation
Deprecate boot2docker-cli officially
2 parents 29dabce + 35e2fc4 commit 67c90c1

4 files changed

Lines changed: 62 additions & 65 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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
4+
Machine](https://docs.docker.com/machine/). The code and documentation here
5+
only exist as a reference for users who have not yet switched over (but please
6+
do soon). The recommended way to install Machine is with the [Docker
7+
Toolbox](https://docker.com/toolbox).
88

99
# boot2docker command line management tool
1010

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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"fmt"
5+
"io/ioutil"
6+
"net/http"
57
"os"
68
)
79

@@ -11,6 +13,16 @@ var (
1113
GitSHA string
1214
)
1315

16+
const (
17+
hardcodedWarning = `
18+
WARNING: The 'boot2docker' command line interface is being officially deprecated.
19+
Users are expected to switch to Docker Machine (https://docs.docker.com/machine/) instead ASAP.
20+
The Docker Toolbox is the recommended way to install it: https://docker.com/toolbox/
21+
22+
`
23+
warningURL = "https://raw.githubusercontent.com/boot2docker/boot2docker-cli/master/DEPRECATION_WARNING"
24+
)
25+
1426
type unknownCommandError struct {
1527
cmd string
1628
}
@@ -48,8 +60,10 @@ func run() error {
4860
case "config", "cfg":
4961
return cmdConfig()
5062
case "init":
63+
printDeprecationWarning()
5164
return cmdInit()
5265
case "up", "start", "boot", "resume":
66+
printDeprecationWarning()
5367
return cmdUp()
5468
case "save", "suspend":
5569
return cmdSave()
@@ -88,3 +102,27 @@ func run() error {
88102
return unknownCommandError{cmd: cmd}
89103
}
90104
}
105+
106+
func printDeprecationWarning() {
107+
var (
108+
warning string
109+
)
110+
111+
// Try to get the warning from the Github raw URL. If there's any
112+
// failure along the way, e.g. network, just fall back to the default
113+
// warning hardcoded in the source.
114+
resp, err := http.Get(warningURL)
115+
if err != nil || resp.StatusCode != http.StatusOK {
116+
warning = hardcodedWarning
117+
} else {
118+
defer resp.Body.Close()
119+
body, err := ioutil.ReadAll(resp.Body)
120+
if err != nil {
121+
warning = hardcodedWarning
122+
} else {
123+
warning = string(body)
124+
}
125+
}
126+
127+
fmt.Fprintln(os.Stderr, warning)
128+
}

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)