Skip to content

Commit

Permalink
Update module-data to 010c9eb3496f515582a4d4868154e5fb246ee9b8
Browse files Browse the repository at this point in the history
010c9eb3496f515582a4d4868154e5fb246ee9b8 Merge pull request redhat-openstack#20 from radford/add-dependencies-to-metadata
161bbda59d0c3d685b75dfafa38214f437658252 puppet considers metadata without dependencies to be invalid
aaa06fd0549da48b01616bcb875796ef18fdf359 Merge pull request redhat-openstack#19 from fatmcgav/fix_issue_18
7b776609b6661d204c31e08600070c0737466aa4 Convert Modulefile to metadata.json.
d0065f5a7d5cf54a98ab93cf4fe8afc3449d5b7c Fixes issue redhat-openstack#18 which was resulting in a 'Can't convert nil to Hash' error when using Hash datatypes.
46f86f2384ce7914506924aab4baf2c5414cf022 release 0.0.4
7e639b87d0ce787326edf3a0c017b305e8abdd8f Merge pull request redhat-openstack#13 from telamonian/master
c9396c4332a5dc7c4df028abdfb9d4b846452f73 added .gitignore
a6729666b6b4efeb476a01125005567f2233f6c0 fixed code style
9008bfa7eded663dc08b4def9f10c415d138efd0 removed some extra Hiera.debug() lines I had put in
b9eccd31f949bd740afa2df05f44688acbcac996 Fixed hash behavior for hiera data in modules. Setting :merge_behavior to deeper works correctly now.
82ed78d5c8eba9e35697be61233b0f4aae2f6640 Merge pull request redhat-openstack#12 from bobtfish/master
fa48b9a677b699efaa1cd9a97258026a08444e97 Fix to work with strict_variables = true
8c0c106b908fe3808165a2e8775b5b341522b4a8 Merge pull request redhat-openstack#11 from jolynch/master
6127ac5eedcc8a8c55ecf9b9a6ed80b8d1a0bc52 Use the global scope for environment lookup
  • Loading branch information
xbezdick committed Dec 2, 2014
1 parent 4c164e6 commit 172867a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod 'memcached',
:git => 'https://github.com/saz/puppet-memcached.git'

mod 'module-data',
:commit => '159fc5e0e21ce9df96c777f0064b5eca88e29cae',
:commit => '010c9eb3496f515582a4d4868154e5fb246ee9b8',
:git => 'https://github.com/ripienaar/puppet-module-data.git'

mod 'mongodb',
Expand Down
1 change: 1 addition & 0 deletions module-data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.project
2 changes: 1 addition & 1 deletion module-data/Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'ripienaar-module_data'
version '0.0.3'
version '0.0.4'
description 'A hiera backend to allow the use of data while writing sharable modules'
project_page 'https://github.com/ripienaar/puppet-module-data'
license 'ASL 2.0'
Expand Down
32 changes: 18 additions & 14 deletions module-data/lib/hiera/backend/module_data_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def load_module_config(module_name, environment)
default_config = {:hierarchy => ["common"]}

mod = Puppet::Module.find(module_name, environment)

return default_config unless mod

path = mod.path
module_config = File.join(path, "data", "hiera.yaml")
config = {}
Expand All @@ -25,7 +25,7 @@ def load_module_config(module_name, environment)
Hiera.debug("Reading config from %s file" % module_config)
config = load_data(module_config)
end

config["path"] = path

default_config.merge(config)
Expand All @@ -44,15 +44,19 @@ def lookup(key, scope, order_override, resolution_type)

Hiera.debug("Looking up %s in Module Data backend" % key)

unless scope["module_name"]
module_name = begin
scope["module_name"]
rescue Puppet::ParseError # Gets thrown if not in a module and strict_variables = true
end

unless module_name
Hiera.debug("Skipping Module Data backend as this does not look like a module")
return answer
end

config = load_module_config(scope["module_name"], scope["environment"])

config = load_module_config(scope["module_name"], scope["::environment"])
unless config["path"]
Hiera.debug("Could not find a path to the module '%s' in environment '%s'" % [scope["module_name"], scope["environment"]])
Hiera.debug("Could not find a path to the module '%s' in environment '%s'" % [scope["module_name"], scope["::environment"]])
return answer
end

Expand All @@ -67,19 +71,19 @@ def lookup(key, scope, order_override, resolution_type)
next if data.empty?
next unless data.include?(key)

found = data[key]

new_answer = Backend.parse_answer(data[key], scope)
case resolution_type
when :array
raise("Hiera type mismatch: expected Array or String and got %s" % found.class) unless [Array, String].include?(found.class)
raise("Hiera type mismatch: expected Array and got %s" % new_answer.class) unless (new_answer.kind_of?(Array) || new_answer.kind_of?(String))
answer ||= []
answer << Backend.parse_answer(found, scope)
answer << new_answer

when :hash
raise("Hiera type mismatch: expected Hash and got %s" % found.class) unless found.is_a?(Hash)
answer = Backend.parse_answer(found, scope).merge(answer || {})
raise("Hiera type mismatch: expected Hash and got %s" % new_answer.class) unless new_answer.kind_of?(Hash)
answer ||= {}
answer = Backend.merge_answer(new_answer, answer)
else
answer = Backend.parse_answer(found, scope)
answer = new_answer
break
end
end
Expand Down
10 changes: 10 additions & 0 deletions module-data/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"author": "R.I.Pienaar <[email protected]>",
"license": "ASL 2.0",
"name": "ripienaar-module_data",
"project_page": "https://github.com/ripienaar/puppet-module-data",
"source": "https://github.com/ripienaar/puppet-module-data.git",
"summary": "A hiera backend to allow the use of data while writing sharable modules",
"version": "0.4.0",
"dependencies": []
}

0 comments on commit 172867a

Please sign in to comment.