-
Notifications
You must be signed in to change notification settings - Fork 0
/
facade.rb
executable file
·43 lines (39 loc) · 1.27 KB
/
facade.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Include ruby tweaks
require_relative 'tools'
# Models
require_relative "model/config"
require_relative "model/component"
require_relative "model/errors"
# Singleton to dispatch all plugin actions
class Facade
# Map Components more configs to components
COMPONENT_CONFIGS = {
Base: false, # false give flat config object without nested
Provider: [:project_name],
Network: [:domain],
Ansible: [:git],
Fs: [:paths],
Hooks: [:hooks]
}
# Passing to each module vagrant object and part of the config struct
def initialize(vagrant, dir, manala = true)
$vagrant = vagrant # Vagrant object
$__dir__ = dir # Keep Vagrantfile dir
c = Config.new # instanciate a config factory
COMPONENT_CONFIGS.each do |plugin, cnfs|
require_relative "components/#{plugin.downcase}"
# Dependency injection system
configs_arg = [c.get(cnfs ? plugin.downcase : nil)]
cnfs ? cnfs.each { |param| configs_arg.push(c.get(param)) } : nil
Object.const_get(plugin).new(*configs_arg)
end
end
# end class VagrantBootstrap
end
# Add common fixes depending on actuals vagrant issues
# vagrant/vbox dhcp error (v2.2.7)
class VagrantPlugins::ProviderVirtualBox::Action::Network
def dhcp_server_matches_config?(dhcp_server, config)
true
end
end