+ def load_config_file(config_file_path="~/.config/arvados/settings.conf")
+ # Initialize config settings with environment variables.
+ config = {}
+ config['ARVADOS_API_HOST'] = ENV['ARVADOS_API_HOST']
+ config['ARVADOS_API_TOKEN'] = ENV['ARVADOS_API_TOKEN']
+ config['ARVADOS_API_HOST_INSECURE'] = ENV['ARVADOS_API_HOST_INSECURE']
+ config['ARVADOS_API_VERSION'] = ENV['ARVADOS_API_VERSION']
+
+ # Load settings from the config file.
+ lineno = 0
+ File.open(File.expand_path config_file_path).each do |line|
+ lineno = lineno + 1
+ # skip comments and blank lines
+ next if line.match('^\s*#') or not line.match('\S')
+ var, val = line.chomp.split('=', 2)
+ # allow environment settings to override config files.
+ if var and val
+ config[var] ||= val
+ else
+ warn "#{config_file}: #{lineno}: could not parse `#{line}'"
+ end
+ end
+
+ config
+ end
+