Skip to main content

synth_ai.sdk.harbor.packager

HarborPackager - Package build context for Harbor deployments. This module handles packaging a directory into a tar.gz archive suitable for uploading to Harbor. It respects include/exclude globs and handles file filtering. Example:
>>> from synth_ai.sdk.harbor import HarborBuildSpec
>>> from synth_ai.sdk.harbor.packager import HarborPackager
>>>
>>> spec = HarborBuildSpec(
...     name="my-deployment",
...     dockerfile_path="./Dockerfile",
...     context_dir="./my-project",
... )
>>>
>>> packager = HarborPackager(spec)
>>> context_base64 = packager.package()
>>> print(f"Packaged {len(context_base64)} bytes")

Classes

HarborPackager

Package build context into tar.gz for Harbor upload. Handles file filtering based on include/exclude globs, creates a compressed tar archive, and returns it as base64. Attributes:
  • spec: The HarborBuildSpec to package
  • max_size_mb: Maximum allowed package size in MB (default: 100)
Methods:

package

package(self) -> str
Package the build context into a base64-encoded tar.gz. Returns:
  • Base64-encoded string of the tar.gz archive
Raises:
  • FileNotFoundError: If context_dir doesn’t exist
  • ValueError: If package exceeds max_size_mb

get_file_list

get_file_list(self) -> list[str]
Get list of files that will be included in the package. Useful for debugging include/exclude patterns. Returns:
  • List of relative paths that will be included

get_package_info

get_package_info(self) -> dict[str, Any]
Get information about the package without creating it. Returns:
  • Dictionary with file count, estimated size, etc.