Skip to content

Commit

Permalink
EmrEtlRunner & StorageLoader: supported environment variables in YAML…
Browse files Browse the repository at this point in the history
… config files (closes #1215)
  • Loading branch information
fblundun committed Jun 23, 2015
1 parent b3eefa3 commit b0f4b65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions 3-enrich/emr-etl-runner/lib/snowplow-emr-etl-runner/cli.rb
Expand Up @@ -16,6 +16,7 @@
require 'optparse'
require 'yaml'
require 'contracts'
require 'erb'

module Snowplow
module EmrEtlRunner
Expand Down Expand Up @@ -135,14 +136,16 @@ def self.load_config(config_file, optparse)

# A single hyphen indicates that the config should be read from stdin
if config_file == '-'
config = YAML.load($stdin.readlines.join)
config = $stdin.readlines.join
elsif File.file?(config_file)
config = YAML.load_file(config_file)
config = File.new(config_file).read
else
raise ConfigError, "Configuration file '#{config_file}' does not exist, or is not a file\n#{optparse}"
end

recursive_symbolize_keys(config)
erb_config = ERB.new(config).result(binding)

recursive_symbolize_keys(YAML.load(erb_config))
end

# Load the enrichments directory into an array
Expand Down
Expand Up @@ -16,6 +16,7 @@
require 'optparse'
require 'date'
require 'yaml'
require 'erb'
require 'sluice'

# Config module to hold functions related to CLI argument parsing
Expand All @@ -36,12 +37,14 @@ def get_config()
options = Config.parse_args()

if Config.indicates_read_from_stdin?(options[:config])
unsymbolized_config = YAML.load($stdin.readlines.join)
unsymbolized_config = $stdin.readlines.join
else
unsymbolized_config = YAML.load_file(options[:config])
unsymbolized_config = File.new(options[:config]).read
end

config = Config.recursive_symbolize_keys(unsymbolized_config)
erb_config = ERB.new(unsymbolized_config).result(binding)

config = Config.recursive_symbolize_keys(YAML.load(erb_config))


# Add in our skip and include settings
Expand Down

0 comments on commit b0f4b65

Please sign in to comment.