Class: Puppet::Indirector::ResourceType::Parser
- Defined in:
- lib/vendor/puppet/indirector/resource_type/parser.rb
Constant Summary
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows
Constants included from Util::Docs
Instance Attribute Summary
Attributes included from Util::Docs
Instance Method Summary collapse
Methods inherited from Terminus
abstract_terminus?, const2name, #indirection, indirection_name, inherited, #initialize, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type
Methods included from Util::InstanceLoader
#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Constructor Details
This class inherits a constructor from Puppet::Indirector::Terminus
Instance Method Details
#find(request) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vendor/puppet/indirector/resource_type/parser.rb', line 8 def find(request) krt = request.environment.known_resource_types # This is a bit ugly. [:hostclass, :definition, :node].each do |type| # We have to us 'find_<type>' here because it will # load any missing types from disk, whereas the plain # '<type>' method only returns from memory. if r = krt.send("find_#{type}", [""], request.key) return r end end nil end |
#search(request) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vendor/puppet/indirector/resource_type/parser.rb', line 23 def search(request) krt = request.environment.known_resource_types # Make sure we've got all of the types loaded. krt.loader.import_all result = [krt.hostclasses.values, krt.definitions.values, krt.nodes.values].flatten.reject { |t| t.name == "" } return nil if result.empty? return result if request.key == "*" # Strip the regex of any wrapping slashes that might exist key = request.key.sub(/^\//, '').sub(/\/$/, '') begin regex = Regexp.new(key) rescue => detail raise ArgumentError, "Invalid regex '#{request.key}': #{detail}" end result.reject! { |t| t.name.to_s !~ regex } return nil if result.empty? result end |