コード例 #1
0
def get_volume(
    volume: str, claim_name: str = None, host_path: str = None, read_only: bool = None
) -> k8s_schemas.V1Volume:
    if claim_name:
        pv_claim = k8s_schemas.V1PersistentVolumeClaimVolumeSource(
            claim_name=claim_name, read_only=read_only
        )
        return k8s_schemas.V1Volume(name=volume, persistent_volume_claim=pv_claim)

    if host_path:
        return k8s_schemas.V1Volume(
            name=volume, host_path=k8s_schemas.V1HostPathVolumeSource(path=host_path)
        )

    empty_dir = k8s_schemas.V1EmptyDirVolumeSource()
    return k8s_schemas.V1Volume(name=volume, empty_dir=empty_dir)
コード例 #2
0
ファイル: volumes.py プロジェクト: opentechfn/polyaxon
def get_volume_from_connection(
    connection: V1ConnectionType, ) -> Optional[k8s_schemas.V1Volume]:
    if not connection:
        return None
    if connection.is_volume_claim:
        pv_claim = k8s_schemas.V1PersistentVolumeClaimVolumeSource(
            claim_name=connection.schema.volume_claim,
            read_only=connection.schema.read_only,
        )
        return k8s_schemas.V1Volume(name=connection.name,
                                    persistent_volume_claim=pv_claim)

    if connection.is_host_path:
        return k8s_schemas.V1Volume(
            name=connection.name,
            host_path=k8s_schemas.V1HostPathVolumeSource(
                path=connection.schema.host_path),
        )