vagrant-extra-vars 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd48f66036ed2c77f4af55557ed163d2197b929d072402ff1df6ee0600e329f2
4
+ data.tar.gz: 9180a410fc8059f4fce619d416f42f047ebccb38fc0b592ee5584bf227a8d799
5
+ SHA512:
6
+ metadata.gz: ed5e33add9f7a1c9c1f887efd282a1f7f83f0d0eb7c0f096295fbe2f4497101c8ee617be6dfe0fac517f001077817e73bf0806b6dc49da2a6622d9bfd7658c25
7
+ data.tar.gz: 037a0fcd7b0353812d0bfa9e3549def82a6178c804c5d0ee94ac14bd9fcf274daec17c8f95227a33954baa44460b21c2caa0b4cf928f92fbc0c6110d7c9e2e21
@@ -0,0 +1,68 @@
1
+ require 'getoptlong'
2
+ require 'json'
3
+
4
+ module VagrantExtraVars
5
+ class Store
6
+ @pass_vars = nil
7
+
8
+ class << self
9
+ def pass_vars
10
+ return @pass_vars if @pass_vars
11
+
12
+ parsed = {}
13
+
14
+ opts = GetoptLong.new(
15
+ ['--pass-var', GetoptLong::OPTIONAL_ARGUMENT], # Defined in VagrantExtraVars
16
+ ['--no-provision', GetoptLong::NO_ARGUMENT],
17
+ ['--provision-with', GetoptLong::REQUIRED_ARGUMENT],
18
+ ['--no-destroy-on-error', GetoptLong::NO_ARGUMENT],
19
+ ['--destroy-on-error', GetoptLong::NO_ARGUMENT],
20
+ ['--no-parallel', GetoptLong::NO_ARGUMENT],
21
+ ['--parallel', GetoptLong::NO_ARGUMENT],
22
+ ['--provider', GetoptLong::REQUIRED_ARGUMENT],
23
+ ['--no-install-provider', GetoptLong::NO_ARGUMENT],
24
+ ['--install-provider', GetoptLong::NO_ARGUMENT],
25
+ ['--no-color', GetoptLong::NO_ARGUMENT],
26
+ ['--color', GetoptLong::NO_ARGUMENT],
27
+ ['--machine-readable', GetoptLong::NO_ARGUMENT],
28
+ ['-v', '--version', GetoptLong::NO_ARGUMENT],
29
+ ['--debug', GetoptLong::NO_ARGUMENT],
30
+ ['--timestamp', GetoptLong::NO_ARGUMENT],
31
+ ['--debug-timestamp', GetoptLong::NO_ARGUMENT],
32
+ ['--no-tty', GetoptLong::NO_ARGUMENT],
33
+ ['-h', '--help', GetoptLong::NO_ARGUMENT],
34
+ ['--provision', GetoptLong::NO_ARGUMENT],
35
+ ['-f', '--force', GetoptLong::NO_ARGUMENT],
36
+ ['-g', '--graceful', GetoptLong::NO_ARGUMENT],
37
+ )
38
+
39
+ pass_var_found = false
40
+
41
+ opts.each do |opt, arg|
42
+ case opt
43
+ when '--pass-var'
44
+ begin
45
+ parsed = JSON.parse(arg).transform_values(&:to_s)
46
+ ENV['VAGRANT_PASS_VARS'] = JSON.dump(parsed)
47
+ pass_var_found = true
48
+ rescue JSON::ParserError => e
49
+ warn "[VagrantExtraVars] Failed to parse --pass-var JSON: #{e.message}"
50
+ end
51
+ end
52
+ end
53
+
54
+ unless pass_var_found && parsed.any?
55
+ if ENV['VAGRANT_PASS_VARS']
56
+ begin
57
+ parsed = JSON.parse(ENV['VAGRANT_PASS_VARS']).transform_values(&:to_s)
58
+ rescue JSON::ParserError => e
59
+ warn "[VagrantExtraVars] Failed to parse ENV['VAGRANT_PASS_VARS']: #{e.message}"
60
+ end
61
+ end
62
+ end
63
+
64
+ @pass_vars = parsed.freeze
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1 @@
1
+ require_relative 'vagrant-extra-vars/core'
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-extra-vars
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Zorkin
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: json
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: A simple way to pass variables that you can use in your Vagrantfile from
27
+ the vagrant CLI
28
+ email: a1handreay@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/vagrant-extra-vars.rb
34
+ - lib/vagrant-extra-vars/core.rb
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.6.7
53
+ specification_version: 4
54
+ summary: provide way to pass variables into Vagrant from command line
55
+ test_files: []