本文整理汇总了Golang中github.com/docker/machine/libmachine/provision/pkgaction.PackageAction类的典型用法代码示例。如果您正苦于以下问题:Golang PackageAction类的具体用法?Golang PackageAction怎么用?Golang PackageAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageAction类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Package
func (provisioner *DebianProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
updateMetadata := true
switch action {
case pkgaction.Install, pkgaction.Upgrade:
packageAction = "install"
case pkgaction.Remove:
packageAction = "remove"
updateMetadata = false
}
switch name {
case "docker":
name = "docker-engine"
}
if updateMetadata {
if _, err := provisioner.SSHCommand("sudo apt-get update"); err != nil {
return err
}
}
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive sudo -E apt-get %s -y %s", packageAction, name)
log.Debugf("package: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}
示例2: Package
func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
updateMetadata := true
switch action {
case pkgaction.Install, pkgaction.Upgrade:
packageAction = "install"
case pkgaction.Remove:
packageAction = "remove"
updateMetadata = false
}
switch name {
case "docker":
name = "docker-engine"
}
if updateMetadata {
if err := waitForLockAptGetUpdate(provisioner); err != nil {
return err
}
}
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive sudo -E apt-get %s -y -o Dpkg::Options::=\"--force-confnew\" %s", packageAction, name)
log.Debugf("package: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}
示例3: Package
func (provisioner *ArchProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
updateMetadata := true
switch action {
case pkgaction.Install, pkgaction.Upgrade:
packageAction = "S"
case pkgaction.Remove:
packageAction = "R"
updateMetadata = false
}
switch name {
case "docker":
name = "docker"
}
pacmanOpts := "-" + packageAction
if updateMetadata {
pacmanOpts = pacmanOpts + "y"
}
pacmanOpts = pacmanOpts + " --noconfirm --noprogressbar"
command := fmt.Sprintf("sudo -E pacman %s %s", pacmanOpts, name)
log.Debugf("package: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}
示例4: Package
func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
updateMetadata := true
switch action {
case pkgaction.Install, pkgaction.Upgrade:
packageAction = "install"
case pkgaction.Remove:
packageAction = "remove"
updateMetadata = false
}
switch name {
case "docker":
name = "docker-engine"
}
if updateMetadata {
apt_update := provisioner.Driver.SSHSudo("apt-get update")
if _, err := provisioner.SSHCommand(apt_update); err != nil {
return err
}
}
// handle the new docker-engine package; we can probably remove this
// after we have a few versions
if action == pkgaction.Upgrade && name == "docker-engine" {
// run the force remove on the existing lxc-docker package
// and remove the existing apt source list
// also re-run the get.docker.com script to properly setup
// the system again
commands := []string{
"rm /etc/apt/sources.list.d/docker.list || true",
"apt-get remove -y lxc-docker || true",
"curl -sSL https://get.docker.com | sh",
}
for _, cmd := range commands {
command := fmt.Sprintf("sudo DEBIAN_FRONTEND=noninteractive %s", cmd)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
}
}
apt_action := provisioner.Driver.SSHSudo("apt-get %s -y %s")
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive && %s", apt_action)
command = fmt.Sprintf(command, packageAction, name)
log.Debugf("package: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}
示例5: Package
func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
updateMetadata := true
switch action {
case pkgaction.Install, pkgaction.Upgrade:
packageAction = "install"
case pkgaction.Remove:
packageAction = "remove"
updateMetadata = false
}
switch name {
case "docker":
name = "docker-engine"
}
if updateMetadata {
if _, err := provisioner.SSHCommand("sudo apt-get update"); err != nil {
return err
}
}
// handle the new docker-engine package; we can probably remove this
// after we have a few versions
if action == pkgaction.Upgrade && name == "docker-engine" {
// run the force remove on the existing lxc-docker package
// and remove the existing apt source list
commands := []string{
"rm /etc/apt/sources.list.d/docker.list || true",
"apt-get remove -y lxc-docker || true",
}
for _, cmd := range commands {
command := fmt.Sprintf("sudo DEBIAN_FRONTEND=noninteractive %s", cmd)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
}
}
command := fmt.Sprintf("DEBIAN_FRONTEND=noninteractive sudo -E apt-get %s -y -o Dpkg::Options::=\"--force-confnew\" %s", packageAction, name)
log.Debugf("package: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}
示例6: Package
func (provisioner *SUSEProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string
switch action {
case pkgaction.Install:
packageAction = "in"
case pkgaction.Remove:
packageAction = "rm"
case pkgaction.Upgrade:
packageAction = "up"
}
command := fmt.Sprintf("sudo -E zypper -n %s %s", packageAction, name)
log.Debugf("zypper: action=%s name=%s", action.String(), name)
if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
return nil
}