providers/docker: warning with host VM about forwarded ports
This commit is contained in:
parent
19c9973a0d
commit
09cc823065
|
@ -27,6 +27,7 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
b2.use HostMachinePortWarning
|
||||
b2.use HostMachinePortChecker
|
||||
b2.use HandleForwardedPortCollisions
|
||||
b2.use PrepareNFSValidIds
|
||||
|
@ -220,6 +221,7 @@ module VagrantPlugins
|
|||
autoload :HasSSH, action_root.join("has_ssh")
|
||||
autoload :HostMachine, action_root.join("host_machine")
|
||||
autoload :HostMachinePortChecker, action_root.join("host_machine_port_checker")
|
||||
autoload :HostMachinePortWarning, action_root.join("host_machine_port_warning")
|
||||
autoload :HostMachineRequired, action_root.join("host_machine_required")
|
||||
autoload :HostMachineSyncFolders, action_root.join("host_machine_sync_folders")
|
||||
autoload :HostMachineSyncFoldersDisable, action_root.join("host_machine_sync_folders_disable")
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
module VagrantPlugins
|
||||
module DockerProvider
|
||||
module Action
|
||||
class HostMachinePortWarning
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
if !env[:machine].provider.host_vm?
|
||||
return @app.call(env)
|
||||
end
|
||||
|
||||
# If we have forwarded ports, then notify the user that they
|
||||
# won't be immediately available unless a private network
|
||||
# is created.
|
||||
if has_forwarded_ports?(env[:machine])
|
||||
env[:machine].ui.warn(I18n.t(
|
||||
"docker_provider.host_machine_forwarded_ports"))
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def has_forwarded_ports?(machine)
|
||||
machine.config.vm.networks.each do |type, _|
|
||||
return true if type == :forwarded_port
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,6 +6,12 @@ en:
|
|||
Container created: %{id}
|
||||
host_machine_disabling_folders: |-
|
||||
Removing synced folders...
|
||||
host_machine_forwarded_ports: |-
|
||||
Warning: When using a remote Docker host, forwarded ports will NOT be
|
||||
immediately available on your machine. They will still be forwarded on
|
||||
the remote machine, however, so if you have a way to access the remote
|
||||
machine, then you should be able to access those ports there. This is
|
||||
not an error, it is only an informational message.
|
||||
host_machine_needed: |-
|
||||
Docker host is required. One will be created if necessary...
|
||||
host_machine_ready: |-
|
||||
|
|
Loading…
Reference in New Issue