Class: RegoValidate::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/cli.rb

Overview

Loads policy and input configuration files.

Constant Summary collapse

JSON_EXTENSIONS =
[".json"].freeze

Instance Method Summary collapse

Constructor Details

#initialize(reporter:, parser:, yaml_aliases:) ⇒ ConfigLoader

Create a config loader.

Parameters:



369
370
371
372
373
374
# File 'lib/ruby/rego/cli.rb', line 369

def initialize(reporter:, parser:, yaml_aliases:)
  @reporter = reporter
  @parser = parser
  @json_extensions = JSON_EXTENSIONS
  @yaml_aliases = yaml_aliases
end

Instance Method Details

#read_config(path) ⇒ ConfigLoadResult

Read and parse the config file content.

Parameters:

  • path (String)

Returns:



388
389
390
391
392
393
# File 'lib/ruby/rego/cli.rb', line 388

def read_config(path)
  content = read_file(path, "config")
  return ConfigLoadResult.new(success: false) unless content

  parse_config(content, path)
end

#read_policy(path) ⇒ String?

Read the policy file content.

Parameters:

  • path (String)

Returns:

  • (String, nil)


380
381
382
# File 'lib/ruby/rego/cli.rb', line 380

def read_policy(path)
  read_file(path, "policy")
end