Class: RegoValidate::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/cli/loading.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:



16
17
18
19
20
21
# File 'lib/ruby/rego/cli/loading.rb', line 16

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:



35
36
37
38
39
40
# File 'lib/ruby/rego/cli/loading.rb', line 35

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)


27
28
29
# File 'lib/ruby/rego/cli/loading.rb', line 27

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