Skip to content

DevOps

Validated types for DevOps tooling: Docker, Helm, Kubernetes, Terraform, and Git.

Modules:

  • docker

    Validated types for Docker image references.

  • git

    Validated types for Git references and URLs.

  • helm

    Validated types for Helm chart references.

  • k8s

    Validated types for Kubernetes resource names and namespaces.

  • terraform

    Validated types for Terraform resource identifiers.

Classes:

  • DockerImageRef

    A Docker/OCI image reference like registry/repo:tag@digest.

  • GitHttpsUrl

    A Git HTTPS clone URL like https://github.com/owner/repo.git with parsed properties.

  • GitSshUrl

    A Git SSH clone URL like git@github.com:owner/repo.git with parsed properties.

  • K8sLabelKey

    A valid Kubernetes label key with optional prefix and name.

  • TerraformResourceAddress

    A Terraform resource address like aws_instance.web.

Attributes:

  • GitCommitSha

    A full 40-character Git commit SHA-1 hash (normalized to lowercase) (e.g. a94a8fe5ccb19ba61c4c0873d391e987982fbbd3).

  • GitRef

    A valid Git ref name (branch or tag) per git-check-ref-format rules (e.g. main).

  • GitShortSha

    A Git short SHA prefix (7-40 hex characters, normalized to lowercase) (e.g. a94a8fe).

  • HelmChartName

    A valid Helm chart name (e.g. nginx).

  • K8sLabelValue

    A valid Kubernetes label value (max 63 chars, empty allowed) (e.g. v1.0).

  • K8sNamespaceName

    A valid Kubernetes namespace name (RFC 1123 DNS label) (e.g. default).

  • K8sResourceName

    A valid Kubernetes resource name (RFC 1123 DNS subdomain, max 253 chars) (e.g. my-deployment).

GitCommitSha module-attribute

GitCommitSha = Annotated[str, AfterValidator(_validate_git_commit_sha), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A full 40-character Git commit SHA-1 hash (normalized to lowercase)', 'examples': ['a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'], 'title': 'GitCommitSha', 'minLength': 40, 'maxLength': 40})]

A full 40-character Git commit SHA-1 hash (normalized to lowercase) (e.g. a94a8fe5ccb19ba61c4c0873d391e987982fbbd3).

GitRef module-attribute

GitRef = Annotated[str, AfterValidator(_validate_git_ref), WithJsonSchema({'type': 'string', 'description': 'A valid Git ref name (branch or tag) per git-check-ref-format rules', 'examples': ['main', 'feature/my-branch', 'refs/heads/main', 'v1.0'], 'title': 'GitRef', 'minLength': 1})]

A valid Git ref name (branch or tag) per git-check-ref-format rules (e.g. main).

GitShortSha module-attribute

GitShortSha = Annotated[str, AfterValidator(_validate_git_short_sha), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A Git short SHA prefix (7-40 hex characters, normalized to lowercase)', 'examples': ['a94a8fe'], 'title': 'GitShortSha', 'minLength': 7, 'maxLength': 40})]

A Git short SHA prefix (7-40 hex characters, normalized to lowercase) (e.g. a94a8fe).

HelmChartName module-attribute

HelmChartName = Annotated[str, AfterValidator(_validate_helm_chart_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A valid Helm chart name.', 'examples': ['nginx', 'cert-manager'], 'title': 'HelmChartName'})]

A valid Helm chart name (e.g. nginx).

K8sLabelValue module-attribute

K8sLabelValue = Annotated[str, AfterValidator(_validate_k8s_label_value), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A valid Kubernetes label value (max 63 chars, empty allowed).', 'examples': ['v1.0', 'production', ''], 'title': 'K8sLabelValue'})]

A valid Kubernetes label value (max 63 chars, empty allowed) (e.g. v1.0).

K8sNamespaceName module-attribute

K8sNamespaceName = Annotated[str, AfterValidator(_validate_k8s_namespace_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A valid Kubernetes namespace name (RFC 1123 DNS label).', 'examples': ['default', 'kube-system'], 'title': 'K8sNamespaceName'})]

A valid Kubernetes namespace name (RFC 1123 DNS label) (e.g. default).

K8sResourceName module-attribute

K8sResourceName = Annotated[str, AfterValidator(_validate_k8s_resource_name), WithJsonSchema({'type': 'string', 'pattern': pattern, 'description': 'A valid Kubernetes resource name (RFC 1123 DNS subdomain, max 253 chars).', 'examples': ['my-deployment', 'nginx-pod'], 'title': 'K8sResourceName'})]

A valid Kubernetes resource name (RFC 1123 DNS subdomain, max 253 chars) (e.g. my-deployment).

DockerImageRef

Bases: str

A Docker/OCI image reference like registry/repo:tag@digest.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for DockerImageRef.

Source code in src/pydantypes/devops/docker.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for DockerImageRef."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for DockerImageRef.

Source code in src/pydantypes/devops/docker.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for DockerImageRef."""
    return {
        "type": "string",
        "format": "docker-image-ref",
        "pattern": cls._pattern.pattern,
        "description": "A Docker/OCI image reference like registry/repo:tag@digest.",
        "examples": [
            "nginx:latest",
            "ghcr.io/owner/repo:v1.0",
            "registry.example.com/my-app@sha256:abc123",
        ],
        "title": "DockerImageRef",
    }

__new__

__new__(value: str) -> DockerImageRef

Create and validate a new DockerImageRef instance.

Source code in src/pydantypes/devops/docker.py
def __new__(cls, value: str) -> DockerImageRef:
    """Create and validate a new DockerImageRef instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "docker_image_ref",
            "Invalid Docker image reference: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.registry = m.group("registry")
    instance.repository = m.group("repository")
    instance.tag = m.group("tag")
    instance.digest = m.group("digest")
    return instance

GitHttpsUrl

Bases: str

A Git HTTPS clone URL like https://github.com/owner/repo.git with parsed properties.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for GitHttpsUrl.

Source code in src/pydantypes/devops/git.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for GitHttpsUrl."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for GitHttpsUrl.

Source code in src/pydantypes/devops/git.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for GitHttpsUrl."""
    return {
        "type": "string",
        "format": "git-https-url",
        "description": "A Git HTTPS clone URL like https://github.com/owner/repo.git",
        "examples": [
            "https://github.com/torvalds/linux.git",
            "https://gitlab.com/group/subgroup/repo.git",
        ],
        "title": "GitHttpsUrl",
    }

__new__

__new__(value: str) -> GitHttpsUrl

Create and validate a new GitHttpsUrl instance.

Source code in src/pydantypes/devops/git.py
def __new__(cls, value: str) -> GitHttpsUrl:
    """Create and validate a new GitHttpsUrl instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "git_https_url",
            "Invalid Git HTTPS URL: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.host = m.group("host")
    path = m.group("path")
    parts = path.rsplit("/", 1)
    if len(parts) == 2:
        instance.owner = parts[0]
        instance.repo = parts[1]
    else:
        instance.owner = ""
        instance.repo = parts[0]
    return instance

GitSshUrl

Bases: str

A Git SSH clone URL like git@github.com:owner/repo.git with parsed properties.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for GitSshUrl.

Source code in src/pydantypes/devops/git.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for GitSshUrl."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for GitSshUrl.

Source code in src/pydantypes/devops/git.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for GitSshUrl."""
    return {
        "type": "string",
        "format": "git-ssh-url",
        "description": "A Git SSH clone URL in SCP-like (git@host:owner/repo.git) or ssh:// format",
        "examples": [
            "git@github.com:torvalds/linux.git",
            "ssh://git@github.com/torvalds/linux.git",
        ],
        "title": "GitSshUrl",
    }

__new__

__new__(value: str) -> GitSshUrl

Create and validate a new GitSshUrl instance.

Source code in src/pydantypes/devops/git.py
def __new__(cls, value: str) -> GitSshUrl:
    """Create and validate a new GitSshUrl instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "git_ssh_url",
            "Invalid Git SSH URL: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    if m.group("scp_host"):
        instance.host = m.group("scp_host")
        path = m.group("scp_path")
    else:
        instance.host = m.group("ssh_host")
        path = m.group("ssh_path")
    parts = path.rsplit("/", 1)
    if len(parts) == 2:
        instance.owner = parts[0]
        instance.repo = parts[1]
    else:
        instance.owner = ""
        instance.repo = parts[0]
    return instance

K8sLabelKey

Bases: str

A valid Kubernetes label key with optional prefix and name.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for K8sLabelKey.

Source code in src/pydantypes/devops/k8s.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for K8sLabelKey."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for K8sLabelKey.

Source code in src/pydantypes/devops/k8s.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for K8sLabelKey."""
    return {
        "type": "string",
        "format": "k8s-label-key",
        "pattern": cls._pattern.pattern,
        "description": "A valid Kubernetes label key with optional prefix and name.",
        "examples": ["app.kubernetes.io/name", "version", "my-label"],
        "title": "K8sLabelKey",
    }

__new__

__new__(value: str) -> K8sLabelKey

Create and validate a new K8sLabelKey instance.

Source code in src/pydantypes/devops/k8s.py
def __new__(cls, value: str) -> K8sLabelKey:
    """Create and validate a new K8sLabelKey instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "k8s_label_key",
            "Invalid Kubernetes label key: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.prefix = m.group("prefix")
    instance.name = m.group("name")
    return instance

TerraformResourceAddress

Bases: str

A Terraform resource address like aws_instance.web.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for TerraformResourceAddress.

Source code in src/pydantypes/devops/terraform.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for TerraformResourceAddress."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for TerraformResourceAddress.

Source code in src/pydantypes/devops/terraform.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for TerraformResourceAddress."""
    return {
        "type": "string",
        "format": "terraform-resource-address",
        "pattern": cls._pattern.pattern,
        "description": "A Terraform resource address like aws_instance.web.",
        "examples": [
            "aws_instance.web",
            "google_compute_instance.default",
        ],
        "title": "TerraformResourceAddress",
    }

__new__

__new__(value: str) -> TerraformResourceAddress

Create and validate a new TerraformResourceAddress instance.

Source code in src/pydantypes/devops/terraform.py
def __new__(cls, value: str) -> TerraformResourceAddress:
    """Create and validate a new TerraformResourceAddress instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "terraform_resource_address",
            "Invalid Terraform resource address: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.resource_type = m.group("resource_type")
    instance.resource_name = m.group("resource_name")
    return instance