Module: AbideDevUtils::CEM::HieraData::ResourceData

Defined in:
lib/abide_dev_utils/cem/hiera_data/resource_data.rb,
lib/abide_dev_utils/cem/hiera_data/resource_data/control.rb,
lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb,
lib/abide_dev_utils/cem/hiera_data/resource_data/parameters.rb

Defined Under Namespace

Classes: Benchmark, Control, Parameters, Resource

Class Method Summary collapse

Class Method Details

.benchmarks_from_puppet_module(pupmod, ignore_all_errors: false, ignore_framework_mismatch: true) ⇒ Array<AbideDevUtils::CEM::Benchmark>

Creates Benchmark objects from a Puppet module

Parameters:

  • pupmod (AbideDevUtils::Ppt::PuppetModule)

    A PuppetModule instance

  • skip_errors (Boolean)

    True skips errors and loads non-erroring benchmarks, false raises the error.

Returns:



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
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data.rb', line 16

def self.benchmarks_from_puppet_module(pupmod, ignore_all_errors: false, ignore_framework_mismatch: true)
  frameworks = pupmod.hiera_conf.local_hiera_files(hierarchy_name: 'Mapping Data').each_with_object([]) do |hf, ary|
    parts = hf.path.split(pupmod.hiera_conf.default_datadir)[-1].split('/')
    ary << parts[2] unless ary.include?(parts[2])
  end
  pupmod.supported_os.each_with_object([]) do |supp_os, ary|
    osname, majver = supp_os.split('::')
    if majver.is_a?(Array)
      majver.sort.each do |v|
        frameworks.each do |fw|
          benchmark = Benchmark.new(osname,
                                    v,
                                    pupmod.hiera_conf,
                                    pupmod.name(strip_namespace: true),
                                    framework: fw)
          benchmark.controls
          ary << benchmark
        rescue AbideDevUtils::Errors::MappingDataFrameworkMismatchError => e
          raise e unless ignore_all_errors || ignore_framework_mismatch
        rescue StandardError => e
          raise e unless ignore_all_errors
        end
      end
    else
      frameworks.each do |fw|
        benchmark = Benchmark.new(osname,
                                  majver,
                                  pupmod.hiera_conf,
                                  pupmod.name(strip_namespace: true),
                                  framework: fw)
        benchmark.controls
        ary << benchmark
      rescue AbideDevUtils::Errors::MappingDataFrameworkMismatchError => e
        raise e unless ignore_all_errors || ignore_framework_mismatch
      rescue StandardError => e
        raise e unless ignore_all_errors
      end
    end
  end
end