Skip to content

Parameters

The param() function is a Python-only feature that reads values from environment variables at render time.

Basic Usage

from helm_me import App, param

class Deploy(App):
    name = "my-app"
    namespace = param("NAMESPACE", "default")
NAMESPACE=production helm-me render deploy.py
# Uses "production" as the namespace

helm-me render deploy.py
# Uses "default" (the fallback)

Parameterize Anything

class Deploy(App):
    name = "my-app"
    namespace = param("NS", "default")
    tag = param("TAG", "latest")
    image_pull_secrets = [param("PULL_SECRET", "ghcr-creds")]

    backend = web(
        image=image(
            repository=param("IMAGE", "ghcr.io/example/backend"),
            tag=param("TAG", "latest"),
        ),
        port=8000,
        replicas=param("REPLICAS", 2),
    )

CI/CD Integration

# GitHub Actions example
- name: Deploy to staging
  run: |
    NS=staging TAG=${{ github.sha }} REPLICAS=1 \
      helm-me deploy deploy.py --yes

- name: Deploy to production
  run: |
    NS=production TAG=${{ github.ref_name }} REPLICAS=3 \
      helm-me deploy deploy.py --yes

Typed Parameters

param() infers the type from the default value:

replicas = param("REPLICAS", 2)        # int
enabled = param("ENABLE_CHAT", True)   # bool
tag = param("TAG", "latest")           # str