summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-05-28 17:37:18 -0700
committerPete Higgins <pete@peterhiggins.org>2020-06-03 11:46:53 -0700
commite258096e8b1452263a7c89031e4ec94d2e0c323e (patch)
tree2e9f324740529bdc07c56f2c63a83160dcb21c73
parent8f7a2bb3eebb44af28aeb583edfdf993f0d47146 (diff)
downloadchef-e258096e8b1452263a7c89031e4ec94d2e0c323e.tar.gz
Untangle some inheritance code around script code.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/provider/powershell_script.rb14
-rw-r--r--lib/chef/provider/script.rb9
2 files changed, 6 insertions, 17 deletions
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 4f77cd2593..196bb3cd6f 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -26,11 +26,6 @@ class Chef
provides :powershell_script
- def initialize(*args)
- super
- add_exit_status_wrapper
- end
-
action :run do
validate_script_syntax!
super()
@@ -53,12 +48,11 @@ class Chef
protected
- # Process exit codes are strange with PowerShell and require
- # special handling to cover common use cases.
- def add_exit_status_wrapper
- self.code = wrapper_script
+ def code
+ code = wrapper_script
logger.trace("powershell_script provider called with script code:\n\n#{new_resource.code}\n")
logger.trace("powershell_script provider will execute transformed code:\n\n#{code}\n")
+ code
end
def validate_script_syntax!
@@ -99,6 +93,8 @@ class Chef
end
end
+ # Process exit codes are strange with PowerShell and require
+ # special handling to cover common use cases.
# A wrapper script is used to launch user-supplied script while
# still obtaining useful process exit codes. Unless you
# explicitly call exit in PowerShell, the powershell.exe
diff --git a/lib/chef/provider/script.rb b/lib/chef/provider/script.rb
index cccb79dfc0..cb4fcd8a22 100644
--- a/lib/chef/provider/script.rb
+++ b/lib/chef/provider/script.rb
@@ -34,14 +34,7 @@ class Chef
provides :ruby
provides :script
- def_delegators :new_resource, :interpreter, :flags
-
- attr_accessor :code
-
- def initialize(new_resource, run_context)
- super
- self.code = new_resource.code
- end
+ def_delegators :new_resource, :interpreter, :flags, :code
def command
"\"#{interpreter}\" #{flags} \"#{script_file.path}\""