ExDaytona.ObjectStorage (ex_daytona v0.1.0)

Copy Markdown View Source

Build-context uploads for declarative image builds.

When an ExDaytona.Image includes local files (add_local_file/3, add_local_dir/3), the files are packaged as tars and pushed to Daytona's S3-compatible object storage before the build; the build references them by content hash (contextHashes). This module implements that flow — ExDaytona.Sandbox.create/2 calls it automatically, so it is rarely used directly.

The upload speaks S3 (SigV4) via the SDK's own HTTP stack — no AWS dependency.

Summary

Functions

The archive path for a local path: normalized, without the leading separator — used as the tar entry name, the content-hash salt, and the COPY source in the generated Dockerfile.

Temporary push credentials for the organization's build-context storage, as a snake_case map.

Upload one build context (a file or directory) and return its hash.

Like upload_context/3 but reuses already-fetched push credentials — used to upload several contexts under one credential grant.

Functions

archive_base_path(path)

@spec archive_base_path(Path.t()) :: String.t()

The archive path for a local path: normalized, without the leading separator — used as the tar entry name, the content-hash salt, and the COPY source in the generated Dockerfile.

push_access(client)

@spec push_access(ExDaytona.Client.t()) ::
  {:ok,
   %{
     access_key: String.t(),
     secret: String.t(),
     session_token: String.t() | nil,
     bucket: String.t(),
     storage_url: String.t(),
     region: String.t() | nil,
     organization_id: String.t()
   }}
  | {:error, ExDaytona.Error.t()}

Temporary push credentials for the organization's build-context storage, as a snake_case map.

upload_context(client, source_path, opts \\ [])

@spec upload_context(ExDaytona.Client.t(), Path.t(), keyword()) ::
  {:ok, String.t()} | {:error, ExDaytona.Error.t()}

Upload one build context (a file or directory) and return its hash.

Skips the upload when an object with the same content hash already exists. archive_path defaults to archive_base_path(source_path).

upload_context_with_access(access, source_path, opts \\ [])

@spec upload_context_with_access(map(), Path.t(), keyword()) ::
  {:ok, String.t()} | {:error, ExDaytona.Error.t()}

Like upload_context/3 but reuses already-fetched push credentials — used to upload several contexts under one credential grant.