class Vcloud::Tools::Tester::UserParameters
Attributes
user_params[R]
Public Class Methods
new(config_file, expected_params)
click to toggle source
# File lib/vcloud/tools/tester/user_parameters.rb, line 9 def initialize(config_file, expected_params) @config_file = config_file @expected_params = expected_params || [] parse_config end
Private Instance Methods
parse_config()
click to toggle source
# File lib/vcloud/tools/tester/user_parameters.rb, line 18 def parse_config unless File.exist?(@config_file) raise ArgumentError.new("Missing required file: #{@config_file}") end organization = ENV.fetch('FOG_CREDENTIAL') do raise "Must set FOG_CREDENTIAL environment variable" end all_config = YAML::load_file(@config_file) @user_params = all_config.fetch(organization) do raise "No matching organisation was found in #{@config_file} for FOG_CREDENTIAL value '#{organization}'" end defined_keys = @user_params.keys missing_params = @expected_params - defined_keys if missing_params.any? raise "Required parameters not defined in #{@config_file}: " + missing_params.join(", ") end end