kitchen-oci 1.6.1 → 1.8.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
  SHA256:
3
- metadata.gz: 3b2f233d2240dacbdd4963f7f3e71a71c1eea4ff252b08871f96ad740980338a
4
- data.tar.gz: 1925454bb9e0565bbbb37011771d67c43c4634b1f86f03bb06a2f6966c9cc562
3
+ metadata.gz: bef4a4b0aadfd5e5f47b67c4a4807d227cf5f636bacbb1a202579f9bda6fd7fc
4
+ data.tar.gz: b7cef03d39724831643dbaf5d04ed21222d4cb496ff65da9ac724fafa6e8ee97
5
5
  SHA512:
6
- metadata.gz: 69de909c99054a2b025c38321e7c44fd53018b887bc4136fc16f7dd8b4878b0cdf6333a65eabb21b0e611b1b04e2e6494521adf7ec960d322edb8b534432a26f
7
- data.tar.gz: 3895434f64165cad197524dccbd0706c53777d8a7970c402dfe1ef6d4b2aa15111915d37edf3b95bc82851e3ee4d59131fc554b2a16431358abc360119046de9
6
+ metadata.gz: 86cb6549515a0f169ff4fbfcc0875688f7c0f374ffcccd366a5ce26b20cfe034e18784d22f70df585e37c675c2c48699c80dcfe2d253da3968fb1efd54dd819e
7
+ data.tar.gz: a49d0d696d9ba6b7af17c9cba108e77a63c1c3c263083a7346afc87406cf081c6160953886165cc8e29578a4d9c92228e91e7fd95f554e8dad4f9e9406c08151
@@ -1,3 +1,7 @@
1
+
2
+ ## 1.8.0 Freeform tags
3
+ - Added optional parameter `freeform_tags`
4
+
1
5
  ## 1.6.0 WinRM password option
2
6
  - Added option to set winrm password, instead of randomly generating one
3
7
 
@@ -6,3 +10,4 @@
6
10
  - Added cloud-init support.
7
11
  - Added support for Windows targets.
8
12
  - Can inject powershell script to set a random password and enable WinRM
13
+
data/README.md CHANGED
@@ -61,6 +61,8 @@ These settings are optional:
61
61
  - post\_create\_script, run a script on compute\_instance after deployment
62
62
  - proxy\_url, Connect via the specified proxy URL
63
63
  - user\_data, Add user data scripts
64
+ - hostname\_prefix, Prefix for the generated hostnames (note that OCI doesn't like underscores)
65
+ - freeform\_tags, Hash containing tag name(s) and values(s)
64
66
 
65
67
  Optional settings for WinRM support in Windows:
66
68
 
@@ -17,6 +17,8 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
 
20
+ # rubocop:disable Metrics/AbcSize
21
+
20
22
  # This require fixes bug in ChefDK 4.0.60-1 on Linux.
21
23
  require 'forwardable'
22
24
 
@@ -42,15 +44,29 @@ module Kitchen
42
44
  default_config :use_private_ip, false
43
45
  default_config :oci_config_file, nil
44
46
  default_config :oci_profile_name, nil
47
+ default_config :hostname_prefix, nil
45
48
  default_keypath = File.expand_path(File.join(%w[~ .ssh id_rsa.pub]))
46
49
  default_config :ssh_keypath, default_keypath
47
50
  default_config :post_create_script, nil
48
51
  default_config :proxy_url, nil
49
52
  default_config :user_data, []
53
+ default_config :freeform_tags, {}
50
54
  default_config :setup_winrm, false
51
55
  default_config :winrm_user, 'opc'
52
56
  default_config :winrm_password, nil
53
57
 
58
+ def process_freeform_tags(freeform_tags)
59
+ prov = instance.provisioner.instance_variable_get(:@config)
60
+ tags = %w[run_list policyfile]
61
+ tags.each do |tag|
62
+ unless prov[tag.to_sym].nil? || prov[tag.to_sym].empty?
63
+ freeform_tags[tag] = prov[tag.to_sym].join(',')
64
+ end
65
+ end
66
+ freeform_tags[:kitchen] = true
67
+ freeform_tags
68
+ end
69
+
54
70
  def process_windows_options(state)
55
71
  state[:username] = config[:winrm_user] if config[:setup_winrm]
56
72
  if config[:setup_winrm] == true &&
@@ -61,7 +77,7 @@ module Kitchen
61
77
  state
62
78
  end
63
79
 
64
- def create(state) # rubocop:disable Metrics/AbcSize
80
+ def create(state)
65
81
  return if state[:server_id]
66
82
 
67
83
  state = process_windows_options(state)
@@ -221,7 +237,7 @@ module Kitchen
221
237
  content.split("\n")
222
238
  end
223
239
 
224
- def mime_parts(boundary) # rubocop:disable Metrics/AbcSize
240
+ def mime_parts(boundary)
225
241
  msg = []
226
242
  config[:user_data].each do |m|
227
243
  msg << "--#{boundary}"
@@ -255,16 +271,22 @@ module Kitchen
255
271
  }
256
272
  end
257
273
 
274
+ def generate_hostname
275
+ prefix = config[:hostname_prefix]
276
+ [prefix, random_hostname(instance.name)].compact.join('-')
277
+ end
278
+
258
279
  def base_oci_launch_details
259
- request = OCI::Core::Models::LaunchInstanceDetails.new
260
- hostname = random_hostname(instance.name)
261
- request.availability_domain = config[:availability_domain]
262
- request.compartment_id = config[:compartment_id]
263
- request.display_name = hostname
264
- request.source_details = instance_source_details
265
- request.shape = config[:shape]
266
- request.create_vnic_details = create_vnic_details(hostname)
267
- request
280
+ OCI::Core::Models::LaunchInstanceDetails.new.tap do |l|
281
+ hostname = generate_hostname
282
+ l.availability_domain = config[:availability_domain]
283
+ l.compartment_id = config[:compartment_id]
284
+ l.display_name = hostname
285
+ l.source_details = instance_source_details
286
+ l.shape = config[:shape]
287
+ l.create_vnic_details = create_vnic_details(hostname)
288
+ l.freeform_tags = process_freeform_tags(config[:freeform_tags])
289
+ end
268
290
  end
269
291
 
270
292
  def compute_instance_request(state)
@@ -284,7 +306,7 @@ module Kitchen
284
306
  "#{prefix}-#{random_string(6)}"
285
307
  end
286
308
 
287
- def random_password # rubocop:disable Metrics/AbcSize
309
+ def random_password
288
310
  (Array.new(5) { %w[! " # & ( ) * + , - . /].sample } +
289
311
  Array.new(5) { ('a'..'z').to_a.sample } +
290
312
  Array.new(5) { ('A'..'Z').to_a.sample } +
@@ -297,3 +319,5 @@ module Kitchen
297
319
  end
298
320
  end
299
321
  end
322
+
323
+ # rubocop:enable Metrics/AbcSize
@@ -20,6 +20,6 @@
20
20
  module Kitchen
21
21
  module Driver
22
22
  # Version string for Oracle OCI Kitchen driver
23
- OCI_VERSION = '1.6.1'
23
+ OCI_VERSION = '1.8.0'
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-oci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-24 00:00:00.000000000 Z
11
+ date: 2019-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oci
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.0.1
149
+ rubygems_version: 3.0.3
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: A Test Kitchen Driver for Oracle OCI