Puppet Function: ora_secured::default_doc_version

Defined in:
lib/puppet/functions/ora_secured/default_doc_version.rb
Function type:
Ruby 4.x API

Summary

Determins the CIS default doc_version based on the product_version.

Overview

ora_secured::default_doc_version(Optional[String[1]] $product_version, Enum['cis','stig'] $benchmark)Any

It uses the following algorithmn:

  1. Use the specified version for this database

  2. Use a generic specified version for all databases

  3. Use the latest version available for thos product_version

See the file “LICENSE” for the full license governing this code.

Parameters:

  • product_version (Optional[String[1]])
  • benchmark (Enum['cis','stig'])

Returns:

  • (Any)


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
44
45
46
47
48
49
50
# File 'lib/puppet/functions/ora_secured/default_doc_version.rb', line 17

Puppet::Functions.create_function('ora_secured::default_doc_version') do
  dispatch :default_doc_version do
    param 'Optional[String[1]]', :product_version
    param "Enum['cis','stig']", :benchmark
  end

  def default_doc_version(product_version, benchmark)
    #
    # When a version is specified, use it.
    #
    value = lookup_setting('doc_version', nil)
    return value if value
    return nil if product_version.nil?

    #
    # The array of versions is sorted from newest on top down to the latest. So the first one
    # in the array is the lastest and we need that one.
    #
    valid_combinations(benchmark)[product_version].first
  end

  def lookup_setting(sid, default_value)
    call_function('ora_secured::lookup_setting', sid, default_value)
  end

  def valid_combinations(benchmark)
    @valid_combinations ||= call_function('lookup', "ora_secured::#{benchmark}::valid_combinations", data_type('Hash'), 'first', nil)
  end

  def data_type(string)
    parser = Puppet::Pops::Types::TypeParser.singleton
    parser.parse(string)
  end
end