summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrishichawda <rishichawda@users.noreply.github.com>2021-08-31 16:04:34 +0530
committerrishichawda <rishichawda@users.noreply.github.com>2021-11-18 14:31:17 +0530
commit9a4358e5bd3087ab94234bdef4da1276009707ad (patch)
tree95943020d546c7db77b04d457644c7c4f7c377a2 /lib
parent7679f33dad8805b7df96f0e46b81a50938feab3b (diff)
downloadchef-9a4358e5bd3087ab94234bdef4da1276009707ad.tar.gz
use powershell_exec helper in powershell_package resource
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/package/powershell.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb
index 1c123d7952..90543c29f0 100644
--- a/lib/chef/provider/package/powershell.rb
+++ b/lib/chef/provider/package/powershell.rb
@@ -17,13 +17,13 @@
require_relative "../package"
require_relative "../../resource/powershell_package"
-require_relative "../../mixin/powershell_out"
+require_relative "../../mixin/powershell_exec"
class Chef
class Provider
class Package
class Powershell < Chef::Provider::Package
- include Chef::Mixin::PowershellOut
+ include Chef::Mixin::PowershellExec
provides :powershell_package
@@ -54,9 +54,9 @@ class Chef
# Installs the package specified with the version passed else latest version will be installed
def install_package(names, versions)
names.each_with_index do |name, index|
- cmd = powershell_out(build_powershell_package_command("Install-Package '#{name}'", versions[index]), timeout: new_resource.timeout)
+ cmd = powershell_exec(build_powershell_package_command("Install-Package '#{name}'", versions[index]), timeout: new_resource.timeout)
next if cmd.nil?
- raise Chef::Exceptions::PowershellCmdletException, "Failed to install package due to catalog signing error, use skip_publisher_check to force install" if /SkipPublisherCheck/.match?(cmd.stderr)
+ raise Chef::Exceptions::PowershellCmdletException, "Failed to install package due to catalog signing error, use skip_publisher_check to force install" if /SkipPublisherCheck/.match?(cmd.error)
end
end
@@ -64,11 +64,11 @@ class Chef
def remove_package(names, versions)
names.each_with_index do |name, index|
if versions && !versions[index].nil?
- powershell_out(build_powershell_package_command("Uninstall-Package '#{name}'", versions[index]), timeout: new_resource.timeout)
+ powershell_exec(build_powershell_package_command("Uninstall-Package '#{name}'", versions[index]), timeout: new_resource.timeout)
else
version = "0"
until version.empty?
- version = powershell_out(build_powershell_package_command("Uninstall-Package '#{name}'"), timeout: new_resource.timeout).stdout.strip
+ version = powershell_exec(build_powershell_package_command("Uninstall-Package '#{name}'"), timeout: new_resource.timeout).result.strip
unless version.empty?
logger.info("Removed package '#{name}' with version #{version}")
end
@@ -82,9 +82,9 @@ class Chef
versions = []
new_resource.package_name.each_with_index do |name, index|
version = if new_resource.version && !new_resource.version[index].nil?
- powershell_out(build_powershell_package_command("Find-Package '#{name}'", new_resource.version[index]), timeout: new_resource.timeout).stdout.strip
+ powershell_exec(build_powershell_package_command("Find-Package '#{name}'", new_resource.version[index]), timeout: new_resource.timeout).result.strip
else
- powershell_out(build_powershell_package_command("Find-Package '#{name}'"), timeout: new_resource.timeout).stdout.strip
+ powershell_exec(build_powershell_package_command("Find-Package '#{name}'"), timeout: new_resource.timeout).result.strip
end
if version.empty?
version = nil
@@ -99,9 +99,9 @@ class Chef
version_list = []
new_resource.package_name.each_with_index do |name, index|
version = if new_resource.version && !new_resource.version[index].nil?
- powershell_out(build_powershell_package_command("Get-Package '#{name}'", new_resource.version[index]), timeout: new_resource.timeout).stdout.strip
+ powershell_exec(build_powershell_package_command("Get-Package '#{name}'", new_resource.version[index]), timeout: new_resource.timeout).result.strip
else
- powershell_out(build_powershell_package_command("Get-Package '#{name}'"), timeout: new_resource.timeout).stdout.strip
+ powershell_exec(build_powershell_package_command("Get-Package '#{name}'"), timeout: new_resource.timeout).result.strip
end
if version.empty?
version = nil