Skip to content

Env from

The hera.workflows.env_from module provides implementations of environment variable classes that can be created from K8s objects.

EnvFrom classes differs from Env classes as EnvFrom uses a source to retrieve a variable from, and you can only prefix the name with something. The Env classes can create new independent variables.

SecretEnvFrom

Exposes a K8s secret as an environment variable.

Source code in src/hera/workflows/env_from.py
@dataclass(kw_only=True)
class SecretEnvFrom(_BaseEnvFrom):
    """Exposes a K8s secret as an environment variable."""

    name: Optional[str] = None
    optional: Optional[bool] = None

    def build(self) -> _ModelEnvFromSource:
        """Constructs and returns the Argo EnvFrom specification."""
        return _ModelEnvFromSource(
            prefix=self.prefix,
            secret_ref=_ModelSecretEnvSource(
                name=self.name,
                optional=self.optional,
            ),
        )

name

name: Optional[str] = None

optional

optional: Optional[bool] = None

prefix

prefix: Optional[str] = None

build

build() -> EnvFromSource

Constructs and returns the Argo EnvFrom specification.

Source code in src/hera/workflows/env_from.py
def build(self) -> _ModelEnvFromSource:
    """Constructs and returns the Argo EnvFrom specification."""
    return _ModelEnvFromSource(
        prefix=self.prefix,
        secret_ref=_ModelSecretEnvSource(
            name=self.name,
            optional=self.optional,
        ),
    )

Comments