CDLUC3 / mrt-dashboard

Merritt Dashboard
4 stars 1 forks source link

SSM_ROOT_PATH improperly set in config/initializers/config.rb. #87

Closed ashleygould closed 3 years ago

ashleygould commented 3 years ago

this is some really ugly code in config/initializers/config.rb. it relies on the hostname to obtain the SSM_ROOT_PATH.

  def load_uc3_config(name:, return_key: nil)
    myenv = Socket.gethostname.match?(/uc3-.*-/) ? Socket.gethostname.gsub(/uc3-.*-/, '') : 'stg'
    resolver = Uc3Ssm::ConfigResolver.new(
      def_value: 'NOT_APPLICABLE',
      region: ENV.key?('AWS_REGION') ? ENV['AWS_REGION'] : 'us-west-2',
      ssm_root_path: ENV.key?('SSM_ROOT_PATH') ? ENV['SSM_ROOT_PATH'] : "/uc3/mrt/#{myenv}/"

needs a cleaner way to handle situations when SSM_ROOT_PATH is not present in ENV. Ether raise and exception or define a set of default values in a :ssm_defaults dictionary.

ashleygould commented 3 years ago

I reposted this issue in mrt-doc