Skip to content
Snippets Groups Projects
0005-options-is-an-instance-variable-not-local.patch 1.46 KiB
Newer Older
From: Christopher Huhn <C.Huhn@gsi.de>
Date: Tue, 9 Nov 2021 18:42:28 +0100
Subject: options is an instance variable, not local

---
 lib/chef/handler/mail.rb | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/chef/handler/mail.rb b/lib/chef/handler/mail.rb
index 3be01cc..9497f83 100644
--- a/lib/chef/handler/mail.rb
+++ b/lib/chef/handler/mail.rb
@@ -37,12 +37,12 @@ class MailHandler < Chef::Handler
       Socket.gethostname
     )
 
-    Chef::Log.debug("mail handler template path: #{options[:template_path]}")
-    if File.exists? options[:template_path]
-      template = IO.read(options[:template_path]).chomp
+    Chef::Log.debug("mail handler template path: #{@options[:template_path]}")
+    if File.exists? @options[:template_path]
+      template = IO.read(@options[:template_path]).chomp
     else
       Chef::Log.error("mail handler template not found: " +
-                      options[:template_path])
+                      @options[:template_path])
       raise Errno::ENOENT
     end
 
@@ -54,12 +54,9 @@ class MailHandler < Chef::Handler
 
     bodystr = Erubis::Eruby.new(template).evaluate(context)
 
-    to_address = options[:to_address]
-    from_address = "chef-client@#{Socket.gethostname}"
-
     mail = Mail.new do
-      from     options[:from_address]
-      to       to_address
+      from     @options[:from_address]
+      to       @options[:to_address]
       subject  subjectstr
       body     bodystr
     end