aboutsummaryrefslogblamecommitdiff
path: root/src/main/scala/com/drivergrp/core/config.scala
blob: 29cd9ed9f5365b82acfce21cd9db9c7ecfd2896a (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                  

               
                                   
                                                                                             
 
                                                     
 
                            
                                           
                                  



                                                                          
 
                                 
     

   
package com.drivergrp.core

import java.io.File
import com.typesafe.config.{Config, ConfigFactory}

object config {

  def loadDefaultConfig: Config = {
    val configDefaults = ConfigFactory.load(this.getClass.getClassLoader, "application.conf")

    scala.sys.props.get("application.config") match {

      case Some(filename) =>
        val configFile = new File(filename)
        if (configFile.exists()) {
          ConfigFactory.parseFile(configFile).withFallback(configDefaults)
        } else {
          throw new IllegalStateException(s"No config found at $filename")
        }

      case None => configDefaults
    }
  }
}