packer-config 1.3.1 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ebf455ba8b1a7020ca59d720b991ed9dddc4b80
4
- data.tar.gz: a1a59a07dd64d5db0ae356d7b8a4c7f5e06c103c
3
+ metadata.gz: e4920f738fb0ed191d9670882f3336847462a085
4
+ data.tar.gz: c41a894f64a07e8e61c1f94dfc5160fdf700880d
5
5
  SHA512:
6
- metadata.gz: 0179e5f9a51d35102209bd304ec4ad1c3ec4646d8b34ef7c33e2d0df238ea0e41d75c4c36a030cc61af472912921dd7fad4e3f25f0c950ae3faeb42dc9f0ddee
7
- data.tar.gz: 0ec5863e8a71cd33156c8f975002251c97cb448db2cf868e1280b0f56eb59c4d154e65d1adb354819060f908b85b9c5fdb325de03a08f16f66a56e8fdb0d36ab
6
+ metadata.gz: 59da5cd9f6be7590e63b8210049d4db889d4339e7f64b6f18e20cded754a377dddc8531e211fad5c801fde8aea16750aa931a27d61823d114c58756c8ccff963
7
+ data.tar.gz: 304585133fb571ad92c8864f731f0454d5888cc9c85ef47879ad18ba44db52d2e82feb56535964f6430b9f73d0922ecf9a9175c3e6254315f32d327ac0aabbd0
@@ -3,5 +3,7 @@ rvm:
3
3
  - 2.0.0
4
4
  - 2.1.1
5
5
  - 2.1.5
6
+ - 2.1.6
6
7
  - 2.2.0
8
+ - 2.2.3
7
9
  - ruby-head
data/COPYRIGHT CHANGED
@@ -5,6 +5,7 @@ Including, but not limited to:
5
5
  Ian Chesal
6
6
  Fraser Cobb
7
7
  Greg Poirier
8
+ Greg Diamond
8
9
 
9
10
  For licensing information please see LICENSE. Copyright holders contributing to
10
11
  this project agree to have their contributions licensed under the terms of the
data/README.md CHANGED
@@ -23,6 +23,10 @@ Bonus: you can really go to town with templates when it's all done it Ruby.
23
23
 
24
24
  require 'packer-config'
25
25
 
26
+ ## Requires
27
+
28
+ * [Packer](http://packer.io) version 0.8.5 or higher
29
+
26
30
  ### Builders
27
31
 
28
32
  The following [Packer builders](http://www.packer.io/docs/templates/builders.html) are currently implemented:
@@ -35,6 +39,8 @@ The following [Packer builders](http://www.packer.io/docs/templates/builders.htm
35
39
  * [vmware-iso](https://www.packer.io/docs/builders/vmware-iso)
36
40
  * [null](https://www.packer.io/docs/builders/null.html)
37
41
 
42
+ [Communicators](https://www.packer.io/docs/templates/communicator.html) are supported as options on Builders in `packer-config`. The `none`, `ssh`, and `winrm` communicators are all available as is the `docker` communicator on the Docker-type builders. `packer-config` will raise an error if you try to use a Communicator type that isn't valid for the Builder.
43
+
38
44
  ### Provisioners
39
45
 
40
46
  The following [Packer provisioners](http://www.packer.io/docs/templates/provisioners.html) are currently implemented:
@@ -79,15 +85,16 @@ This example is based on the integration test [spec/integration/centos_vagrant_s
79
85
  builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
80
86
  builder.guest_os_type "RedHat_64"
81
87
  builder.http_directory "scripts/kickstart"
82
- builder.iso_checksum '08be09fd7276822bd3468af8f96198279ffc41f0'
88
+ builder.iso_checksum '7bb8c1c23a4fdef93e6f0a6347d570e5764d0b38'
83
89
  builder.iso_checksum_type 'sha1'
84
- builder.iso_url "#{pconfig.variable 'mirror'}/6.6/isos/x86_64/CentOS-6.6-x86_64-bin-DVD1.iso"
90
+ builder.iso_url "#{pconfig.variable 'mirror'}/6.7/isos/x86_64/CentOS-6.7-x86_64-bin-DVD1.iso"
85
91
  builder.output_directory "#{OS}-x86_64-virtualbox"
86
92
  builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
93
+ builder.communicator "ssh"
87
94
  builder.ssh_password "vagrant"
88
95
  builder.ssh_port 22
89
96
  builder.ssh_username "vagrant"
90
- builder.ssh_wait_timeout "10000s"
97
+ builder.ssh_timeout "10000s"
91
98
  builder.vboxmanage [
92
99
  [
93
100
  "modifyvm",
@@ -1,5 +1,11 @@
1
1
  # packer-config Release Notes
2
2
 
3
+ ## 1.4.0
4
+
5
+ * Adds support for Communicators (with help from [diamond29][]).
6
+ * Validates the minimum version of Packer is met before running any Packer command line calls. Minimum version is set to 0.8.5 to support Communicators.
7
+ * Bumps integration spec and working example in the README to CentOS 6.7.
8
+
3
9
  ## 1.3.1
4
10
 
5
11
  * Adds a fix for [issue #8](https://github.com/ianchesal/packer-config/issues/8). Removes psuedo-terminals from the runner library which were causing the problem.
@@ -34,3 +40,4 @@
34
40
  [frasercobb]: https://github.com/frasercobb
35
41
  [grepory]: https://github.com/grepory
36
42
  [ianchesal]: https://github.com/ianchesal
43
+ [diamond29]: https://github.com/diamond29
data/TODO.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # TODO
2
2
 
3
- * Use [lowered-expectations](https://rubygems.org/gems/lowered-expectations) to enforce a minimum version of `packer` exists in order to use this gem
4
3
  * Add an option to Packer::Config#validate to run the configuration through packer's `validate` command
5
4
  * Add spec tests for every method on every sub-class. Found during integration testing that some methods on the sub-classes had typos in the `__*` method calls. Spec tests would have caught this.
6
5
  * Look in to something like VCR to drive the tests of the child classes -- there's a lot of repetitive testing that could be done on them.
@@ -8,6 +8,7 @@ require 'packer/postprocessor'
8
8
  require 'packer/macro'
9
9
  require 'packer/envvar'
10
10
  require 'packer/version'
11
+ require 'lowered/expectations'
11
12
 
12
13
  module Packer
13
14
  class Config < Packer::DataObject
@@ -20,6 +21,8 @@ module Packer
20
21
  attr_reader :envvar
21
22
  attr_reader :output_file
22
23
 
24
+ PACKER_VERSION = '0.8.5'
25
+
23
26
  def initialize(file)
24
27
  super()
25
28
  self.data['variables'] = {}
@@ -35,6 +38,7 @@ module Packer
35
38
 
36
39
  def validate
37
40
  super
41
+ verify_packer_version
38
42
  if self.builders.length == 0
39
43
  raise DataValidationError.new("At least one builder is required")
40
44
  end
@@ -117,10 +121,6 @@ module Packer
117
121
  self.__add_string('description', description)
118
122
  end
119
123
 
120
- def min_packer_version(version)
121
- self.__add_string('min_packer_version', version)
122
- end
123
-
124
124
  def variables
125
125
  self.data['variables']
126
126
  end
@@ -160,8 +160,18 @@ module Packer
160
160
  end
161
161
 
162
162
  private
163
+
163
164
  attr_writer :output_file
164
165
  attr_writer :macro
165
166
  attr_writer :envvar
167
+
168
+ def min_packer_version(version)
169
+ self.__add_string('min_packer_version', version)
170
+ end
171
+
172
+ def verify_packer_version
173
+ min_packer_version PACKER_VERSION
174
+ LoweredExpectations.expect('packer', ">= #{PACKER_VERSION}", vopt: 'version')
175
+ end
166
176
  end
167
177
  end
@@ -39,6 +39,8 @@ module Packer
39
39
  }.fetch(type).new
40
40
  end
41
41
 
42
+ attr_reader :communicators
43
+
42
44
  def self.types
43
45
  VALID_BUILDER_TYPES
44
46
  end
@@ -46,13 +48,99 @@ module Packer
46
48
  def initialize
47
49
  super
48
50
  self.add_required('type')
51
+ self.communicators = []
49
52
  end
50
53
 
51
54
  def name(name)
52
55
  self.__add_string('name', name)
53
56
  end
54
57
 
58
+ # @ianchesal: Communicators are technically Templates in Packer land but
59
+ # they modify Builders. Weird. So we'll treat them as Builder attributes.
60
+ # See: https://packer.io/docs/templates/communicator.html
61
+ def communicator(comm)
62
+ raise(DataValidationError, "unknown communicator protocol #{comm}") unless communicators.include? comm
63
+ self.__add_string('communicator', comm)
64
+ end
65
+
66
+ # Technically these only apply if the communicator is ssh
67
+ def ssh_host(host)
68
+ self.__add_string('ssh_host', host)
69
+ end
70
+
71
+ def ssh_port(port)
72
+ self.__add_integer('ssh_port', port)
73
+ end
74
+
75
+ def ssh_username(username)
76
+ self.__add_string('ssh_username', username)
77
+ end
78
+
79
+ def ssh_password(password)
80
+ self.__add_string('ssh_password', password)
81
+ end
82
+
83
+ def ssh_private_key_file(filename)
84
+ self.__add_string('ssh_private_key_file', filename)
85
+ end
86
+
87
+ def ssh_pty(pty)
88
+ self.__add_boolean('ssh_pty', pty)
89
+ end
90
+
91
+ def ssh_timeout(timeout)
92
+ self.__add_string('ssh_timeout', timeout)
93
+ end
94
+
95
+ def ssh_handshake_attempts(attempts)
96
+ self.__add_integer('ssh_handshake_attempts', attempts)
97
+ end
98
+
99
+ def ssh_disable_agent(disable)
100
+ self.__add_boolean('ssh_disable_agent', disable)
101
+ end
102
+
103
+ def ssh_bastion_host(hostname)
104
+ self.__add_string('ssh_bastion_host', hostname)
105
+ end
106
+
107
+ def ssh_bastion_username(username)
108
+ self.__add_string('ssh_bastion_username', username)
109
+ end
110
+
111
+ def ssh_bastion_password(password)
112
+ self.__add_string('ssh_bastion_password', password)
113
+ end
114
+
115
+ def ssh_bastion_private_key_file(filename)
116
+ self.__add_string('ssh_bastion_private_key_file', filename)
117
+ end
118
+
119
+ # Technically these only apply if the communicator is winrm
120
+ def winrm_host(host)
121
+ self.__add_string('winrm_host', host)
122
+ end
123
+
124
+ def winrm_port(port)
125
+ self.__add_string('winrm_port', port)
126
+ end
127
+
128
+ def winrm_username(username)
129
+ self.__add_string('winrm_username', username)
130
+ end
131
+
132
+ def winrm_password(password)
133
+ self.__add_string('winrm_password', password)
134
+ end
135
+
136
+ def winrm_timeout(timeout)
137
+ self.__add_string('winrm_timeout', timeout)
138
+ end
139
+
55
140
  private
141
+
142
+ attr_writer :communicators
143
+
56
144
  def self.validate_type(type)
57
145
  VALID_BUILDER_TYPES.include? type
58
146
  end
@@ -12,8 +12,9 @@ module Packer
12
12
  'instance_type',
13
13
  'region',
14
14
  'source_ami',
15
- 'ssh_username'
15
+ 'communicator'
16
16
  )
17
+ self.communicators = %w(none ssh winrm)
17
18
  end
18
19
 
19
20
  def access_key(key)
@@ -36,10 +37,6 @@ module Packer
36
37
  self.__add_string('source_ami', name)
37
38
  end
38
39
 
39
- def ssh_username(username)
40
- self.__add_string('ssh_username', username)
41
- end
42
-
43
40
  def secret_key(key)
44
41
  self.__add_string('secret_key', key)
45
42
  end
@@ -104,18 +101,6 @@ module Packer
104
101
  self.__add_array_of_strings('security_group_ids', ids, %w[security_group_id])
105
102
  end
106
103
 
107
- def ssh_port(port)
108
- self.__add_integer('ssh_port', port)
109
- end
110
-
111
- def ssh_private_key_file(file)
112
- self.__add_string('ssh_private_key_file', file)
113
- end
114
-
115
- def ssh_timeout(time)
116
- self.__add_string('ssh_timeout', time)
117
- end
118
-
119
104
  def subnet_id(id)
120
105
  self.__add_string('subnet_id', id)
121
106
  end
@@ -8,32 +8,7 @@ module Packer
8
8
  def initialize
9
9
  super
10
10
  self.data['type'] = NULL
11
- self.add_required(
12
- 'host',
13
- 'ssh_password',
14
- 'ssh_private_key_file',
15
- 'ssh_username'
16
- )
17
- end
18
-
19
- def host(name)
20
- self.__add_string('host', name)
21
- end
22
-
23
- def ssh_password(passwd)
24
- self.__add_string('ssh_password', passwd)
25
- end
26
-
27
- def ssh_private_key_file(filename)
28
- self.__add_string('ssh_private_key_file', filename)
29
- end
30
-
31
- def ssh_username(name)
32
- self.__add_string('ssh_username', name)
33
- end
34
-
35
- def port(number)
36
- self.__add_integer('port', number)
11
+ self.communicators = %w(none ssh winrm)
37
12
  end
38
13
  end
39
14
  end
@@ -12,8 +12,9 @@ module Packer
12
12
  'iso_checksum',
13
13
  'iso_checksum_type',
14
14
  'iso_url',
15
- 'ssh_username'
15
+ 'communicator'
16
16
  )
17
+ self.communicators = %w(none ssh winrm)
17
18
  end
18
19
 
19
20
  def iso_checksum(checksum)
@@ -32,10 +33,6 @@ module Packer
32
33
  self.__add_array_of_strings('iso_urls', urls, %[iso_url])
33
34
  end
34
35
 
35
- def ssh_username(username)
36
- self.__add_string('ssh_username', username)
37
- end
38
-
39
36
  def boot_command(commands)
40
37
  self.__add_array_of_strings('boot_command', commands)
41
38
  end
@@ -112,30 +109,6 @@ module Packer
112
109
  self.__add_string('shutdown_timeout', time)
113
110
  end
114
111
 
115
- def ssh_host_port_min(port_number)
116
- self.__add_integer('ssh_host_port_min', port_number)
117
- end
118
-
119
- def ssh_host_port_max(port_number)
120
- self.__add_integer('ssh_host_port_max', port_number)
121
- end
122
-
123
- def ssh_key_path(path)
124
- self.__add_string('ssh_key_path', path)
125
- end
126
-
127
- def ssh_password(password)
128
- self.__add_string('ssh_password', password)
129
- end
130
-
131
- def ssh_port(port_number)
132
- self.__add_integer('ssh_port', port_number)
133
- end
134
-
135
- def ssh_wait_timeout(time)
136
- self.__add_string('ssh_wait_timeout', time)
137
- end
138
-
139
112
  def vboxmanage(array_of_commands)
140
113
  self.__add_array_of_array_of_strings('vboxmanage', array_of_commands)
141
114
  end
@@ -12,8 +12,9 @@ module Packer
12
12
  'iso_checksum',
13
13
  'iso_checksum_type',
14
14
  'iso_url',
15
- 'ssh_username'
15
+ 'communicator'
16
16
  )
17
+ self.communicators = %w(none ssh winrm)
17
18
  end
18
19
 
19
20
  def iso_checksum(checksum)
@@ -32,10 +33,6 @@ module Packer
32
33
  self.__add_array_of_strings('iso_urls', urls, %[iso_url])
33
34
  end
34
35
 
35
- def ssh_username(username)
36
- self.__add_string('ssh_username', username)
37
- end
38
-
39
36
  def boot_command(commands)
40
37
  self.__add_array_of_strings('boot_command', commands)
41
38
  end
@@ -130,38 +127,6 @@ module Packer
130
127
  self.__add_boolean('skip_compaction', bool)
131
128
  end
132
129
 
133
- def ssh_host(host)
134
- self.__add_string('ssh_host', host)
135
- end
136
-
137
- def ssh_host_port_min(port_number)
138
- self.__add_integer('ssh_host_port_min', port_number)
139
- end
140
-
141
- def ssh_host_port_max(port_number)
142
- self.__add_integer('ssh_host_port_max', port_number)
143
- end
144
-
145
- def ssh_key_path(path)
146
- self.__add_string('ssh_key_path', path)
147
- end
148
-
149
- def ssh_password(password)
150
- self.__add_string('ssh_password', password)
151
- end
152
-
153
- def ssh_port(port_number)
154
- self.__add_integer('ssh_port', port_number)
155
- end
156
-
157
- def ssh_skip_request_pty(bool)
158
- self.__add_boolean('ssh_skip_request_pty', bool)
159
- end
160
-
161
- def ssh_wait_timeout(time)
162
- self.__add_string('ssh_wait_timeout', time)
163
- end
164
-
165
130
  def tools_upload_flavor(flavor)
166
131
  self.__add_string('tools_upload_flavor', flavor)
167
132
  end
@@ -6,22 +6,15 @@ module Packer
6
6
  data['type'] = VMWARE_VMX
7
7
  add_required(
8
8
  'source_path',
9
- 'ssh_username'
9
+ 'communicator'
10
10
  )
11
+ self.communicators = %w(none ssh winrm)
11
12
  end
12
13
 
13
14
  def source_path(path)
14
15
  __add_string('source_path', path)
15
16
  end
16
17
 
17
- def ssh_username(username)
18
- __add_string('ssh_username', username)
19
- end
20
-
21
- def ssh_password(password)
22
- __add_string('ssh_password', password)
23
- end
24
-
25
18
  def boot_command(commands)
26
19
  __add_array_of_strings('boot_command', commands)
27
20
  end
@@ -70,22 +63,6 @@ module Packer
70
63
  __add_boolean('skip_compaction', bool)
71
64
  end
72
65
 
73
- def ssh_key_path(path)
74
- __add_string('ssh_key_path', path)
75
- end
76
-
77
- def ssh_port(port)
78
- __add_integer('ssh_port', port)
79
- end
80
-
81
- def ssh_skip_request_pty(bool)
82
- __add_boolean('ssh_skip_request_pty', bool)
83
- end
84
-
85
- def ssh_wait_timeout(timeout)
86
- __add_string('ssh_wait_timeout', timeout)
87
- end
88
-
89
66
  def vm_name(name)
90
67
  __add_string('vm_name', name)
91
68
  end
@@ -1,3 +1,3 @@
1
1
  module Packer
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -6,7 +6,7 @@ require 'packer/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "packer-config"
8
8
  spec.version = Packer::VERSION
9
- spec.authors = ["Ian Chesal", "Fraser Cobb", "Greg Poirier", "Matasano Security"]
9
+ spec.authors = ["Ian Chesal", "Fraser Cobb", "Greg Poirier", "Matasano Security", "Greg Diamond"]
10
10
  spec.email = ["ian.chesal@gmail.com"]
11
11
  spec.summary = 'An object model to build packer.io configurations in Ruby.'
12
12
  spec.description = <<-END
@@ -26,6 +26,8 @@ END
26
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
27
  spec.require_paths = ["lib"]
28
28
 
29
+ spec.add_runtime_dependency "lowered-expectations"
30
+
29
31
  spec.add_development_dependency "bundler", "~> 1.7"
30
32
  spec.add_development_dependency "rake", "~> 10.3"
31
33
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -18,15 +18,16 @@ RSpec.describe Packer::Config do
18
18
  builder.guest_additions_path "VBoxGuestAdditions_#{pconfig.macro.Version}.iso"
19
19
  builder.guest_os_type "RedHat_64"
20
20
  builder.http_directory "scripts/kickstart"
21
- builder.iso_checksum '08be09fd7276822bd3468af8f96198279ffc41f0'
21
+ builder.iso_checksum '7bb8c1c23a4fdef93e6f0a6347d570e5764d0b38'
22
22
  builder.iso_checksum_type 'sha1'
23
- builder.iso_url "#{pconfig.variable 'mirror'}/6.6/isos/x86_64/CentOS-6.6-x86_64-bin-DVD1.iso"
23
+ builder.iso_url "#{pconfig.variable 'mirror'}/6.7/isos/x86_64/CentOS-6.7-x86_64-bin-DVD1.iso"
24
24
  builder.output_directory "#{OS}-x86_64-virtualbox"
25
25
  builder.shutdown_command "echo 'vagrant'|sudo -S /sbin/halt -h -p"
26
+ builder.communicator "ssh"
26
27
  builder.ssh_password "vagrant"
27
28
  builder.ssh_port 22
28
29
  builder.ssh_username "vagrant"
29
- builder.ssh_wait_timeout "10000s"
30
+ builder.ssh_timeout "10000s"
30
31
  builder.vboxmanage [
31
32
  [
32
33
  "modifyvm",
@@ -23,4 +23,10 @@ RSpec.describe Packer::Builder do
23
23
  builder.data.delete('name')
24
24
  end
25
25
  end
26
+
27
+ describe '#communicator' do
28
+ it 'raises an error if you try to set an invalid communicator' do
29
+ expect { builder.communicator 'foo' }.to raise_error Packer::DataObject::DataValidationError
30
+ end
31
+ end
26
32
  end
@@ -57,19 +57,39 @@ end
57
57
  RSpec.describe Packer::Builder::Amazon::EBS do
58
58
  let(:builder) { Packer::Builder.get_builder(Packer::Builder::AMAZON_EBS) }
59
59
 
60
- describe '#initialize' do
61
- it 'has a type of amazon-ebs' do
62
- expect(builder.data['type']).to eq(Packer::Builder::AMAZON_EBS)
63
- end
60
+ it 'has a type of amazon-ebs' do
61
+ expect(builder.data['type']).to eq(Packer::Builder::AMAZON_EBS)
62
+ end
63
+
64
+ it 'requires ami_name, instance_type, region, source_ami, and communicator' do
65
+ expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
66
+ builder.ami_name 'foo'
67
+ builder.instance_type 'foo'
68
+ builder.region 'foo'
69
+ builder.source_ami 'foo'
70
+ builder.communicator 'ssh'
71
+ expect { builder.validate }.not_to raise_error
64
72
  end
65
73
  end
66
74
 
67
75
  RSpec.describe Packer::Builder::Amazon::Instance do
68
76
  let(:builder) { Packer::Builder.get_builder(Packer::Builder::AMAZON_INSTANCE) }
69
77
 
70
- describe '#initialize' do
71
- it 'has a type of amazon-instance' do
72
- expect(builder.data['type']).to eq(Packer::Builder::AMAZON_INSTANCE)
73
- end
78
+ it 'has a type of amazon-instance' do
79
+ expect(builder.data['type']).to eq(Packer::Builder::AMAZON_INSTANCE)
80
+ end
81
+
82
+ it 'requires ami_name, instance_type, region, source_ami, account_id, s3_bucket, x509_cert_path, x509_key_path, and communicator' do
83
+ expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
84
+ builder.ami_name 'foo'
85
+ builder.instance_type 'foo'
86
+ builder.region 'foo'
87
+ builder.source_ami 'foo'
88
+ builder.account_id 'foo'
89
+ builder.s3_bucket 'foo'
90
+ builder.x509_cert_path 'foo'
91
+ builder.x509_key_path 'foo'
92
+ builder.communicator 'ssh'
93
+ expect { builder.validate }.not_to raise_error
74
94
  end
75
95
  end
@@ -5,21 +5,7 @@ RSpec.describe Packer::Builder::Null do
5
5
  let(:builder) { Packer::Builder.get_builder(Packer::Builder::NULL) }
6
6
  let(:some_string) { 'some string' }
7
7
 
8
- it 'requires a number of parameters to be valid' do
9
- expect{ builder.validate }.to raise_error
10
- builder.host :some_string
11
- expect{ builder.validate }.to raise_error
12
- builder.ssh_password :some_string
13
- expect{ builder.validate }.to raise_error
14
- builder.ssh_private_key_file :some_string
15
- expect{ builder.validate }.to raise_error
16
- builder.ssh_username :some_string
17
- expect(builder.validate).to be_truthy
18
- end
19
-
20
- describe '#initialize' do
21
- it 'has a type of null' do
22
- expect(builder.data['type']).to eq(Packer::Builder::NULL)
23
- end
8
+ it 'has a type of null' do
9
+ expect(builder.data['type']).to eq(Packer::Builder::NULL)
24
10
  end
25
11
  end
@@ -7,10 +7,17 @@ RSpec.describe Packer::Builder::VirtualBoxISO do
7
7
  let(:in_commands_mixed) { [["command1", 1 ], ["command2", 2 ]] }
8
8
  let(:out_commands_strings) { [["command1", "1"], ["command2", "2"]] }
9
9
 
10
- describe '#initialize' do
11
- it 'has a type of virtualbox-iso' do
12
- expect(builder.data['type']).to eq(Packer::Builder::VIRTUALBOX_ISO)
13
- end
10
+ it 'has a type of virtualbox-iso' do
11
+ expect(builder.data['type']).to eq(Packer::Builder::VIRTUALBOX_ISO)
12
+ end
13
+
14
+ it 'requires iso_checksum, iso_checksum_type, iso_url and communicator' do
15
+ expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
16
+ builder.iso_checksum '88197272b2a442402820fcc788a8cc7a'
17
+ builder.iso_checksum_type "MD5"
18
+ builder.iso_url 'path'
19
+ builder.communicator 'ssh'
20
+ expect { builder.validate }.not_to raise_error
14
21
  end
15
22
 
16
23
  describe '#vboxmanage' do
@@ -4,19 +4,17 @@ require 'spec_helper'
4
4
  RSpec.describe Packer::Builder::VMWareISO do
5
5
  let(:builder) { Packer::Builder.get_builder(Packer::Builder::VMWARE_ISO) }
6
6
 
7
- describe '#initialize' do
8
- it 'has a type of VMWare ISO' do
9
- expect(builder.data['type']).to eq(Packer::Builder::VMWARE_ISO)
10
- end
7
+ it 'has a type of VMWare ISO' do
8
+ expect(builder.data['type']).to eq(Packer::Builder::VMWARE_ISO)
9
+ end
11
10
 
12
- it 'requires iso_checksum' do
13
- expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
14
- builder.iso_checksum '88197272b2a442402820fcc788a8cc7a'
15
- builder.iso_checksum_type "MD5"
16
- builder.iso_url 'path'
17
- builder.ssh_username 'user'
18
- expect { builder.validate }.not_to raise_error
19
- end
11
+ it 'requires iso_checksum, iso_checksum_type, iso_url and communicator' do
12
+ expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
13
+ builder.iso_checksum '88197272b2a442402820fcc788a8cc7a'
14
+ builder.iso_checksum_type "MD5"
15
+ builder.iso_url 'path'
16
+ builder.communicator 'ssh'
17
+ expect { builder.validate }.not_to raise_error
20
18
  end
21
19
 
22
20
  describe '#vmx_data' do
@@ -4,17 +4,15 @@ require 'spec_helper'
4
4
  RSpec.describe Packer::Builder::VMWareVMX do
5
5
  let(:builder) { Packer::Builder.get_builder(Packer::Builder::VMWARE_VMX) }
6
6
 
7
- describe '#initialize' do
8
- it 'has a type of VMWare VMX' do
9
- expect(builder.data['type']).to eq(Packer::Builder::VMWARE_VMX)
10
- end
7
+ it 'has a type of VMWare VMX' do
8
+ expect(builder.data['type']).to eq(Packer::Builder::VMWARE_VMX)
9
+ end
11
10
 
12
- it 'requires source_path' do
13
- expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
14
- builder.source_path 'path'
15
- builder.ssh_username 'user'
16
- expect { builder.validate }.not_to raise_error
17
- end
11
+ it 'requires source_path and communicator' do
12
+ expect { builder.validate }.to raise_error(Packer::DataObject::DataValidationError)
13
+ builder.source_path 'path'
14
+ builder.communicator 'ssh'
15
+ expect { builder.validate }.not_to raise_error
18
16
  end
19
17
 
20
18
  describe '#vmx_data' do
@@ -22,6 +22,7 @@ RSpec.describe Packer::Config do
22
22
  it 'returns true for a valid instance' do
23
23
  expect(packer.builders).to receive(:length).and_return(1)
24
24
  expect(Packer::Runner).to receive(:run!).and_return('')
25
+ expect(LoweredExpectations).to receive(:expect).and_return(true)
25
26
  FakeFS do
26
27
  expect(packer.validate).to be_truthy
27
28
  end
@@ -29,10 +30,22 @@ RSpec.describe Packer::Config do
29
30
 
30
31
  it 'raises an error for an invalid instance' do
31
32
  expect(packer.builders).to receive(:length).and_return(0)
33
+ expect(LoweredExpectations).to receive(:expect).and_return(true)
32
34
  FakeFS do
33
35
  expect { packer.validate }.to raise_error
34
36
  end
35
37
  end
38
+
39
+ it 'sets the minimum Packer version' do
40
+ expect(packer.builders).to receive(:length).and_return(1)
41
+ expect(Packer::Runner).to receive(:run!).and_return('')
42
+ expect(LoweredExpectations).to receive(:expect).and_return(true)
43
+ expect(packer.data['min_packer_version']).to be_falsey
44
+ FakeFS do
45
+ expect(packer.validate).to be_truthy
46
+ end
47
+ expect(packer.data['min_packer_version']).to eq(Packer::Config::PACKER_VERSION)
48
+ end
36
49
  end
37
50
 
38
51
  describe '#dump' do
metadata CHANGED
@@ -1,18 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packer-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Chesal
8
8
  - Fraser Cobb
9
9
  - Greg Poirier
10
10
  - Matasano Security
11
+ - Greg Diamond
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2015-07-15 00:00:00.000000000 Z
15
+ date: 2015-09-14 00:00:00.000000000 Z
15
16
  dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: lowered-expectations
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
16
31
  - !ruby/object:Gem::Dependency
17
32
  name: bundler
18
33
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
244
  version: '0'
230
245
  requirements: []
231
246
  rubyforge_project:
232
- rubygems_version: 2.4.6
247
+ rubygems_version: 2.4.8
233
248
  signing_key:
234
249
  specification_version: 4
235
250
  summary: An object model to build packer.io configurations in Ruby.