Lightning.Projects.Environment (Lightning v2.19.0-pre)

View Source

Which environment a project resolves its credentials in.

A credential can hold a body per environment, and the environment name is what selects between them. Anything reaching for a credential body therefore has to answer this question first, and every caller answering it differently is how two of them ended up hard-coding "main" and handing sandbox members the parent project's production secret.

This is that answer, in one place. It fails closed: a sandbox with no environment set gets an error rather than a guess, because guessing here means guessing which secret to hand over.

Summary

Functions

The environment for whatever you have in hand.

Types

error()

@type error() :: :environment_not_configured | :project_not_found

subject()

@type subject() ::
  Lightning.Projects.Project.t()
  | Lightning.Run.t()
  | Ecto.UUID.t()
  | %{project_id: Ecto.UUID.t()}
  | nil

Functions

fetch(project)

@spec fetch(subject()) :: {:ok, String.t()} | {:error, error()}

The environment for whatever you have in hand.

Takes a project, a run, a project id, or any struct carrying a project_id, so a caller does not have to load a project it does not otherwise need. That matters at the channel proxy, which holds a channel and never preloads its project.