Class: Abide::CLI::XccdfToHieraCommand
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::XccdfToHieraCommand
- 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
- #execute(xccdf_file) ⇒ Object
-
#initialize ⇒ XccdfToHieraCommand
constructor
A new instance of XccdfToHieraCommand.
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, to_h, #to_h
Constructor Details
#initialize ⇒ XccdfToHieraCommand
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) .on('-b [TYPE]', '--benchmark-type [TYPE]', 'XCCDF Benchmark type') { |b| @data[:type] = b } .on('-o [FILE]', '--out-file [FILE]', 'Path to save file') { |f| @data[:file] = f } .on('-p [PREFIX]', '--parent-key-prefix [PREFIX]', 'A prefix to append to the parent key') do |p| @data[:parent_key_prefix] = p end .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 |