Structure
Environment
The environment the application is running in, i.e., production, dev, etc. All
Containers will have an Environment that can be used to dynamically register and configure services.struct Environment
Overview
switch env {
case .production:
app.http.server.configuration = ...
default: break
}
The Environment can also be used to retrieve variables from the Process’ ENV.
print(Environment.get("DB_PASSWORD"))
Topics
Structures
struct ProcessThe process information of an environment. WrapsProcessInto.processInfo.
Operators
static func == (Environment, Environment) -> BoolSeeEquatable
Initializers
init(name: String, arguments: [String])Create a newEnvironment.
Instance Properties
var arguments: [String]The command-line arguments for thisEnvironment.var commandInput: CommandInputExposes theEnvironment’sargumentsproperty as aCommandInput.var isRelease: Booltrueif this environment is meant for production use cases.let name: StringThe environment’s unique name.
Type Properties
static var development: EnvironmentAn environment for developing your application.static var process: Environment.ProcessThe current process of the environment.static var production: EnvironmentAn environment for deploying your application to consumers.static var testing: EnvironmentAn environment for testing your application.
Type Methods
static func custom(name: String) -> EnvironmentCreates a custom environment.static func detect(arguments: [String]) throws -> EnvironmentDetects the environment fromCommandLine.arguments. Invokesdetect(from:).static func detect(from: inout CommandInput) throws -> EnvironmentDetects the environment fromCommandInput. Parses the--envflag, with theVAPOR_ENVenvironment variable as a fallback.static func get(String) -> String?Gets a key from the process environmentstatic func secret(key: String) async throws -> String?Reads a file’s content for a secret. The secret key is the name of the environment variable that is expected to specify the path of the file containing the secret.static func secret(key: String, fileIO: NonBlockingFileIO, on: any EventLoop) -> EventLoopFuture<String?>Reads a file’s content for a secret. The secret key is the name of the environment variable that is expected to specify the path of the file containing the secret.static func secret(path: String) async throws -> String?Load the content of a file at a given path as a secret.static func secret(path: String, fileIO: NonBlockingFileIO, on: any EventLoop) -> EventLoopFuture<String?>Load the content of a file at a given path as a secret.
Relationships
Conforms To
Swift.EquatableSwift.SendableSwift.SendableMetatype