Skip to content

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

Operators

Initializers

Instance Properties

  • arguments
    The command-line arguments for this Environment.
  • commandInput
    Exposes the Environment’s arguments property as a CommandInput.
  • isRelease
    true if this environment is meant for production use cases.
  • name
    The environment’s unique name.

Type Properties

  • development
    An environment for developing your application.
  • process
    The current process of the environment.
  • production
    An environment for deploying your application to consumers.
  • testing
    An environment for testing your application.

Type Methods

  • custom(name:)
    Creates a custom environment.
  • detect(arguments:)
    Detects the environment from CommandLine.arguments. Invokes detect(from:).
  • detect(from:)
    Detects the environment from CommandInput. Parses the --env flag, with the VAPOR_ENV environment variable as a fallback.
  • get(_:)
    Gets a key from the process environment
  • secret(key:)
    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.
  • secret(key:fileIO:on:)
    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.
  • secret(path:)
    Load the content of a file at a given path as a secret.
  • secret(path:fileIO:on:)
    Load the content of a file at a given path as a secret.

Relationships

Conforms To

  • Swift.Equatable
  • Swift.Sendable
  • Swift.SendableMetatype