New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#14149) Refactor utility code into PuppetX namespace #18

Merged
merged 2 commits into from Aug 24, 2012
Jump to file or symbol
Failed to load files and symbols.
+57 −42
Diff settings

Always

Just for now

View

This file was deleted.

Oops, something went wrong.
@@ -1,10 +1,18 @@
# REMIND: need to support recursive delete of subkeys & values
require 'pathname' # JJM WORK_AROUND #14073
require Pathname.new(__FILE__).dirname.dirname.dirname.expand_path + 'modules/registry'
require Pathname.new(__FILE__).dirname.dirname.dirname.expand_path + 'modules/registry/provider_base'
begin
# We expect this to work once Puppet supports Rubygems in #7788
require "puppet_x/puppetlabs/registry"
require "puppet_x/puppetlabs/registry/provider_base"
rescue LoadError => detail
# Work around #7788 (Rubygems support for modules)
require 'pathname' # JJM WORK_AROUND #14073
module_base = Pathname.new(__FILE__).dirname
require module_base + "../../../" + "puppet_x/puppetlabs/registry"
require module_base + "../../../" + "puppet_x/puppetlabs/registry/provider_base"
end
Puppet::Type.type(:registry_key).provide(:registry) do
include Puppet::Modules::Registry::ProviderBase
include PuppetX::Puppetlabs::Registry::ProviderBase
defaultfor :operatingsystem => :windows
confine :operatingsystem => :windows
@@ -51,6 +59,6 @@ def values
private
def path
@path ||= Puppet::Modules::Registry::RegistryKeyPath.new(resource.parameter(:path).value)
@path ||= PuppetX::Puppetlabs::Registry::RegistryKeyPath.new(resource.parameter(:path).value)
end
end
@@ -1,10 +1,16 @@
require 'puppet/type'
require 'pathname' # JJM WORK_AROUND #14073
require Pathname.new(__FILE__).dirname.dirname.dirname.expand_path + 'modules/registry'
require Pathname.new(__FILE__).dirname.dirname.dirname.expand_path + 'modules/registry/provider_base'
begin
require "puppet_x/puppetlabs/registry"
require "puppet_x/puppetlabs/registry/provider_base"
rescue LoadError => detail
require "pathname" # JJM WORK_AROUND #14073 and #7788
module_base = Pathname.new(__FILE__).dirname + "../../../"
require module_base + "puppet_x/puppetlabs/registry"
require module_base + "puppet_x/puppetlabs/registry/provider_base"
end
Puppet::Type.type(:registry_value).provide(:registry) do
include Puppet::Modules::Registry::ProviderBase
include PuppetX::Puppetlabs::Registry::ProviderBase
defaultfor :operatingsystem => :windows
confine :operatingsystem => :windows
@@ -160,6 +166,6 @@ def write_value
end
def path
@path ||= Puppet::Modules::Registry::RegistryValuePath.new(resource.parameter(:path).value)
@path ||= PuppetX::Puppetlabs::Registry::RegistryValuePath.new(resource.parameter(:path).value)
end
end
@@ -1,6 +1,10 @@
require 'puppet/type'
require 'pathname' # JJM WORK_AROUND #14073
require Pathname.new(__FILE__).dirname.dirname.expand_path + 'modules/registry'
begin
require "puppet_x/puppetlabs/registry"
rescue LoadError => detail
require 'pathname' # JJM WORK_AROUND #14073 and #7788
require Pathname.new(__FILE__).dirname + "../../" + "puppet_x/puppetlabs/registry"
end
Puppet::Type.newtype(:registry_key) do
@doc = <<-EOT
@@ -32,10 +36,10 @@ def self.title_patterns
prefix. For example: '32:HKLM\Software'"
validate do |path|
Puppet::Modules::Registry::RegistryKeyPath.new(path).valid?
PuppetX::Puppetlabs::Registry::RegistryKeyPath.new(path).valid?
end
munge do |path|
reg_path = Puppet::Modules::Registry::RegistryKeyPath.new(path)
reg_path = PuppetX::Puppetlabs::Registry::RegistryKeyPath.new(path)
# Windows is case insensitive and case preserving. We deal with this by
# aliasing resources to their downcase values. This is inspired by the
# munge block in the alias metaparameter.
@@ -83,7 +87,7 @@ def self.title_patterns
# Autorequire the nearest ancestor registry_key found in the catalog.
autorequire(:registry_key) do
req = []
path = Puppet::Modules::Registry::RegistryKeyPath.new(value(:path))
path = PuppetX::Puppetlabs::Registry::RegistryKeyPath.new(value(:path))
# It is important to match against the downcase value of the path because
# other resources are expected to alias themselves to the downcase value so
# that we respect the case insensitive and preserving nature of Windows.
@@ -99,7 +103,7 @@ def eval_generate
# get the "should" names of registry values associated with this key
should_values = catalog.relationship_graph.direct_dependents_of(self).select {|dep| dep.type == :registry_value }.map do |reg|
Puppet::Modules::Registry::RegistryValuePath.new(reg.parameter(:path).value).valuename
PuppetX::Puppetlabs::Registry::RegistryValuePath.new(reg.parameter(:path).value).valuename
end
# get the "is" names of registry values associated with this key
@@ -1,6 +1,10 @@
require 'puppet/type'
require 'pathname' # JJM WORK_AROUND #14073
require Pathname.new(__FILE__).dirname.dirname.expand_path + 'modules/registry'
begin
require "puppet_x/puppetlabs/registry"
rescue
require 'pathname' # JJM WORK_AROUND #14073 and #7788
require Pathname.new(__FILE__).dirname + "../../" + "puppet_x/puppetlabs/registry"
end
Puppet::Type.newtype(:registry_value) do
@doc = <<-EOT
@@ -28,10 +32,10 @@ def self.title_patterns
'32:HKLM\Software\Value3'"
validate do |path|
Puppet::Modules::Registry::RegistryValuePath.new(path).valid?
PuppetX::Puppetlabs::Registry::RegistryValuePath.new(path).valid?
end
munge do |path|
reg_path = Puppet::Modules::Registry::RegistryValuePath.new(path)
reg_path = PuppetX::Puppetlabs::Registry::RegistryValuePath.new(path)
# Windows is case insensitive and case preserving. We deal with this by
# aliasing resources to their downcase values. This is inspired by the
# munge block in the alias metaparameter.
@@ -119,7 +123,7 @@ def change_to_s(currentvalue, newvalue)
req = []
# This is a value path and not a key path because it's based on the path of
# the value resource.
path = Puppet::Modules::Registry::RegistryValuePath.new(value(:path))
path = PuppetX::Puppetlabs::Registry::RegistryValuePath.new(value(:path))
# It is important to match against the downcase value of the path because
# other resources are expected to alias themselves to the downcase value so
# that we respect the case insensitive and preserving nature of Windows.
@@ -1,10 +1,6 @@
require 'pathname'
# JJM WORK_AROUND
# explicitly require files without relying on $LOAD_PATH until #14073 is fixed.
# https://projects.puppetlabs.com/issues/14073 is fixed.
require Pathname.new(__FILE__).dirname.expand_path
module Puppet::Modules::Registry
module PuppetX
module Puppetlabs
module Registry
# For 64-bit OS, use 64-bit view. Ignored on 32-bit OS
KEY_WOW64_64KEY = 0x100 unless defined? KEY_WOW64_64KEY
# For 64-bit OS, use 32-bit view. Ignored on 32-bit OS
@@ -86,10 +82,10 @@ def filter_path
case captures[1]
when '32:'
result[:access] = Puppet::Modules::Registry::KEY_WOW64_32KEY
result[:access] = PuppetX::Puppetlabs::Registry::KEY_WOW64_32KEY
result[:prefix] = '32:'
else
result[:access] = Puppet::Modules::Registry::KEY_WOW64_64KEY
result[:access] = PuppetX::Puppetlabs::Registry::KEY_WOW64_64KEY
result[:prefix] = ''
end
@@ -161,3 +157,5 @@ def default?
end
end
end
end
end
@@ -1,8 +1,8 @@
require 'pathname' # JJM WORK_AROUND #14073
require Pathname.new(__FILE__).dirname.expand_path
# This module is meant to be mixed into the registry_key AND registry_value providers.
module Puppet::Modules::Registry::ProviderBase
module PuppetX
module Puppetlabs
module Registry
module ProviderBase
# This is a class method in order to be easily mocked in the spec tests.
def self.initialize_system_api
if Puppet.features.microsoft_windows?
@@ -86,3 +86,6 @@ def name2type(name)
name2type[name]
end
end
end
end
end
ProTip! Use n and p to navigate between commits in a pull request.