In-Memory Provider

A cloud provider in memory, for tests and local development without a cloud account.

Its DNS zones, records and certificates are kept in memory, and behave like a cloud’s, so that tests exercise the service layer, and its signals, without reaching real infrastructure.

from smarter.apps.infrastructure.providers import configure_provider
from smarter.apps.infrastructure.providers.memory import InMemoryProvider

provider = InMemoryProvider()
configure_provider(lambda: provider)
provider.dns.add_zone("example.com")
provider.certificates.issue_all = True
class smarter.apps.infrastructure.providers.memory.InMemoryCertificateService(provider, dns, **kwargs)[source]

Bases: CertificateService

TLS certificates in memory, issued once their validation records exist, or at once with issue_all.

__init__(provider, dns, **kwargs)[source]
issue_all

Issue every certificate, whether or not its validation records exist.

issue_wait_seconds: float = 0

Seconds between the checks.

property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

validation_wait_seconds: float = 0

Seconds between the attempts.

A provider generates validation records in seconds.

class smarter.apps.infrastructure.providers.memory.InMemoryDNSService(provider, **kwargs)[source]

Bases: DNSService

DNS zones and records in memory.

__init__(provider, **kwargs)[source]
add_zone(domain, a_record=None)[source]

Add a zone, e.g. the environment’s API domain, optionally with an A record.

Return type:

DNSZone

property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

record_wait_seconds: float = 0

Seconds between the attempts.

records: dict[str, list[DNSRecord]]
zones: dict[str, DNSZone]
class smarter.apps.infrastructure.providers.memory.InMemoryProvider(ready=True, **kwargs)[source]

Bases: CloudProvider

A cloud provider in memory.

Parameters:

ready (bool) – Whether the provider is authenticated.

__init__(ready=True, **kwargs)[source]
property account_id: str | None

The cloud account’s id, or None if the provider is not authenticated.

property certificates: InMemoryCertificateService

The provider’s TLS certificate service.

cluster_info: dict[str, Any]
property dns: InMemoryDNSService

The provider’s DNS service.

get_kubernetes_cluster_info()[source]

Describe the platform’s Kubernetes cluster, e.g. for the status API.

Raises:

InfrastructureNotReadyError – If the provider is not ready.

Return type:

dict[str, Any]

property identity: dict[str, Any] | None

The identity that the provider authenticates as, e.g. its account, or None.

name: str = 'memory'

The provider’s name, see CloudProviders.

property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

property sdk_version: str

The version of the provider’s SDK.

update_kubeconfig()[source]

Write the kubeconfig of the platform’s Kubernetes cluster, for kubectl.

Return type:

bool

Returns:

True if it was written.