provisioners/docker: Simplify raising of Docker related errors
This commit is contained in:
parent
0536817e90
commit
82fc9330af
|
@ -22,7 +22,7 @@ module VagrantPlugins
|
||||||
@machine.guest.capability(:docker_install, @version)
|
@machine.guest.capability(:docker_install, @version)
|
||||||
|
|
||||||
if !@machine.guest.capability(:docker_installed)
|
if !@machine.guest.capability(:docker_installed)
|
||||||
raise Errors::DockerInstallFailed
|
raise DockerError, :install_failed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module Docker
|
|
||||||
module Errors
|
|
||||||
class DockerInstallFailed < ::Vagrant::Errors::VagrantError
|
|
||||||
end
|
|
||||||
|
|
||||||
class DockerNotRunning < ::Vagrant::Errors::VagrantError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +1,12 @@
|
||||||
require_relative "errors"
|
|
||||||
require_relative "docker_client"
|
require_relative "docker_client"
|
||||||
require_relative "docker_installer"
|
require_relative "docker_installer"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Docker
|
module Docker
|
||||||
|
class DockerError < Vagrant::Errors::VagrantError
|
||||||
|
error_namespace("vagrant.provisioners.docker")
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: Improve handling of vagrant-lxc specifics (like checking for apparmor
|
# TODO: Improve handling of vagrant-lxc specifics (like checking for apparmor
|
||||||
# profile stuff + autocorrection)
|
# profile stuff + autocorrection)
|
||||||
class Provisioner < Vagrant.plugin("2", :provisioner)
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
|
@ -15,7 +18,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def provision
|
def provision
|
||||||
@logger = Log4r::Logger.new("vagrant::provisioners::vocker")
|
@logger = Log4r::Logger.new("vagrant::provisioners::docker")
|
||||||
|
|
||||||
@logger.info("Checking for Docker installation...")
|
@logger.info("Checking for Docker installation...")
|
||||||
@installer.ensure_installed
|
@installer.ensure_installed
|
||||||
|
@ -23,7 +26,7 @@ module VagrantPlugins
|
||||||
# Attempt to start service if not running
|
# Attempt to start service if not running
|
||||||
@client.start_service
|
@client.start_service
|
||||||
unless @client.daemon_running?
|
unless @client.daemon_running?
|
||||||
raise Errors::DockerNotRunning
|
raise DockerError, :not_running
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.images.any?
|
if config.images.any?
|
||||||
|
|
|
@ -1295,3 +1295,7 @@ en:
|
||||||
playbook_path_invalid: "`playbook` for the Ansible provisioner does not exist on the host system: %{path}"
|
playbook_path_invalid: "`playbook` for the Ansible provisioner does not exist on the host system: %{path}"
|
||||||
inventory_path_invalid: "`inventory_path` for the Ansible provisioner does not exist on the host system: %{path}"
|
inventory_path_invalid: "`inventory_path` for the Ansible provisioner does not exist on the host system: %{path}"
|
||||||
extra_vars_invalid: "`extra_vars` for the Ansible provisioner must be a hash or a path to an existing file. Received: %{value} (as %{type})"
|
extra_vars_invalid: "`extra_vars` for the Ansible provisioner must be a hash or a path to an existing file. Received: %{value} (as %{type})"
|
||||||
|
|
||||||
|
docker:
|
||||||
|
not_running: "Docker is not running on the guest VM."
|
||||||
|
install_failed: "Docker installation failed."
|
||||||
|
|
Loading…
Reference in New Issue