Please review pull request #26: (#14461) Remove Puppet parser functions opened by (kelseyhightower)
Description:
The next release of Hiera will ship with the Puppet parser functions:
hiera, hiera_hash, hiera_array, and hiera_include. To prevent conflicts
the Puppet parser functions are being removed from the hiera-puppet gem.
We only provide a puppet hiera backend as described in the README.
- Opened: Mon May 14 13:39:41 UTC 2012
- Based on: puppetlabs:master (59b8bf64abaa89472f8b0aa593e439f05258843a)
- Requested merge: kelseyhightower:ticket/master/14461_remove_puppet_parser_functions (48bfccb45e8234fb6d20929b8259ee8dfccb5298)
Diff follows:
diff --git a/CHANGES.txt b/CHANGES.txt index d87c448..81836b7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,4 @@ +2012/05/14 - remove puppet parser functions 2011/06/26 - add hiera_hash function 2011/06/12 - Release 0.2.0 2011/06/11 - add hiera_array function diff --git a/README.md b/README.md index 487e945..98d2aa9 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,6 @@ scope for data. The data structure and approach is heavily based on work by Nigel Kersten but made more configurable and with full hierarchy. -It also includes a Puppet function that works like extlookup() -but uses the Hiera backends. - Usage? ====== @@ -129,12 +126,4 @@ $ extlookup2hiera --in common.csv --out common.json --json Installation? ============= -It's not 100% ready for prime time, shortly a simple _gem install hiera-puppet_ on your master will do it. - -For the moment the Gem install will place the Puppet Parser Function where Puppet cannot find it, you should -copy it out and distribute it to your master using Pluginsync or something similar - -Who? -==== - -R.I.Pienaar / [email protected] / @ripienaar / www.devco.net +Shortly a simple _gem install hiera-puppet_ on your master will do it. diff --git a/lib/puppet/parser/functions/hiera.rb b/lib/puppet/parser/functions/hiera.rb deleted file mode 100644 index ed5404f..0000000 --- a/lib/puppet/parser/functions/hiera.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:hiera, :type => :rvalue) do |*args| - # Functions called from puppet manifests that look like this: - # lookup("foo", "bar") - # internally in puppet are invoked: func(["foo", "bar"]) - # - # where as calling from templates should work like this: - # scope.function_lookup("foo", "bar") - # - # Therefore, declare this function with args '*args' to accept any number - # of arguments and deal with puppet's special calling mechanism now: - if args[0].is_a?(Array) - args = args[0] - end - - key = args[0] - default = args[1] - override = args[2] - - configfile = File.join([File.dirname(Puppet.settings[:config]), "hiera.yaml"]) - - raise(Puppet::ParseError, "Hiera config file #{configfile} not readable") unless File.exist?(configfile) - - require 'hiera' - require 'hiera/scope' - - config = YAML.load_file(configfile) - config[:logger] = "puppet" - - hiera = Hiera.new(:config => config) - - if self.respond_to?("[]") - hiera_scope = self - else - hiera_scope = Hiera::Scope.new(self) - end - - answer = hiera.lookup(key, default, hiera_scope, override, :priority) - - raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.nil? - - return answer - end -end diff --git a/lib/puppet/parser/functions/hiera_array.rb b/lib/puppet/parser/functions/hiera_array.rb deleted file mode 100644 index 31db5c9..0000000 --- a/lib/puppet/parser/functions/hiera_array.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:hiera_array, :type => :rvalue) do |*args| - if args[0].is_a?(Array) - args = args[0] - end - - key = args[0] - default = args[1] - override = args[2] - - configfile = File.join([File.dirname(Puppet.settings[:config]), "hiera.yaml"]) - - raise(Puppet::ParseError, "Hiera config file #{configfile} not readable") unless File.exist?(configfile) - - require 'hiera' - require 'hiera/scope' - - config = YAML.load_file(configfile) - config[:logger] = "puppet" - - hiera = Hiera.new(:config => config) - - if self.respond_to?("[]") - hiera_scope = self - else - hiera_scope = Hiera::Scope.new(self) - end - - answer = hiera.lookup(key, default, hiera_scope, override, :array) - - raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty? - - answer - end -end diff --git a/lib/puppet/parser/functions/hiera_hash.rb b/lib/puppet/parser/functions/hiera_hash.rb deleted file mode 100644 index ae665ca..0000000 --- a/lib/puppet/parser/functions/hiera_hash.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:hiera_hash, :type => :rvalue) do |*args| - if args[0].is_a?(Array) - args = args[0] - end - - raise(Puppet::ParseError, "Please supply a parameter to perform a Hiera lookup") if args.empty? - - key = args[0] - default = args[1] - override = args[2] - - configfile = File.join([File.dirname(Puppet.settings[:config]), "hiera.yaml"]) - - raise(Puppet::ParseError, "Hiera config file #{configfile} not readable") unless File.exist?(configfile) - - require 'hiera' - require 'hiera/scope' - - config = YAML.load_file(configfile) - config[:logger] = "puppet" - - hiera = Hiera.new(:config => config) - - if self.respond_to?("{}") - hiera_scope = self - else - hiera_scope = Hiera::Scope.new(self) - end - - answer = hiera.lookup(key, default, hiera_scope, override, :hash) - - raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty? - - answer - end -end diff --git a/lib/puppet/parser/functions/hiera_include.rb b/lib/puppet/parser/functions/hiera_include.rb deleted file mode 100644 index 3f53786..0000000 --- a/lib/puppet/parser/functions/hiera_include.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:hiera_include) do |*args| - if args[0].is_a?(Array) - args = args[0] - end - - key = args[0] - default = args[1] - override = args[2] - - configfile = File.join([File.dirname(Puppet.settings[:config]), "hiera.yaml"]) - - raise(Puppet::ParseError, "Hiera config file #{configfile} not readable") unless File.exist?(configfile) - - require 'hiera' - require 'hiera/scope' - - config = YAML.load_file(configfile) - config[:logger] = "puppet" - - hiera = Hiera.new(:config => config) - - if self.respond_to?("[]") - hiera_scope = self - else - hiera_scope = Hiera::Scope.new(self) - end - - answer = hiera.lookup(key, default, hiera_scope, override, :array) - - raise(Puppet::ParseError, "Could not find data item #{key} in any Hiera data file and no default supplied") if answer.empty? - - method = Puppet::Parser::Functions.function(:include) - send(method, answer) - end -end diff --git a/spec/unit/parser/functions/hiera_hash_spec.rb b/spec/unit/parser/functions/hiera_hash_spec.rb deleted file mode 100644 index 368df49..0000000 --- a/spec/unit/parser/functions/hiera_hash_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'puppet' -require 'hiera' -require 'spec_helper' - -describe 'Puppet::Parser::Functions#hiera_hash' do - it 'should require a key argument' do - Puppet::Parser::Functions.function(:hiera_hash) - @scope = Puppet::Parser::Scope.new - expect { @scope.function_hiera_hash([]) }.should raise_error(Puppet::ParseError) - end -end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
