desc | Environment selector and validator for environments such as (local, dev, qa, stg, prod) ) |
date | 2021-01-03 |
version | 2.0.0 |
jar | slatekit.common.jar |
namespace | slatekit.common.envs |
artifact | com.slatekit:slatekit-common |
source folder | src/lib/kotlin/slatekit-common/src/main/kotlin/slatekit/common/envs |
example | src/lib/kotlin/slate-examples/src/main/kotlin/slatekit/examples/Example_Env.kt |
depends on | slatekit-results |
// other setup ...
repositories {
maven { url "https://dl.bintray.com/codehelixinc/slatekit" }
}
dependencies {
// other libraries
// slatekit-common: Utilities for Android or Server
compile 'com.slatekit:slatekit-common:0.9.35'
}
// required
import slatekit.common.envs.*
// optional
import slatekit.cmds.Command
import slatekit.cmds.CommandRequest
import slatekit.results.Try
import slatekit.results.Success
n/a
// CASE 1: Build a list of environments
val envs1 = Envs(listOf(
Env("loc", EnvMode.Dev , desc = "Dev environment (local)"),
Env("dev", EnvMode.Dev , desc = "Dev environment (dev)"),
Env("qat", EnvMode.Qat , desc = "QAT environment (test)"),
Env("stg", EnvMode.Uat , desc = "STG environment (demo)"),
Env("pro", EnvMode.Pro , desc = "LIVE environment")
))
// CASE 2: Use the default list of environments ( same as above )
val envs = slatekit.common.envs.Envs.defaults()
// CASE 3: Get one of the environments by api
val qa1 = envs.get("qa1")
println( qa1 )
// CASE 4: Validate one of the environments by api
println( envs.isValid("qa2") )
// CASE 5: Current environment ( nothing - none selected )
println( envs.current )
// CASE 6: Select an environment
val envs2 = envs.select("dev")
println( envs2 )
// CASE 7: Get info about currently selected environment
println( envs2.name )
println( envs2.isDev )
println( envs2.isQat )
println( envs2.isUat )
println( envs2.isPro )
println( envs2.current )