diff options
author | Tim Smith <tsmith@chef.io> | 2018-06-26 21:19:20 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-06-26 22:36:02 -0700 |
commit | c36147dea6c1147da2c8159cfe3c4d034572eab9 (patch) | |
tree | 97c9862c0d1e8ee288149edf0437ed9e6f3fbdcf /lib | |
parent | 21a1a909ffe0819c884c58da7298b49df9099f70 (diff) | |
download | chef-c36147dea6c1147da2c8159cfe3c4d034572eab9.tar.gz |
Use ALLUSERSPROFILE ENV variable vs. hardcoding the path
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/chocolatey_config.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/chocolatey_source.rb | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/resource/chocolatey_config.rb b/lib/chef/resource/chocolatey_config.rb index 87ba3af66d..bfa95ddd05 100644 --- a/lib/chef/resource/chocolatey_config.rb +++ b/lib/chef/resource/chocolatey_config.rb @@ -41,7 +41,7 @@ class Chef # @return [String] the element's value field def fetch_config_element(id) require "rexml/document" - config_file = 'C:\ProgramData\chocolatey\config\chocolatey.config' + config_file = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\config\\chocolatey.config" raise "Could not find the Chocolatey config at #{config_file}!" unless ::File.exist?(config_file) contents = REXML::Document.new(::File.read(config_file)) @@ -73,7 +73,7 @@ class Chef # @param [String] action the name of the action to perform # @return [String] the choco config command string def choco_cmd(action) - cmd = "C:\\ProgramData\\chocolatey\\bin\\choco config #{action} --name #{new_resource.config_key}" + cmd = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\bin\\choco config #{action} --name #{new_resource.config_key}" cmd << " --value #{new_resource.value}" if action == "set" cmd end diff --git a/lib/chef/resource/chocolatey_source.rb b/lib/chef/resource/chocolatey_source.rb index 9308a07587..2a2948e986 100644 --- a/lib/chef/resource/chocolatey_source.rb +++ b/lib/chef/resource/chocolatey_source.rb @@ -43,7 +43,7 @@ class Chef def fetch_source_element(id) require "rexml/document" - config_file = 'C:\ProgramData\chocolatey\config\chocolatey.config' + config_file = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\config\\chocolatey.config" raise "Could not find the Chocolatey config at #{config_file}!" unless ::File.exist?(config_file) config_contents = REXML::Document.new(::File.read(config_file)) @@ -75,7 +75,7 @@ class Chef # @param [String] action the name of the action to perform # @return [String] the choco source command string def choco_cmd(action) - cmd = "C:\\ProgramData\\chocolatey\\bin\\choco source #{action} -n \"#{new_resource.source_name}\"" + cmd = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\bin\\choco source #{action} -n \"#{new_resource.source_name}\"" if action == "add" cmd << " -s #{new_resource.source} --priority=#{new_resource.priority}" cmd << " --bypassproxy" if new_resource.bypass_proxy |