knife-windows 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bb6cf74b7d035cc8d5a2e165c11b2f31b5d13d3
4
- data.tar.gz: 851e56bd0d5329dc2c22b176962772482b231f07
3
+ metadata.gz: 2626d5fa8eb4c9f59c5fa6d78548a75da2f13191
4
+ data.tar.gz: c368fddf73e2377cde52ec84ca97d0bc6173d0fa
5
5
  SHA512:
6
- metadata.gz: 1e09c42feecae9bce95cf1c6dc4f3a3844f0728810c34eb2ff2e2d906c9fdd46f37c53f6dc0f534fd41b7956dace49e9d08d16255e2a00b5ca2088f5af6a8093
7
- data.tar.gz: 31c3aad802d5c4245a5f4f2d619a4f4d30512bf44f152597fc56d634b1f764025579c4984871529343be18bcc1887a2bff64e5fef523f587912d940d7a71e36f
6
+ metadata.gz: e428bb9f8143cb39f06c00c9f668de98a53d7fb561927a3a96068472888f50b905335cc10b10a2822c7c7fe2a6402deb0fbb0324b9a468781cc9461c2e1b1464
7
+ data.tar.gz: 765c2b04b88c9f30ff13f7e1d865d836f9562223f6a189f53d563db23be793a31ca496ccced45783f70415fa21bfc92e4772c934494b5f7f9184d344f7b0b8cd
@@ -1,5 +1,9 @@
1
1
  # knife-windows Change Log
2
2
 
3
+ ## Release 1.5.0
4
+
5
+ * [knife-windows #377](https://github.com/chef/knife-windows/pull/377) Added code and corresponding RSpecs to read the json attributes from the --json-attributes-file option.
6
+
3
7
  ## Release 1.4.1
4
8
 
5
9
  * [knife-windows #362](https://github.com/chef/knife-windows/pull/362) Fix `knife windows bootstrap` chef client downloads over a proxy
@@ -1,14 +1,14 @@
1
- <!---
2
- This file is reset every time a new release is done. This file describes changes that have not yet been released.
3
-
4
- Example Doc Change:
5
- ### Headline for the required change
6
- Description of the required change.
7
- -->
8
- # knife-windows 1.2.0 doc changes
9
-
10
- ### Support for NTLM/Negotiate on both windows and linux
11
-
12
- This release makes no changes to the command line interface, but users should now be aware that Negotiate authentication and encryption over plaintext HTTP now works on linux in addition to windows.
13
-
14
- Users who use knife-windows to bootstrap nodes over plaintext HTTP should also be aware that they no longer need, and in fact should not, configure base images enabling `basic_auth` or enabling `AllowUnencrypted` in their winrm configuration.
1
+ <!---
2
+ This file is reset every time a new release is done. This file describes changes that have not yet been released.
3
+
4
+ Example Doc Change:
5
+ ### Headline for the required change
6
+ Description of the required change.
7
+ -->
8
+ # knife-windows 1.2.0 doc changes
9
+
10
+ ### Support for NTLM/Negotiate on both windows and linux
11
+
12
+ This release makes no changes to the command line interface, but users should now be aware that Negotiate authentication and encryption over plaintext HTTP now works on linux in addition to windows.
13
+
14
+ Users who use knife-windows to bootstrap nodes over plaintext HTTP should also be aware that they no longer need, and in fact should not, configure base images enabling `basic_auth` or enabling `AllowUnencrypted` in their winrm configuration.
data/Gemfile CHANGED
@@ -9,4 +9,5 @@ group :test do
9
9
  gem "ruby-wmi"
10
10
  gem "httpclient"
11
11
  gem 'rake'
12
+ gem "rack", "< 2.0" # 2.0 requires Ruby 2.2+
12
13
  end
data/ci.gemfile CHANGED
@@ -1,15 +1,16 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in knife-windows.gemspec
4
- gemspec
5
-
6
- if ENV['CHEF_VERSION'] == 'master'
7
- gem 'chef', github: 'chef/chef'
8
- else
9
- gem 'chef', ENV['CHEF_VERSION']
10
- end
11
-
12
- gem "rspec", '~> 3.0'
13
- gem "ruby-wmi"
14
- gem "httpclient"
15
- gem 'rake'
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in knife-windows.gemspec
4
+ gemspec
5
+
6
+ if ENV['CHEF_VERSION'] == 'master'
7
+ gem 'chef', github: 'chef/chef'
8
+ else
9
+ gem 'chef', ENV['CHEF_VERSION']
10
+ end
11
+
12
+ gem "rspec", '~> 3.0'
13
+ gem "ruby-wmi"
14
+ gem "httpclient"
15
+ gem 'rake'
16
+ gem "rack", "< 2.0" # 2.0 requires Ruby 2.2+
@@ -1,25 +1,25 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "knife-windows/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "knife-windows"
7
- s.version = Knife::Windows::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Seth Chisamore"]
10
- s.email = ["schisamo@chef.io"]
11
- s.license = "Apache-2.0"
12
- s.homepage = "https://github.com/chef/knife-windows"
13
- s.summary = %q{Plugin that adds functionality to Chef's Knife CLI for configuring/interacting with nodes running Microsoft Windows}
14
- s.description = s.summary
15
-
16
- s.required_ruby_version = ">= 1.9.1"
17
- s.add_dependency "winrm", "~> 1.7"
18
-
19
- s.add_development_dependency 'pry'
20
-
21
- s.files = `git ls-files`.split("\n")
22
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
- s.require_paths = ["lib"]
25
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "knife-windows/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "knife-windows"
7
+ s.version = Knife::Windows::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Seth Chisamore"]
10
+ s.email = ["schisamo@chef.io"]
11
+ s.license = "Apache-2.0"
12
+ s.homepage = "https://github.com/chef/knife-windows"
13
+ s.summary = %q{Plugin that adds functionality to Chef's Knife CLI for configuring/interacting with nodes running Microsoft Windows}
14
+ s.description = s.summary
15
+
16
+ s.required_ruby_version = ">= 1.9.1"
17
+ s.add_dependency "winrm", "~> 1.7"
18
+
19
+ s.add_development_dependency 'pry'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -268,7 +268,12 @@ class Chef
268
268
  cli_secret_file || cli_secret || knife_secret_file || knife_secret
269
269
  end
270
270
 
271
+ def first_boot_attributes
272
+ config[:first_boot_attributes] || config[:first_boot_attributes_from_file] || {}
273
+ end
274
+
271
275
  def render_template(template=nil)
276
+ config[:first_boot_attributes] = first_boot_attributes
272
277
  config[:secret] = load_correct_secret
273
278
  Erubis::Eruby.new(template).evaluate(bootstrap_context)
274
279
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Windows
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -339,4 +339,88 @@ describe Chef::Knife::BootstrapWindowsWinrm do
339
339
  end
340
340
  end
341
341
  end
342
+
343
+ describe 'first_boot_attributes' do
344
+ let(:first_boot_attributes) { { 'a1' => 'b1', 'a2' => 'b2', 'source' => 'hash' } }
345
+ let(:json_file) { 'my_json.json' }
346
+ let(:first_boot_attributes_from_file) { read_json_file(json_file) }
347
+
348
+ before do
349
+ File.open(json_file,"w+") do |f|
350
+ f.write <<-EOH
351
+ {"b2" : "a3", "a4" : "b5", "source" : "file"}
352
+ EOH
353
+ end
354
+ end
355
+
356
+ context 'when none of the json-attributes options are passed' do
357
+ it 'returns an empty hash' do
358
+ response = bootstrap.first_boot_attributes
359
+ expect(response).to be == {}
360
+ end
361
+ end
362
+
363
+ context 'when only --json-attributes option is passed' do
364
+ before do
365
+ bootstrap.config[:first_boot_attributes] = first_boot_attributes
366
+ end
367
+
368
+ it 'returns the hash passed by the user in --json-attributes option' do
369
+ response = bootstrap.first_boot_attributes
370
+ expect(response).to be == first_boot_attributes
371
+ end
372
+ end
373
+
374
+ context 'when only --json-attribute-file option is passed' do
375
+ before do
376
+ bootstrap.config[:first_boot_attributes_from_file] = first_boot_attributes_from_file
377
+ end
378
+
379
+ it 'returns the hash passed by the user in --json-attribute-file option' do
380
+ response = bootstrap.first_boot_attributes
381
+ expect(response).to be == { 'b2' => 'a3', 'a4' => 'b5', 'source' => 'file' }
382
+ end
383
+ end
384
+
385
+ context 'when both the --json-attributes option and --json-attribute-file options are passed' do
386
+ before do
387
+ bootstrap.config[:first_boot_attributes] = first_boot_attributes
388
+ bootstrap.config[:first_boot_attributes_from_file] = first_boot_attributes_from_file
389
+ end
390
+
391
+ it 'returns the hash passed by the user in --json-attributes option' do
392
+ response = bootstrap.first_boot_attributes
393
+ expect(response).to be == first_boot_attributes
394
+ end
395
+ end
396
+
397
+ after do
398
+ FileUtils.rm_rf json_file
399
+ end
400
+ end
401
+
402
+ describe 'render_template' do
403
+ before do
404
+ allow(bootstrap).to receive(:first_boot_attributes).and_return(
405
+ { 'a1' => 'b3', 'a2' => 'b1' }
406
+ )
407
+ allow(bootstrap).to receive(:load_correct_secret).and_return(
408
+ 'my_secret'
409
+ )
410
+ allow(Erubis::Eruby).to receive_message_chain(:new, :evaluate).and_return(
411
+ 'my_template'
412
+ )
413
+ end
414
+
415
+ it 'sets correct values into config and returns the correct response' do
416
+ response = bootstrap.render_template
417
+ expect(bootstrap.config[:first_boot_attributes]).to be == { 'a1' => 'b3', 'a2' => 'b1' }
418
+ expect(bootstrap.config[:secret]).to be == 'my_secret'
419
+ expect(response).to be == 'my_template'
420
+ end
421
+ end
422
+ end
423
+
424
+ def read_json_file(file)
425
+ Chef::JSONCompat.parse(File.read(file))
342
426
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-windows
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Chisamore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: winrm
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
@@ -46,9 +46,9 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".gitignore"
50
- - ".rspec"
51
- - ".travis.yml"
49
+ - .gitignore
50
+ - .rspec
51
+ - .travis.yml
52
52
  - CHANGELOG.md
53
53
  - DOC_CHANGES.md
54
54
  - Gemfile
@@ -108,19 +108,20 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - '>='
112
112
  - !ruby/object:Gem::Version
113
113
  version: 1.9.1
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.6.3
121
+ rubygems_version: 2.0.14
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
125
125
  with nodes running Microsoft Windows
126
126
  test_files: []
127
+ has_rdoc: