Class: Abide::CLI::XccdfToHieraCommand

Inherits:
AbideCommand
  • Object
show all
Defined in:
lib/abide_dev_utils/cli/xccdf.rb

Constant Summary collapse

CMD_NAME =
'to-hiera'
CMD_SHORT =
'Generates control coverage report'
CMD_LONG =
'Generates report of valid Puppet classes that match with Hiera controls'

Constants included from AbideDevUtils::Config

AbideDevUtils::Config::DEFAULT_PATH

Instance Method Summary collapse

Methods included from AbideDevUtils::Config

config_section, #config_section, fetch, #fetch, to_h, #to_h

Constructor Details

#initializeXccdfToHieraCommand

Returns a new instance of XccdfToHieraCommand.



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/abide_dev_utils/cli/xccdf.rb', line 78

def initialize
  super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false)
  options.on('-b [TYPE]', '--benchmark-type [TYPE]', 'XCCDF Benchmark type') { |b| @data[:type] = b }
  options.on('-o [FILE]', '--out-file [FILE]', 'Path to save file') { |f| @data[:file] = f }
  options.on('-p [PREFIX]', '--parent-key-prefix [PREFIX]', 'A prefix to append to the parent key') do |p|
    @data[:parent_key_prefix] = p
  end
  options.on('-N', '--number-fmt', 'Format Hiera control names based off of control number instead of name.') do
    @data[:num] = true
  end
end

Instance Method Details

#execute(xccdf_file) ⇒ Object



90
91
92
93
94
# File 'lib/abide_dev_utils/cli/xccdf.rb', line 90

def execute(xccdf_file)
  @data[:type] = 'cis' if @data[:type].nil?
  hfile = AbideDevUtils::XCCDF.to_hiera(xccdf_file, @data)
  AbideDevUtils::Output.yaml(hfile, console: @data[:file].nil?, file: @data[:file])
end