vagrant-invade 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.idea/dictionaries/lenste.xml +14 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +81 -1
- data/README.md +37 -4
- data/invade.yml.dist +6 -0
- data/lib/vagrant-invade/action/check.rb +44 -0
- data/lib/vagrant-invade/action/config.rb +4 -3
- data/lib/vagrant-invade/action/create.rb +30 -63
- data/lib/vagrant-invade/action/process.rb +139 -0
- data/lib/vagrant-invade/action.rb +21 -14
- data/lib/vagrant-invade/command/build.rb +6 -9
- data/lib/vagrant-invade/command/check.rb +33 -0
- data/lib/vagrant-invade/command/init.rb +3 -3
- data/lib/vagrant-invade/command/root.rb +15 -9
- data/lib/vagrant-invade/command/validate.rb +8 -7
- data/lib/vagrant-invade/extend.rb +24 -0
- data/lib/vagrant-invade/generator/type.rb +15 -0
- data/lib/vagrant-invade/generator.rb +48 -4
- data/lib/vagrant-invade/helper/checksum.rb +58 -0
- data/lib/vagrant-invade/helper.rb +9 -0
- data/lib/vagrant-invade/{builder → module/hostmanager}/hostmanager.rb +3 -7
- data/lib/vagrant-invade/module/hostmanager/rules.yml +15 -0
- data/lib/vagrant-invade/{template/hostmanager.erb → module/hostmanager/template.erb} +1 -1
- data/lib/vagrant-invade/module/invade/invade.rb +12 -0
- data/lib/vagrant-invade/module/invade/machine/machine.rb +46 -0
- data/lib/vagrant-invade/{template/machine.erb → module/invade/machine/template.erb} +6 -2
- data/lib/vagrant-invade/{builder/network → module/network/forwarded_port}/forwarded_port.rb +3 -5
- data/lib/vagrant-invade/module/network/forwarded_port/rules.yml +19 -0
- data/lib/vagrant-invade/module/network/forwarded_port/template.erb +8 -0
- data/lib/vagrant-invade/module/network/network.rb +13 -0
- data/lib/vagrant-invade/{builder/network/private_network.rb → module/network/private/private.rb} +25 -11
- data/lib/vagrant-invade/module/network/private/rules.yml +16 -0
- data/lib/vagrant-invade/module/network/private/template.erb +5 -0
- data/lib/vagrant-invade/{builder/network/public_network.rb → module/network/public/public.rb} +3 -5
- data/lib/vagrant-invade/module/network/public/rules.yml +13 -0
- data/lib/vagrant-invade/{template/network/public_network.erb → module/network/public/template.erb} +0 -0
- data/lib/vagrant-invade/module/nfs/nfs.rb +36 -0
- data/lib/vagrant-invade/module/nfs/rules.yml +12 -0
- data/lib/vagrant-invade/module/nfs/template.erb +12 -0
- data/lib/vagrant-invade/{builder/plugin → module/plugin/hostmanager}/hostmanager.rb +7 -10
- data/lib/vagrant-invade/module/plugin/hostmanager/rules.yml +4 -0
- data/lib/vagrant-invade/{template/plugin/hostmanager.erb → module/plugin/hostmanager/template.erb} +0 -0
- data/lib/vagrant-invade/module/plugin/plugin.rb +13 -0
- data/lib/vagrant-invade/{builder/plugin → module/plugin/r10k}/r10k.rb +6 -9
- data/lib/vagrant-invade/module/plugin/r10k/rules.yml +15 -0
- data/lib/vagrant-invade/{template/plugin/r10k.erb → module/plugin/r10k/template.erb} +0 -0
- data/lib/vagrant-invade/module/plugin/winnfsd/rules.yml +10 -0
- data/lib/vagrant-invade/{template/plugin/winnfsd.erb → module/plugin/winnfsd/template.erb} +0 -0
- data/lib/vagrant-invade/{builder/plugin → module/plugin/winnfsd}/winnfsd.rb +5 -8
- data/lib/vagrant-invade/module/provider/provider.rb +12 -0
- data/lib/vagrant-invade/module/provider/virtualbox/rules.yml +25 -0
- data/lib/vagrant-invade/module/provider/virtualbox/template.erb +26 -0
- data/lib/vagrant-invade/{builder/provider → module/provider/virtualbox}/virtualbox.rb +6 -6
- data/lib/vagrant-invade/module/provider/vmware/rules.yml +13 -0
- data/lib/vagrant-invade/{template/provider/vmware.erb → module/provider/vmware/template.erb} +9 -0
- data/lib/vagrant-invade/{builder/provider → module/provider/vmware}/vmware.rb +4 -6
- data/lib/vagrant-invade/module/provision/provision.rb +15 -0
- data/lib/vagrant-invade/{builder/provision → module/provision/puppet_agent}/puppet_agent.rb +3 -6
- data/lib/vagrant-invade/module/provision/puppet_agent/rules.yml +19 -0
- data/lib/vagrant-invade/{template/provision/puppet_agent.erb → module/provision/puppet_agent/template.erb} +0 -0
- data/lib/vagrant-invade/{builder/provision → module/provision/puppet_apply}/puppet_apply.rb +11 -6
- data/lib/vagrant-invade/module/provision/puppet_apply/rules.yml +41 -0
- data/lib/vagrant-invade/module/provision/puppet_apply/template.erb +41 -0
- data/lib/vagrant-invade/module/provision/salt/rules.yml +64 -0
- data/lib/vagrant-invade/module/provision/salt/salt.rb +61 -0
- data/lib/vagrant-invade/module/provision/salt/template.erb +67 -0
- data/lib/vagrant-invade/module/provision/shell/rules.yml +12 -0
- data/lib/vagrant-invade/{builder/provision → module/provision/shell}/shell.rb +6 -10
- data/lib/vagrant-invade/module/provision/shell/template.erb +1 -0
- data/lib/vagrant-invade/module/provision/shell_inline/rules.yml +12 -0
- data/lib/vagrant-invade/{builder/provision → module/provision/shell_inline}/shell_inline.rb +6 -10
- data/lib/vagrant-invade/module/provision/shell_inline/template.erb +1 -0
- data/lib/vagrant-invade/module/ssh/rules.yml +48 -0
- data/lib/vagrant-invade/{builder → module/ssh}/ssh.rb +4 -6
- data/lib/vagrant-invade/module/ssh/template.erb +1 -0
- data/lib/vagrant-invade/{builder/synced_folder → module/synced_folder/nfs}/nfs.rb +3 -6
- data/lib/vagrant-invade/module/synced_folder/nfs/rules.yml +22 -0
- data/lib/vagrant-invade/module/synced_folder/nfs/template.erb +2 -0
- data/lib/vagrant-invade/module/synced_folder/synced_folder.rb +12 -0
- data/lib/vagrant-invade/module/synced_folder/virtualbox/rules.yml +21 -0
- data/lib/vagrant-invade/{template/synced_folder/virtualbox.erb → module/synced_folder/virtualbox/template.erb} +0 -0
- data/lib/vagrant-invade/{builder/synced_folder → module/synced_folder/virtualbox}/virtualbox.rb +3 -6
- data/lib/vagrant-invade/module/vm/rules.yml +9 -0
- data/lib/vagrant-invade/{template/vm/vm.erb → module/vm/template.erb} +0 -0
- data/lib/vagrant-invade/{builder → module/vm}/vm.rb +3 -7
- data/lib/vagrant-invade/module.rb +26 -0
- data/lib/vagrant-invade/plugin.rb +3 -5
- data/lib/vagrant-invade/validator/ruleset/yaml_ruleset.rb +97 -0
- data/lib/vagrant-invade/validator/ruleset.rb +12 -0
- data/lib/vagrant-invade/validator/type/type_array.rb +38 -0
- data/lib/vagrant-invade/validator/type/type_boolean.rb +38 -0
- data/lib/vagrant-invade/validator/type/type_hash.rb +39 -0
- data/lib/vagrant-invade/validator/type/type_integer.rb +46 -0
- data/lib/vagrant-invade/validator/type/type_string.rb +42 -0
- data/lib/vagrant-invade/validator/type/type_string_array.rb +42 -0
- data/lib/vagrant-invade/validator/type.rb +14 -0
- data/lib/vagrant-invade/validator.rb +51 -119
- data/lib/vagrant-invade/version.rb +1 -1
- data/lib/vagrant-invade.rb +3 -1
- metadata +85 -82
- data/lib/vagrant-invade/action/generate.rb +0 -115
- data/lib/vagrant-invade/action/validate.rb +0 -161
- data/lib/vagrant-invade/builder/machine.rb +0 -45
- data/lib/vagrant-invade/builder/network.rb +0 -13
- data/lib/vagrant-invade/builder/plugin.rb +0 -13
- data/lib/vagrant-invade/builder/provider.rb +0 -12
- data/lib/vagrant-invade/builder/provision.rb +0 -14
- data/lib/vagrant-invade/builder/synced_folder.rb +0 -12
- data/lib/vagrant-invade/builder/vagrantfile.rb +0 -36
- data/lib/vagrant-invade/builder.rb +0 -20
- data/lib/vagrant-invade/generator/hostmanager.rb +0 -23
- data/lib/vagrant-invade/generator/machine.rb +0 -25
- data/lib/vagrant-invade/generator/machine_part/network.rb +0 -38
- data/lib/vagrant-invade/generator/machine_part/plugin.rb +0 -39
- data/lib/vagrant-invade/generator/machine_part/provider.rb +0 -36
- data/lib/vagrant-invade/generator/machine_part/provision.rb +0 -40
- data/lib/vagrant-invade/generator/machine_part/ssh.rb +0 -27
- data/lib/vagrant-invade/generator/machine_part/synced_folder.rb +0 -35
- data/lib/vagrant-invade/generator/machine_part/vm.rb +0 -27
- data/lib/vagrant-invade/generator/machine_part.rb +0 -23
- data/lib/vagrant-invade/generator/vagrantfile.rb +0 -23
- data/lib/vagrant-invade/template/network/forwarded_port.erb +0 -8
- data/lib/vagrant-invade/template/network/private_network.erb +0 -2
- data/lib/vagrant-invade/template/provider/virtualbox.erb +0 -11
- data/lib/vagrant-invade/template/provision/puppet_apply.erb +0 -21
- data/lib/vagrant-invade/template/provision/shell.erb +0 -3
- data/lib/vagrant-invade/template/provision/shell_inline.erb +0 -3
- data/lib/vagrant-invade/template/ssh/ssh.erb +0 -2
- data/lib/vagrant-invade/template/synced_folder/nfs.erb +0 -12
- data/lib/vagrant-invade/template/v2.erb +0 -10
- data/lib/vagrant-invade/validator/hostmanager.rb +0 -56
- data/lib/vagrant-invade/validator/invade.rb +0 -38
- data/lib/vagrant-invade/validator/network/forwarded_port.rb +0 -68
- data/lib/vagrant-invade/validator/network/private_network.rb +0 -44
- data/lib/vagrant-invade/validator/network/public_network.rb +0 -56
- data/lib/vagrant-invade/validator/network.rb +0 -13
- data/lib/vagrant-invade/validator/plugin/hostmanager.rb +0 -34
- data/lib/vagrant-invade/validator/plugin/r10k.rb +0 -53
- data/lib/vagrant-invade/validator/plugin/winnfsd.rb +0 -46
- data/lib/vagrant-invade/validator/plugin.rb +0 -13
- data/lib/vagrant-invade/validator/provider/virtualbox.rb +0 -46
- data/lib/vagrant-invade/validator/provider/vmware.rb +0 -27
- data/lib/vagrant-invade/validator/provider.rb +0 -39
- data/lib/vagrant-invade/validator/provision/puppet_agent.rb +0 -68
- data/lib/vagrant-invade/validator/provision/puppet_apply.rb +0 -62
- data/lib/vagrant-invade/validator/provision/shell.rb +0 -53
- data/lib/vagrant-invade/validator/provision/shell_inline.rb +0 -53
- data/lib/vagrant-invade/validator/provision.rb +0 -24
- data/lib/vagrant-invade/validator/ssh.rb +0 -31
- data/lib/vagrant-invade/validator/synced_folder/nfs.rb +0 -46
- data/lib/vagrant-invade/validator/synced_folder/vb.rb +0 -52
- data/lib/vagrant-invade/validator/synced_folder.rb +0 -36
- data/lib/vagrant-invade/validator/vm.rb +0 -45
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Invade
|
|
3
|
+
module Action
|
|
4
|
+
|
|
5
|
+
include Vagrant::Action::Builtin
|
|
6
|
+
|
|
7
|
+
class Process
|
|
8
|
+
|
|
9
|
+
def initialize(app, env)
|
|
10
|
+
@app = app
|
|
11
|
+
@env = env
|
|
12
|
+
|
|
13
|
+
@validator = VagrantPlugins::Invade::Validator::Validator.new(env)
|
|
14
|
+
@generator = VagrantPlugins::Invade::Generator::Generator.new(env)
|
|
15
|
+
|
|
16
|
+
@logger = Log4r::Logger.new('vagrant::invade::action::validate')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call(env)
|
|
20
|
+
config = env[:invade]
|
|
21
|
+
quiet = @env[:invade_validate_quiet]
|
|
22
|
+
generate = @env[:invade_generate]
|
|
23
|
+
|
|
24
|
+
invade_machine = Hash.new
|
|
25
|
+
invade_machine_part = Hash.new
|
|
26
|
+
invade_vagrantfile = Hash.new
|
|
27
|
+
|
|
28
|
+
###############################################################
|
|
29
|
+
# Validate the settings and set default variables if needed
|
|
30
|
+
###############################################################
|
|
31
|
+
|
|
32
|
+
# Remove empty Hashes
|
|
33
|
+
config.delete_blank
|
|
34
|
+
|
|
35
|
+
config.each do |config_key, config_data|
|
|
36
|
+
|
|
37
|
+
if config_key == 'machines'
|
|
38
|
+
|
|
39
|
+
# Iterate over machine configurations
|
|
40
|
+
config_data.each_with_index do |(machine, machine_part), _|
|
|
41
|
+
|
|
42
|
+
# Iterate over each machine part configuration
|
|
43
|
+
machine_part.each do |machine_part_name, machine_part_data|
|
|
44
|
+
@env[:ui].info("\n[Invade][Machine: #{machine.upcase}]: Validating #{machine_part_name.upcase} part...") unless quiet
|
|
45
|
+
|
|
46
|
+
# Is nested synced_folder, network, provision, or plugin part hash
|
|
47
|
+
if machine_part_data.depth > 1
|
|
48
|
+
|
|
49
|
+
invade_machine_part[machine_part_name] = ''
|
|
50
|
+
machine_part_data.each do |value_name, value_data|
|
|
51
|
+
|
|
52
|
+
# Output info message
|
|
53
|
+
info_message = "\t#{machine_part_name.split('_').collect(&:capitalize).join}: #{value_name}"
|
|
54
|
+
@env[:ui].info(info_message) unless @env[:invade_validate_quiet]
|
|
55
|
+
|
|
56
|
+
# Exception handling for synced_folder and provision types
|
|
57
|
+
if machine_part_name == 'synced_folder' or machine_part_name == 'provision'
|
|
58
|
+
value_name = value_data['type']
|
|
59
|
+
value_data.delete('type')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
validated_data = validate(machine_part_name, value_name, value_data, machine_part_data.depth)
|
|
63
|
+
invade_machine_part[machine_part_name].concat(
|
|
64
|
+
generate(
|
|
65
|
+
machine_name: machine,
|
|
66
|
+
part: machine_part_name,
|
|
67
|
+
part_type: value_name,
|
|
68
|
+
data: validated_data,
|
|
69
|
+
generator_type: Invade::Generator::Type::MACHINE_NESTED_PART
|
|
70
|
+
)
|
|
71
|
+
) if generate
|
|
72
|
+
end
|
|
73
|
+
else # Is VM, or SSH part
|
|
74
|
+
validated_data = validate('Machine', machine_part_name, machine_part_data, machine_part_data.depth)
|
|
75
|
+
invade_machine_part[machine_part_name] = generate(
|
|
76
|
+
machine_name: machine,
|
|
77
|
+
part_type: machine_part_name,
|
|
78
|
+
data: validated_data,
|
|
79
|
+
generator_type: Invade::Generator::Type::MACHINE_PART
|
|
80
|
+
) if generate
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
invade_machine[machine] = generate(
|
|
85
|
+
machine_name: machine,
|
|
86
|
+
data: invade_machine_part,
|
|
87
|
+
generator_type: Invade::Generator::Type::MACHINE
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
invade_vagrantfile['machines'] = invade_machine
|
|
93
|
+
@env[:ui].success "\n[Invade]: Processed #{config_data.count} machine(s)."
|
|
94
|
+
|
|
95
|
+
else
|
|
96
|
+
|
|
97
|
+
# Info message
|
|
98
|
+
@env[:ui].info("\n[Invade]: Validating #{config_key.upcase} part...") unless quiet
|
|
99
|
+
|
|
100
|
+
validated_data = validate(config_key, config_key, config_data, config_data.depth)
|
|
101
|
+
invade_vagrantfile[config_key] = generate(
|
|
102
|
+
part_type: config_key,
|
|
103
|
+
data: validated_data,
|
|
104
|
+
generator_type: Invade::Generator::Type::VAGRANT_PART
|
|
105
|
+
) if generate
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
@env[:invade]['vagrantfile'] = generate(
|
|
112
|
+
data: invade_vagrantfile,
|
|
113
|
+
generator_type: Invade::Generator::Type::VAGRANTFILE
|
|
114
|
+
) if generate
|
|
115
|
+
|
|
116
|
+
@env[:invade].delete('machines')
|
|
117
|
+
|
|
118
|
+
@app.call(env)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def validate(part_name, value_name, value_data, depth)
|
|
122
|
+
@validator.depth = depth
|
|
123
|
+
@validator.validate(part_name, value_name, value_data)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def generate(machine_name: nil, part: nil, part_type: nil, data: nil, generator_type: nil)
|
|
127
|
+
@generator.type = generator_type
|
|
128
|
+
@generator.generate(
|
|
129
|
+
machine: machine_name,
|
|
130
|
+
part: part,
|
|
131
|
+
type: part_type,
|
|
132
|
+
data: data
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -5,21 +5,19 @@ module VagrantPlugins
|
|
|
5
5
|
module Invade
|
|
6
6
|
module Action
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
def self.validate
|
|
8
|
+
def self.build
|
|
10
9
|
Vagrant::Action::Builder.new.tap do |builder|
|
|
11
10
|
builder.use Config
|
|
12
|
-
builder.use
|
|
11
|
+
builder.use Process
|
|
12
|
+
builder.use Create
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
# This middleware sequence will validate and build the
|
|
17
|
-
def self.
|
|
16
|
+
# This middleware sequence will validate and build the invade configuration file
|
|
17
|
+
def self.process
|
|
18
18
|
Vagrant::Action::Builder.new.tap do |builder|
|
|
19
19
|
builder.use Config
|
|
20
|
-
builder.use
|
|
21
|
-
builder.use Generate
|
|
22
|
-
builder.use Create
|
|
20
|
+
builder.use Process
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
|
|
@@ -30,13 +28,22 @@ module VagrantPlugins
|
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
|
|
31
|
+
def self.check
|
|
32
|
+
Vagrant::Action::Builder.new.tap do |builder|
|
|
33
|
+
builder.use Config
|
|
34
|
+
builder.use Process
|
|
35
|
+
builder.use Check
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
33
39
|
# The autoload farm
|
|
34
|
-
action_root = Pathname.new(File.expand_path(
|
|
35
|
-
autoload :Init, action_root.join(
|
|
36
|
-
autoload :Config, action_root.join(
|
|
37
|
-
autoload :
|
|
38
|
-
autoload :
|
|
39
|
-
autoload :
|
|
40
|
+
action_root = Pathname.new(File.expand_path('../action', __FILE__))
|
|
41
|
+
autoload :Init, action_root.join('init')
|
|
42
|
+
autoload :Config, action_root.join('config')
|
|
43
|
+
autoload :Process, action_root.join('process')
|
|
44
|
+
autoload :Create, action_root.join('create')
|
|
45
|
+
autoload :Check, action_root.join('check')
|
|
46
|
+
|
|
40
47
|
end
|
|
41
48
|
end
|
|
42
49
|
end
|
|
@@ -8,25 +8,22 @@ module VagrantPlugins
|
|
|
8
8
|
def execute
|
|
9
9
|
options = {}
|
|
10
10
|
opts = OptionParser.new do |o|
|
|
11
|
-
o.banner =
|
|
12
|
-
o.separator
|
|
13
|
-
o.on(
|
|
14
|
-
options[:force] = f
|
|
15
|
-
end
|
|
16
|
-
o.on("-q", "--quiet", "No verbose output.") do |q|
|
|
11
|
+
o.banner = 'Usage: vagrant invade build [-q|--quiet] [-h|--help]'
|
|
12
|
+
o.separator ''
|
|
13
|
+
o.on('-q', '--quiet', 'No verbose output.') do |q|
|
|
17
14
|
options[:quiet] = q
|
|
18
15
|
end
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
# Parse the options
|
|
22
19
|
argv = parse_options(opts)
|
|
23
|
-
return
|
|
20
|
+
return unless argv
|
|
24
21
|
|
|
25
22
|
# Validates InVaDE configuration
|
|
26
23
|
action(Action.build, {
|
|
27
|
-
:invade_build_force => options[:force],
|
|
28
24
|
:invade_build_quiet => options[:quiet],
|
|
29
|
-
:invade_validate_quiet => true
|
|
25
|
+
:invade_validate_quiet => true,
|
|
26
|
+
:invade_generate => true
|
|
30
27
|
})
|
|
31
28
|
|
|
32
29
|
# Success, exit status 0
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
require_relative 'base'
|
|
3
|
+
|
|
4
|
+
module VagrantPlugins
|
|
5
|
+
module Invade
|
|
6
|
+
module Command
|
|
7
|
+
class Check < Base
|
|
8
|
+
def execute
|
|
9
|
+
options = {}
|
|
10
|
+
opts = OptionParser.new do |o|
|
|
11
|
+
o.banner = 'Usage: vagrant invade check [-f|--force] [-q|--quiet] [-h|--help]'
|
|
12
|
+
o.separator ''
|
|
13
|
+
o.on('-q', '--quiet', 'No verbose output.') do |q|
|
|
14
|
+
options[:quiet] = q
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Parse the options
|
|
19
|
+
argv = parse_options(opts)
|
|
20
|
+
return unless argv
|
|
21
|
+
|
|
22
|
+
# Validates InVaDE configuration
|
|
23
|
+
action(Action.check, {
|
|
24
|
+
:invade_validate_quiet => true # set this to true. Just build without validate output
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
# Success, exit status 0
|
|
28
|
+
0
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -8,9 +8,9 @@ module VagrantPlugins
|
|
|
8
8
|
def execute
|
|
9
9
|
options = {}
|
|
10
10
|
opts = OptionParser.new do |o|
|
|
11
|
-
o.banner =
|
|
12
|
-
o.separator
|
|
13
|
-
o.on(
|
|
11
|
+
o.banner = 'Usage: vagrant invade init [-f|--force] [-h]'
|
|
12
|
+
o.separator ''
|
|
13
|
+
o.on('-f', '--force', 'Force creating configuration file.') do |f|
|
|
14
14
|
options[:force] = f
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -16,25 +16,31 @@ module VagrantPlugins
|
|
|
16
16
|
|
|
17
17
|
# INIT COMMAND ("vagrant invade init")
|
|
18
18
|
@subcommands.register(:init) do
|
|
19
|
-
require_relative
|
|
19
|
+
require_relative 'init'
|
|
20
20
|
Init
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# CHECK COMMAND ("vagrant invade check")
|
|
24
|
+
@subcommands.register(:check) do
|
|
25
|
+
require_relative 'check'
|
|
26
|
+
Check
|
|
27
|
+
end
|
|
28
|
+
|
|
23
29
|
# VALIDATE COMMAND ("vagrant invade validate")
|
|
24
30
|
@subcommands.register(:validate) do
|
|
25
|
-
require_relative
|
|
31
|
+
require_relative 'validate'
|
|
26
32
|
Validate
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
# BUILD COMMAND ("vagrant invade build")
|
|
30
36
|
@subcommands.register(:build) do
|
|
31
|
-
require_relative
|
|
37
|
+
require_relative 'build'
|
|
32
38
|
Build
|
|
33
39
|
end
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
def execute
|
|
37
|
-
if @main_args.include?(
|
|
43
|
+
if @main_args.include?('-h') || @main_args.include?('--help')
|
|
38
44
|
# Print the help for all the sub-commands.
|
|
39
45
|
return help
|
|
40
46
|
end
|
|
@@ -52,9 +58,9 @@ module VagrantPlugins
|
|
|
52
58
|
# Prints the help out for this command
|
|
53
59
|
def help
|
|
54
60
|
opts = OptionParser.new do |o|
|
|
55
|
-
o.banner =
|
|
56
|
-
o.separator
|
|
57
|
-
o.separator
|
|
61
|
+
o.banner = 'Usage: vagrant invade <command> [<args>]'
|
|
62
|
+
o.separator ''
|
|
63
|
+
o.separator 'Available subcommands:'
|
|
58
64
|
|
|
59
65
|
# Add the available subcommands as separators in order to print them
|
|
60
66
|
# out as well.
|
|
@@ -65,8 +71,8 @@ module VagrantPlugins
|
|
|
65
71
|
o.separator " #{key}"
|
|
66
72
|
end
|
|
67
73
|
|
|
68
|
-
o.separator
|
|
69
|
-
o.separator
|
|
74
|
+
o.separator ''
|
|
75
|
+
o.separator 'For help on any individual command run `vagrant invade COMMAND -h`'
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
@env.ui.info(opts.help, prefix: false)
|
|
@@ -8,24 +8,25 @@ module VagrantPlugins
|
|
|
8
8
|
def execute
|
|
9
9
|
options = {}
|
|
10
10
|
opts = OptionParser.new do |o|
|
|
11
|
-
o.banner =
|
|
12
|
-
o.separator
|
|
13
|
-
o.on(
|
|
11
|
+
o.banner = 'Usage: vagrant invade validate [-f|--force] [-q|--quiet] [-h]'
|
|
12
|
+
o.separator ''
|
|
13
|
+
o.on('-f', '--force', 'Force replacing current Vagrantfile') do |f|
|
|
14
14
|
options[:force] = f
|
|
15
15
|
end
|
|
16
|
-
o.on(
|
|
16
|
+
o.on('-q', '--quiet', 'Just make it whisper.') do |q|
|
|
17
17
|
options[:quiet] = q
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Parse the options
|
|
22
22
|
argv = parse_options(opts)
|
|
23
|
-
return
|
|
23
|
+
return unless argv
|
|
24
24
|
|
|
25
25
|
# Validates InVaDE configuration
|
|
26
|
-
action(Action.
|
|
26
|
+
action(Action.process, {
|
|
27
27
|
:invade_validate_force => options[:force],
|
|
28
|
-
:invade_validate_quiet => options[:quiet]
|
|
28
|
+
:invade_validate_quiet => options[:quiet],
|
|
29
|
+
:invade_generate => false
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
# Success, exit status 0
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
def depth
|
|
3
|
+
a = self.to_a
|
|
4
|
+
d = 1
|
|
5
|
+
while (a.flatten!(1).map! {|e| (e.is_a? Hash) ? e.to_a.flatten(1) : (e.is_a? Array) ? e : nil}.compact!.size > 0)
|
|
6
|
+
d += 1
|
|
7
|
+
end
|
|
8
|
+
d
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def delete_blank
|
|
12
|
+
delete_if do |_, v|
|
|
13
|
+
(v.respond_to?(:empty?) ? v.empty? : !v) or v.instance_of?(Hash) && v.delete_blank.empty?
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Array
|
|
19
|
+
def depth
|
|
20
|
+
a = self.to_a
|
|
21
|
+
return 0 unless a.is_a?(Array)
|
|
22
|
+
return 1 + depth(a[0])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -2,10 +2,54 @@ module VagrantPlugins
|
|
|
2
2
|
module Invade
|
|
3
3
|
module Generator
|
|
4
4
|
|
|
5
|
-
autoload :
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
autoload :Type, 'vagrant-invade/generator/type'
|
|
6
|
+
|
|
7
|
+
class Generator
|
|
8
|
+
|
|
9
|
+
attr_accessor :type
|
|
10
|
+
|
|
11
|
+
def initialize(env)
|
|
12
|
+
@env = env
|
|
13
|
+
@type = Type::VAGRANT_PART
|
|
14
|
+
|
|
15
|
+
@logger = Log4r::Logger.new('vagrant::invade::generator::vagrant')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def generate(machine: nil, part: nil, type: nil, data: nil)
|
|
19
|
+
|
|
20
|
+
begin
|
|
21
|
+
|
|
22
|
+
# Generates the templates with validated data
|
|
23
|
+
case @type
|
|
24
|
+
when Invade::Generator::Type::VAGRANTFILE
|
|
25
|
+
generated_data = InvadeModule::Invade::Vagrantfile.new(data).build
|
|
26
|
+
|
|
27
|
+
when Invade::Generator::Type::VAGRANT_PART
|
|
28
|
+
generator_class_name = type.split('_').collect(&:capitalize).join
|
|
29
|
+
generated_data = InvadeModule.const_get(generator_class_name).new(data).build
|
|
30
|
+
|
|
31
|
+
when Invade::Generator::Type::MACHINE
|
|
32
|
+
generated_data = InvadeModule::Invade::Machine.new(machine, data).build
|
|
33
|
+
|
|
34
|
+
when Invade::Generator::Type::MACHINE_NESTED_PART
|
|
35
|
+
type_formatted = type.split('_').collect(&:capitalize).join
|
|
36
|
+
part_formatted = part.split('_').collect(&:capitalize).join
|
|
37
|
+
generator_class_name = part_formatted + '::' + type_formatted
|
|
38
|
+
generated_data = InvadeModule.const_get(generator_class_name).new(machine, data).build
|
|
39
|
+
|
|
40
|
+
else
|
|
41
|
+
generator_class_name = type.split('_').collect(&:capitalize).join
|
|
42
|
+
generated_data = InvadeModule.const_get(generator_class_name).new(machine, data).build
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
return generated_data
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
@logger.error e
|
|
48
|
+
fail e
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
9
53
|
|
|
10
54
|
end
|
|
11
55
|
end
|