chef-powershell 1.0.7 → 1.0.13

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
  SHA256:
3
- metadata.gz: df450d23064493f0c708866adb3f5eb5e83da1e11e76238cfe1c0de60009b4c5
4
- data.tar.gz: 30c82e0ca452f6ca72834f69e30fd59e7be7ac7e38fa4c2748e5214ecb31eb22
3
+ metadata.gz: '0385078e80f481abcc62b6b6285cd0ba94b2524857a5c5f0913e1fff69953ed6'
4
+ data.tar.gz: 19f0715afb033447d152fb9ab133c64d276f485b18eccbabfe10fa30281abe16
5
5
  SHA512:
6
- metadata.gz: 8dfeb7613876db120ebcb32fe080d64fbe7f2b98b33d928f3d5a5300d73ed57eb3cc3e41d40c16c987af1d94e0cb99ec786792d8e733a9024c64937b84e6a9be
7
- data.tar.gz: 43a55310801d6df2467a4f393db27e79638289d9243bbfe1c286e93d53d3d3a6ddc18977fbb43cc8960fa2879723f19dee52a765e68ef4f814113456749a9b50
6
+ metadata.gz: 8deacd340559575fdd59530823bd9aef4524cf0fef3e2b1cfbe7c9a5fff0205a3278fd2ad9821e31b94000c4cd58dbdb39c7411a815e2a3dea6726d9b39209c6
7
+ data.tar.gz: 0aacaca1c8df702ee8fe18d6484e23fb1666304d1ee6ca718ecacf7284d2806615d2534defe76d6e58522842f44b4196908ee7120080ead35d0bfc75991c84de
@@ -1,52 +1,52 @@
1
- # frozen_string_literal: true
2
- lib = File.expand_path("lib", __dir__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- bin = File.expand_path("bin", __dir__)
5
- $LOAD_PATH.unshift(bin) unless $LOAD_PATH.include?(bin)
6
- require "chef-powershell/version"
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "chef-powershell"
10
- spec.version = ChefPowerShell::VERSION
11
- spec.authors = ["Chef Software, Inc"]
12
- spec.email = ["oss@chef.io"]
13
-
14
- spec.summary = %q{External Chef module for accessing and utilizing PowerShell}
15
- spec.homepage = "https://github.com/chef/chef-powershell-shim"
16
- spec.license = "Apache-2.0"
17
-
18
- spec.required_ruby_version = ">= 2.6"
19
-
20
- spec.add_runtime_dependency "ffi", "~> 1.15"
21
- spec.add_runtime_dependency "ffi-yajl", "~> 2.4"
22
-
23
- spec.metadata = {
24
- "bug_tracker_uri" => "https://github.com/chef/chef/issues",
25
- "changelog_uri" => "https://github.com/chef/chef-powershell-shim/CHANGELOG.md",
26
- "documentation_uri" => "https://github.com/chef/chef-powershell-shim/chef-powershell/README.md",
27
- "homepage_uri" => "https://github.com/chef/chef/tree/main/chef-powershell",
28
- "source_code_uri" => "https://github.com/chef/chef-powershell-shim/chef-powershell",
29
- }
30
-
31
- spec.require_paths = %w{lib bin}
32
-
33
- #
34
- # NOTE: DO NOT ADD RUNTIME DEPS TO OTHER CHEF ECOSYSTEM GEMS
35
- # (e.g. chef, ohai, mixlib-anything, ffi-yajl, and IN PARTICULAR NOT chef-config)
36
- #
37
- # This is so that this set of common code can be reused in any other library without
38
- # creating circular dependencies. If you find yourself wanting to do that you probably
39
- # have a helper that should go into the library you want to declare a dependency on,
40
- # or you need to create another gem that is not this one. You may also want to rub some
41
- # dependency injection on your API to invert things so that you don't have to take
42
- # a dependency on the thing you need (i.e. allow injecting a hash-like thing instead of taking
43
- # a dep on mixlib-config and then require the consumer to wire up chef-config to your
44
- # API). Same for mixlib-log and Chef::Log in general.
45
- #
46
- # ABSOLUTELY NO EXCEPTIONS
47
- #
48
- spec.bindir = "bin"
49
- spec.executables = []
50
- spec.files = %w{Rakefile LICENSE} + Dir.glob("*.gemspec") +
51
- Dir.glob("{lib,spec,bin}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
52
- end
1
+ # frozen_string_literal: true
2
+ lib = File.expand_path("lib", __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ bin = File.expand_path("bin", __dir__)
5
+ $LOAD_PATH.unshift(bin) unless $LOAD_PATH.include?(bin)
6
+ require "chef-powershell/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "chef-powershell"
10
+ spec.version = ChefPowerShellModule::VERSION
11
+ spec.authors = ["Chef Software, Inc"]
12
+ spec.email = ["oss@chef.io"]
13
+
14
+ spec.summary = %q{External Chef module for accessing and utilizing PowerShell}
15
+ spec.homepage = "https://github.com/chef/chef-powershell-shim"
16
+ spec.license = "Apache-2.0"
17
+
18
+ spec.required_ruby_version = ">= 2.6"
19
+
20
+ spec.add_runtime_dependency "ffi", "~> 1.15"
21
+ spec.add_runtime_dependency "ffi-yajl", "~> 2.4"
22
+
23
+ spec.metadata = {
24
+ "bug_tracker_uri" => "https://github.com/chef/chef/issues",
25
+ "changelog_uri" => "https://github.com/chef/chef-powershell-shim/CHANGELOG.md",
26
+ "documentation_uri" => "https://github.com/chef/chef-powershell-shim/chef-powershell/README.md",
27
+ "homepage_uri" => "https://github.com/chef/chef/tree/main/chef-powershell",
28
+ "source_code_uri" => "https://github.com/chef/chef-powershell-shim/chef-powershell",
29
+ }
30
+
31
+ spec.require_paths = %w{lib bin}
32
+
33
+ #
34
+ # NOTE: DO NOT ADD RUNTIME DEPS TO OTHER CHEF ECOSYSTEM GEMS
35
+ # (e.g. chef, ohai, mixlib-anything, ffi-yajl, and IN PARTICULAR NOT chef-config)
36
+ #
37
+ # This is so that this set of common code can be reused in any other library without
38
+ # creating circular dependencies. If you find yourself wanting to do that you probably
39
+ # have a helper that should go into the library you want to declare a dependency on,
40
+ # or you need to create another gem that is not this one. You may also want to rub some
41
+ # dependency injection on your API to invert things so that you don't have to take
42
+ # a dependency on the thing you need (i.e. allow injecting a hash-like thing instead of taking
43
+ # a dep on mixlib-config and then require the consumer to wire up chef-config to your
44
+ # API). Same for mixlib-log and Chef::Log in general.
45
+ #
46
+ # ABSOLUTELY NO EXCEPTIONS
47
+ #
48
+ spec.bindir = "bin"
49
+ spec.executables = []
50
+ spec.files = %w{Rakefile LICENSE} + Dir.glob("*.gemspec") +
51
+ Dir.glob("{lib,spec,bin}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
52
+ end
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- class Chef_PowerShell
18
+ class ChefPowerShell
19
19
  class PowerShellExceptions
20
20
  class PowerShellCommandFailed < RuntimeError; end
21
21
 
@@ -16,12 +16,11 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require "ffi" unless defined?(FFI)
19
- require_relative "json_compat"
19
+ autoload :FFI_Yajl, "ffi_yajl"
20
20
  require_relative "exceptions"
21
21
  require_relative "unicode"
22
- # require "chef-powershell"
23
22
 
24
- class Chef_PowerShell
23
+ class ChefPowerShell
25
24
  class PowerShell
26
25
 
27
26
  attr_reader :result
@@ -58,10 +57,10 @@ class Chef_PowerShell
58
57
  end
59
58
 
60
59
  #
61
- # @raise [Chef_PowerShell::PowerShellExceptions::PowerShellCommandFailed] raise if the command failed
60
+ # @raise [ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed] raise if the command failed
62
61
  #
63
62
  def error!
64
- raise Chef_PowerShell::PowerShellExceptions::PowerShellCommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
63
+ raise ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
65
64
  end
66
65
 
67
66
  module PowerMod
@@ -98,8 +97,8 @@ class Chef_PowerShell
98
97
  PowerMod.set_ps_command(script)
99
98
  execution = PowerMod.do_work
100
99
  output = execution.read_utf16string
101
- hashed_outcome = Chef::JSONCompat.parse(output)
102
- @result = Chef::JSONCompat.parse(hashed_outcome["result"])
100
+ hashed_outcome = FFI_Yajl::Parser.parse(output)
101
+ @result = FFI_Yajl::Parser.parse(hashed_outcome["result"])
103
102
  @errors = hashed_outcome["errors"]
104
103
  @verbose = hashed_outcome["verbose"]
105
104
  end
@@ -23,7 +23,7 @@ require_relative "./pwsh"
23
23
  # powershell_exec is initialized with a string that should be set to the script
24
24
  # to run and also takes an optional interpreter argument which must be either
25
25
  # :powershell (Windows PowerShell which is the default) or :pwsh (PowerShell
26
- # Core). It will return a Chef_PowerShell::PowerShell object that provides 5 methods:
26
+ # Core). It will return a ChefPowerShell::PowerShell object that provides 5 methods:
27
27
  #
28
28
  # .result - returns a hash representing the results returned by executing the
29
29
  # PowerShell script block
@@ -95,8 +95,8 @@ require_relative "./pwsh"
95
95
  # credentials of the user running Chef Client are used.
96
96
  #
97
97
 
98
- class Chef_PowerShell
99
- module ChefPowerShell
98
+ class ChefPowerShell
99
+ module ChefPowerShellModule
100
100
  module PowerShellExec
101
101
  # The Chef.PowerShell.Wrapper.dll file looks in the same folder as ruby.exe OR in the folder specified by the environment variable CHEF_POWERSHELL_BIN for other chef powershell dll's
102
102
  # We don't want to move files around so we're setting the variable here to keep everything tidy.
@@ -113,16 +113,16 @@ class Chef_PowerShell
113
113
  def powershell_exec(script, interpreter = :powershell, timeout: -1)
114
114
  case interpreter
115
115
  when :powershell
116
- Chef_PowerShell::PowerShell.new(script, timeout: timeout)
116
+ ChefPowerShell::PowerShell.new(script, timeout: timeout)
117
117
  when :pwsh
118
- Chef_PowerShell::Pwsh.new(script, timeout: timeout)
118
+ ChefPowerShell::Pwsh.new(script, timeout: timeout)
119
119
  else
120
120
  raise ArgumentError, "Expected interpreter of :powershell or :pwsh"
121
121
  end
122
122
  end
123
123
 
124
124
  # The same as the #powershell_exec method except this will raise
125
- # Chef_PowerShell::PowerShellExceptions::PowerShellCommandFailed if the command fails
125
+ # ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed if the command fails
126
126
  def powershell_exec!(script, interpreter = :powershell, **options)
127
127
  cmd = powershell_exec(script, interpreter, **options)
128
128
  cmd.error!
@@ -15,8 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- class Chef_PowerShell
19
- class Pwsh < Chef_PowerShell::PowerShell
18
+ class ChefPowerShell
19
+ class Pwsh < ChefPowerShell::PowerShell
20
20
  # Run a command under pwsh (powershell core) via FFI
21
21
  # This implementation requires the managed dll, native wrapper and a
22
22
  # published, self contained dotnet core directory tree to exist in the
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
- # Copyright:: Copyright (c) Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- module ChefPowerShell
18
- CHEFPOWERSHELL_ROOT = File.expand_path("..", __dir__)
19
- VERSION = "1.0.7"
20
- end
1
+ # frozen_string_literal: true
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module ChefPowerShellModule
18
+ CHEFPOWERSHELL_ROOT = File.expand_path("..", __dir__)
19
+ VERSION = "1.0.13"
20
+ end
@@ -18,6 +18,6 @@
18
18
 
19
19
  require_relative "chef-powershell/powershell_exec"
20
20
 
21
- module ChefPowerShell
22
- include Chef_PowerShell::ChefPowerShell::PowerShellExec
21
+ module ChefPowerShellModule
22
+ include ChefPowerShell::ChefPowerShellModule::PowerShellExec
23
23
  end
@@ -18,8 +18,8 @@
18
18
 
19
19
  require "chef-powershell"
20
20
 
21
- describe Chef_PowerShell::ChefPowerShell::PowerShellExec, :windows_only do
22
- let(:powershell_mixin) { Class.new { include Chef_PowerShell::ChefPowerShell::PowerShellExec } }
21
+ describe ChefPowerShell::ChefPowerShellModule::PowerShellExec, :windows_only do
22
+ let(:powershell_mixin) { Class.new { include ChefPowerShell::ChefPowerShellModule::PowerShellExec } }
23
23
  subject(:object) { powershell_mixin.new }
24
24
 
25
25
  before do
@@ -30,7 +30,7 @@ describe Chef_PowerShell::ChefPowerShell::PowerShellExec, :windows_only do
30
30
  describe "#powershell_exec" do
31
31
  context "not specifying an interpreter" do
32
32
  it "runs a basic command and returns a Chef::PowerShell object" do
33
- expect(object.powershell_exec("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(Chef_PowerShell::PowerShell)
33
+ expect(object.powershell_exec("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(ChefPowerShell::PowerShell)
34
34
  end
35
35
 
36
36
  it "uses less than version 7" do
@@ -41,7 +41,7 @@ describe Chef_PowerShell::ChefPowerShell::PowerShellExec, :windows_only do
41
41
 
42
42
  context "using pwsh interpreter" do
43
43
  it "runs a basic command and returns a Chef::PowerShell object" do
44
- expect(object.powershell_exec("$PSVersionTable", :pwsh, timeout: -1)).to be_kind_of(Chef_PowerShell::Pwsh)
44
+ expect(object.powershell_exec("$PSVersionTable", :pwsh, timeout: -1)).to be_kind_of(ChefPowerShell::Pwsh)
45
45
  end
46
46
 
47
47
  it "uses greater than version 6" do
@@ -52,7 +52,7 @@ describe Chef_PowerShell::ChefPowerShell::PowerShellExec, :windows_only do
52
52
 
53
53
  context "using powershell interpreter" do
54
54
  it "runs a basic command and returns a Chef::PowerShell object" do
55
- expect(object.powershell_exec("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(Chef_PowerShell::PowerShell)
55
+ expect(object.powershell_exec("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(ChefPowerShell::PowerShell)
56
56
  end
57
57
 
58
58
  it "uses less than version 6" do
@@ -80,11 +80,11 @@ describe Chef_PowerShell::ChefPowerShell::PowerShellExec, :windows_only do
80
80
 
81
81
  describe "#powershell_exec!" do
82
82
  it "runs a basic command and returns a Chef::PowerShell object" do
83
- expect(object.powershell_exec!("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(Chef_PowerShell::PowerShell)
83
+ expect(object.powershell_exec!("$PSVersionTable", :powershell, timeout: -1)).to be_kind_of(ChefPowerShell::PowerShell)
84
84
  end
85
85
 
86
86
  it "raises an error if the command fails" do
87
- expect { object.powershell_exec!("this-should-error") }.to raise_error(Chef_PowerShell::PowerShellExceptions::PowerShellCommandFailed)
87
+ expect { object.powershell_exec!("this-should-error") }.to raise_error(ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed)
88
88
  end
89
89
 
90
90
  it "raises an error if the interpreter is invalid" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-powershell
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.4'
41
- description:
41
+ description:
42
42
  email:
43
43
  - oss@chef.io
44
44
  executables: []
@@ -658,7 +658,6 @@ files:
658
658
  - chef-powershell.gemspec
659
659
  - lib/chef-powershell.rb
660
660
  - lib/chef-powershell/exceptions.rb
661
- - lib/chef-powershell/json_compat.rb
662
661
  - lib/chef-powershell/powershell.rb
663
662
  - lib/chef-powershell/powershell_exec.rb
664
663
  - lib/chef-powershell/pwsh.rb
@@ -675,7 +674,7 @@ metadata:
675
674
  documentation_uri: https://github.com/chef/chef-powershell-shim/chef-powershell/README.md
676
675
  homepage_uri: https://github.com/chef/chef/tree/main/chef-powershell
677
676
  source_code_uri: https://github.com/chef/chef-powershell-shim/chef-powershell
678
- post_install_message:
677
+ post_install_message:
679
678
  rdoc_options: []
680
679
  require_paths:
681
680
  - lib
@@ -691,8 +690,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
691
690
  - !ruby/object:Gem::Version
692
691
  version: '0'
693
692
  requirements: []
694
- rubygems_version: 3.2.22
695
- signing_key:
693
+ rubyforge_project:
694
+ rubygems_version: 2.7.6.3
695
+ signing_key:
696
696
  specification_version: 4
697
697
  summary: External Chef module for accessing and utilizing PowerShell
698
698
  test_files: []
@@ -1,63 +0,0 @@
1
- #
2
- # Author:: Tim Hinderliter (<tim@chef.io>)
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- # Wrapper class for interacting with JSON.
19
-
20
- autoload :FFI_Yajl, "ffi_yajl"
21
- require_relative "exceptions"
22
- # We're requiring this to prevent breaking consumers using Hash.to_json
23
- require "json" unless defined?(JSON)
24
-
25
- class Chef
26
- class JSONCompat
27
-
28
- class << self
29
-
30
- def parse(source, opts = {})
31
- FFI_Yajl::Parser.parse(source, opts)
32
- rescue FFI_Yajl::ParseError => e
33
- raise Chef_PowerShell::PowerShellExceptions::JSON::ParseError, e.message
34
- end
35
-
36
- def from_json(source, opts = {})
37
- obj = parse(source, opts)
38
-
39
- # JSON gem requires top level object to be a Hash or Array (otherwise
40
- # you get the "must contain two octets" error). Yajl doesn't impose the
41
- # same limitation. For compatibility, we re-impose this condition.
42
- unless obj.is_a?(Hash) || obj.is_a?(Array)
43
- raise Chef_PowerShell::PowerShellExceptions::JSON::ParseError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
44
- end
45
-
46
- obj
47
- end
48
-
49
- def to_json(obj, opts = nil)
50
- FFI_Yajl::Encoder.encode(obj, opts)
51
- rescue FFI_Yajl::EncodeError => e
52
- raise Chef_PowerShell::PowerShellExceptions::JSON::EncodeError, e.message
53
- end
54
-
55
- def to_json_pretty(obj, opts = nil)
56
- options_map = { pretty: true }
57
- options_map[:indent] = opts[:indent] if opts.respond_to?(:key?) && opts.key?(:indent)
58
- to_json(obj, options_map).chomp
59
- end
60
-
61
- end
62
- end
63
- end