Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

COOK-710, COOK-711 Refactor of registry provider #184

Closed
wants to merge 7 commits into
from
@@ -19,13 +19,15 @@
#
action :create do
- windows_registry 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
+ windows_registry "CreateAutoRun #{new_resource.program} #{new_resource.args}" do
+ key_name 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
values new_resource.name => "\"#{new_resource.program}\" #{new_resource.args}"
end
end
action :remove do
- windows_registry 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
+ windows_registry "RemoveAutoRun #{new_resource.program} #{new_resource.args}" do
+ key_name 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
values new_resource.name => ''
action :remove
end
@@ -1,33 +0,0 @@
-#
-# Author:: Paul Morotn (<pmorton@biaprotect.com>)
-# Cookbook Name:: windows
-# Provider:: env_vars
-#
-# Copyright:: 2011, Business Intelligence Associates, Inc
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-action :create do
- windows_registry Windows::KeyHelper::ENV_KEY do
- values new_resource.name => new_resource.value
- action :create
- end
-end
-
-action :remove do
- windows_registry Windows::KeyHelper::ENV_KEY do
- values new_resource.name => ''
- action :remove
- end
-end
View
@@ -18,37 +18,20 @@
# limitations under the License.
#
-action :add do
- path = ENV['PATH'].split(';')
- if !path.include?(new_resource.path)
- path.insert(-1,new_resource.path)
- end
- windows_registry Windows::KeyHelper::ENV_KEY do
- values 'Path' => path.join(';')
+action :add do
+ env "PATH" do
+ action :create
+ delim ";"
+ value new_resource.path
end
- timeoutVars
+
end
action :remove do
- path = ENV['PATH'].split(';')
- path.delete(new_resource.path)
- windows_registry Windows::KeyHelper::ENV_KEY do
- values 'Path' => path.join(';')
+ env "PATH" do
+ action :delete
+ delim ";"
+ value new_resource.path
end
- timeoutVars
-end
-
-private
-# Notify all processes that the environmental variables have been updated.
-def timeoutVars
- # Dosent seem to work... You may need to re-login
- Chef::Log.debug("Telling other processes that the env vars have been updated")
- require 'Win32API'
- sendMessageTimeout = Win32API.new('user32', 'SendMessageTimeout', 'LLLPLLP', 'L')
- hwnd_broadcast = 0xffff
- wm_settingchange = 0x001A
- smto_abortifhung = 2
- result = 0
- sendMessageTimeout.call(hwnd_broadcast, wm_settingchange, 0, 'Environment', smto_abortifhung, 5000, result)
end
No changes.
@@ -1,29 +0,0 @@
-#
-# Author:: Paul Morotn (<pmorton@biaprotect.com>)
-# Cookbook Name:: windows
-# Resource:: env_vars
-#
-# Copyright:: 2011, Business Intelligence Associates, Inc
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-def initianize(name,run_context=nil)
- super
- @action = :create
-end
-
-actions :create, :remove
-
-attribute :value, :kind_of => String
-attribute :name, :kind_of => String, :name_attribute => true
@@ -22,11 +22,11 @@
actions :create, :modify, :force_modify, :remove
-attribute :key_name, :kind_of => String, :name_attribute => true
-attribute :values, :kind_of => Hash
+attribute :name, :kind_of => String, :name_attribute => true
+attribute :key_name, :kind_of => String, :required => true
+attribute :values, :kind_of => Hash, :required => true
def initialize(name, run_context=nil)
super
@action = :modify
- @key_name = name
end
No changes.