Skip to content

Commit

Permalink
Refresh updatefile on each check even if we're not updating, fixes #479
Browse files Browse the repository at this point in the history
… (#489)

* Refresh updatefile on each check even if we're not updating, fixes #479

* Move docker check to top so update check can just fail
  • Loading branch information
rfay committed Sep 30, 2017
1 parent 855a64c commit c860c12
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions cmd/ddev/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import (
)

var (
logLevel = log.WarnLevel
plugin = "local"
// 1 week
updateInterval = time.Hour * 24 * 7
logLevel = log.WarnLevel
plugin = "local"
updateInterval = time.Hour * 24 * 7 // One week interval between updates
serviceType string
)

Expand Down Expand Up @@ -50,6 +49,17 @@ var RootCmd = &cobra.Command{
}
}

err := dockerutil.CheckDockerVersion(version.DockerVersionConstraint)
if err != nil {
if err.Error() == "no docker" {
if os.Args[1] != "version" && os.Args[1] != "config" {
util.Failed("Could not connect to docker. Please ensure Docker is installed and running.")
}
} else {
util.Failed("The docker version currently installed does not meet ddev's requirements: %v", err)
}
}

// Verify that the ~/.ddev exists
userDdevDir := util.GetGlobalDdevDir()

Expand All @@ -62,6 +72,13 @@ var RootCmd = &cobra.Command{
}

if timeToCheckForUpdates {
// Recreate the updatefile with current time so we won't do this again soon.
err = updatecheck.ResetUpdateTime(updateFile)
if err != nil {
util.Warning("Failed to update updatecheck file %s", updateFile)
return // Do not continue as we'll end up with github api violations.
}

// nolint: vetshadow
updateNeeded, updateURL, err := updatecheck.AvailableUpdates("drud", "ddev", version.DdevVersion)

Expand All @@ -73,23 +90,9 @@ var RootCmd = &cobra.Command{

if updateNeeded {
util.Warning("\n\nA new update is available! please visit %s to download the update!\n\n", updateURL)
err = updatecheck.ResetUpdateTime(updateFile)
if err != nil {
util.Warning("Could not reset automated update checking interval: %v", err)
}
}
}

err = dockerutil.CheckDockerVersion(version.DockerVersionConstraint)
if err != nil {
if err.Error() == "no docker" {
if os.Args[1] != "version" && os.Args[1] != "config" {
util.Failed("Could not connect to docker. Please ensure Docker is installed and running.")
}
} else {
util.Failed("The docker version currently installed does not meet ddev's requirements: %v", err)
}
}
},
}

Expand Down

0 comments on commit c860c12

Please sign in to comment.