mirror of https://github.com/docker/docs.git
Implement upgrade for Ubuntu provisioner
Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
parent
f010a7bb80
commit
a04b908fd3
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/docker/machine/libmachine/auth"
|
"github.com/docker/machine/libmachine/auth"
|
||||||
"github.com/docker/machine/libmachine/engine"
|
"github.com/docker/machine/libmachine/engine"
|
||||||
"github.com/docker/machine/libmachine/provision"
|
"github.com/docker/machine/libmachine/provision"
|
||||||
|
"github.com/docker/machine/libmachine/provision/pkgaction"
|
||||||
"github.com/docker/machine/libmachine/swarm"
|
"github.com/docker/machine/libmachine/swarm"
|
||||||
"github.com/docker/machine/ssh"
|
"github.com/docker/machine/ssh"
|
||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
|
@ -221,8 +222,19 @@ func (h *Host) Restart() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) Upgrade() error {
|
func (h *Host) Upgrade() error {
|
||||||
// TODO: refactor to provisioner
|
provisioner, err := provision.DetectProvisioner(h.Driver)
|
||||||
return fmt.Errorf("centralized upgrade coming in the provisioner")
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := provisioner.Service("docker", pkgaction.Restart); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) Remove(force bool) error {
|
func (h *Host) Remove(force bool) error {
|
||||||
|
|
|
@ -27,11 +27,13 @@ type PackageAction int
|
||||||
const (
|
const (
|
||||||
Install PackageAction = iota
|
Install PackageAction = iota
|
||||||
Remove
|
Remove
|
||||||
|
Upgrade
|
||||||
)
|
)
|
||||||
|
|
||||||
var packageActions = []string{
|
var packageActions = []string{
|
||||||
"install",
|
"install",
|
||||||
"remove",
|
"remove",
|
||||||
|
"upgrade",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s PackageAction) String() string {
|
func (s PackageAction) String() string {
|
||||||
|
|
|
@ -56,6 +56,14 @@ func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.Pack
|
||||||
packageAction = "install"
|
packageAction = "install"
|
||||||
case pkgaction.Remove:
|
case pkgaction.Remove:
|
||||||
packageAction = "remove"
|
packageAction = "remove"
|
||||||
|
case pkgaction.Upgrade:
|
||||||
|
packageAction = "upgrade"
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This should probably have a const
|
||||||
|
switch name {
|
||||||
|
case "docker":
|
||||||
|
name = "lxc-docker"
|
||||||
}
|
}
|
||||||
|
|
||||||
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive sudo -E apt-get %s -y %s", packageAction, name)
|
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive sudo -E apt-get %s -y %s", packageAction, name)
|
||||||
|
|
Loading…
Reference in New Issue