Environment

public struct Environment: Equatable

The environment the application is running in, i.e., production, dev, etc. All Container’s will have an Environment that can be used to dynamically register and configure services.

switch env {
case .production: config.prefer(ProductionLogger.self, for: Logger.self)
default: config.prefer(DebugLogger.self, for: Logger.self)
}

The Environment can also be used to retrieve variables from the Process’s ENV.

print(Environment.get("DB_PASSWORD"))
  • An environment for deploying your application to consumers.

    Declaration

    Swift

    public static var production: Environment
  • An environment for developing your application.

    Declaration

    Swift

    public static var development: Environment
  • An environment for testing your application.

    Declaration

    Swift

    public static var testing: Environment
  • Creates a custom environment.

    Declaration

    Swift

    public static func custom(name: String, isRelease: Bool = false) -> Environment
  • Gets a key from the process environment

    Declaration

    Swift

    public static func get(_ key: String) -> String?
  • See Equatable

    Declaration

    Swift

    public static func ==(lhs: Environment, rhs: Environment) -> Bool
  • The environment’s unique name.

    Declaration

    Swift

    public let name: String
  • true if this environment is meant for production use cases.

    This usually means reducing logging, disabling debug information, and sometimes providing warnings about configuration states that are not suitable for production.

    Declaration

    Swift

    public let isRelease: Bool
  • The command-line arguments for this Environment.

    Declaration

    Swift

    public var arguments: [String]