Packages

  • package root
    Definition Classes
    root
  • package args4c

    Args4c (arguments for configuration) is intended to add some helpers and utilities in obtaining a typesafe configuration from user arguments.

    Args4c (arguments for configuration) is intended to add some helpers and utilities in obtaining a typesafe configuration from user arguments.

    The core is simply to convert an Array[String] to a Config where the arguments are either paths to configuration resources or simple key=value pairs via args4c.configForArgs

    Left-most arguments take precedence. In this example, we assume 'prod.conf' is a resource on the classpath:

    MyApp foo.x=bar foo.x=ignored /opt/etc/overrides.conf prod.conf

    In addition to this core concept, this library also provides some additional configuration utilities via args4c.RichConfigOps which can be made available by extending args4c.LowPriorityArgs4cImplicits or importing args4c.implicits:

    import args4c.implicits._
    object MyApp {
       override def main(args : Array[String]) : Unit = {
         val config = args.asConfig()
         println("Starting MyApp with config:")
    
         // let's "log" our app's config on startup:
         val flatSummary : String = config.filter(_.startsWith("myapp")).summary()
         println(flatSummary) // "logging" our config
       }
    }

    Where the 'summary' will produce sorted args4c.StringEntry values with potentially sensitive entries (e.g. passwords) obscured and a source comment for some sanity as to where each entry comes from:

    myapp.foo : bar # command-line
    myapp.password : **** obscured **** # command-line
    myapp.saveTo : afile # file:/opt/etc/myapp/test.conf@3

    Also, when extracting user arguments into a configuration, an additional 'fallback' config is specified. Typically this would just be the ConfigFactory.load() configuration, but args4c uses the args4c.defaultConfig, which is essentially just the system environment variables converted from snake-caes to dotted lowercase values first, then falling back on ConfigFactory.load().

    Applications can elect to not have this behaviour and provide their own fallback configs when parsing args, but the default provides a convenience for system environment variables to override e.g. 'foo.bar.x=default' by specifying

    FOO_BAR_X=override

    as a system environment variable. Otherwise you may end up having to repeat this sort of thing all over you config:

    foo.bar=default
    foo.bar=$${?FOO_BAR}
    
    foo.bazz=default2
    foo.bazz=$${?FOO_BAZZ}
    
    ...

    Finally, args4c also provides a args4c.ConfigApp which provides some additional functionality to configuration-based applications.

    Definition Classes
    root
  • ConfigApp
  • Encryption
  • LowPriorityArgs4cImplicits
  • PasswordPrompt
  • Prompt
  • PromptForConfigFilePermissions
  • PromptForExistingPassword
  • PromptForPassword
  • PromptForUpdatedPassword
  • ReadNextKeyValuePair
  • ReadNextKeyValuePairAfterError
  • RichConfig
  • RichConfigOps
  • SaveSecretPrompt
  • SecureConfig
  • Selected
  • StringEntry
  • implicits

case class SecureConfig(promptForInput: UserInput) extends Product with Serializable

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SecureConfig
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SecureConfig(promptForInput: UserInput)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  9. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  10. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  12. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  13. def productElementNames: Iterator[String]
    Definition Classes
    Product
  14. val promptForInput: UserInput
  15. def readConfigPassword(): Array[Byte]

    returns

    the application config password used to encrypt the config

    Attributes
    protected
  16. def readSecureConfigAtPath(pathToEncryptedConfig: Path): Option[Config]

    read the configuration from the given path, prompting for the password via 'promptForInput' should the SecureConfig.SecureEnvVariableName environment variable not be set

    read the configuration from the given path, prompting for the password via 'promptForInput' should the SecureConfig.SecureEnvVariableName environment variable not be set

    pathToEncryptedConfig

    the path pointing at the encrypted config

    returns

    a configuration if the file exists

  17. def setupSecureConfig(defaultSecureConfigFilePath: Path, requiredPaths: Seq[String] = Nil): Path

    defaultSecureConfigFilePath

    the default path to store the configuration in, either from the --secure=x/y/z user arg, and env variable or default

    requiredPaths

    a potentially empty list of configuration paths which need to have values specified

    returns

    the path to the secure config

  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def updateSecureConfig(configPath: Path, requiredPaths: Seq[String]): Path

    prompt for and set some secure values

    prompt for and set some secure values

    configPath

    the path where the secure config is written

    requiredPaths

    a potentially empty list of configuration paths which need to have values specified

    returns

    the path to the encrypted configuration file

  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped