Puppet Function: es_plugin_name
- Defined in:
- lib/puppet/parser/functions/es_plugin_name.rb
- Function type:
- Ruby 3.x API
Overview
Given a string, return the best guess at what the directory name will be for the given plugin. Any arguments past the first will be fallbacks (using the same logic) should the first fail.
For example, all the following return values are “plug”:
es_plugin_name('plug')
es_plugin_name('foo/plug')
es_plugin_name('foo/plug/1.0.0')
es_plugin_name('foo/elasticsearch-plug')
es_plugin_name('foo/es-plug/1.3.2')
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/parser/functions/es_plugin_name.rb', line 9 newfunction( :es_plugin_name, type: :rvalue, doc: <<-ENDHEREDOC) do |args| Given a string, return the best guess at what the directory name will be for the given plugin. Any arguments past the first will be fallbacks (using the same logic) should the first fail. For example, all the following return values are "plug": es_plugin_name('plug') es_plugin_name('foo/plug') es_plugin_name('foo/plug/1.0.0') es_plugin_name('foo/elasticsearch-plug') es_plugin_name('foo/es-plug/1.3.2') @return String ENDHEREDOC if args.empty? raise Puppet::ParseError, 'wrong number of arguments, at least one value required' end ret = args.select do |arg| arg.is_a?(String) && !arg.empty? end.first if ret Puppet_X::Elastic.plugin_name ret else raise Puppet::Error, 'could not determine plugin name' end end |