Skip to content

Commit c660095

Browse files
committed
feat: add "runas_host_user" param to get_source()
1 parent d064d42 commit c660095

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

airbyte/_executors/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
22
from __future__ import annotations
33

4+
import os
45
import tempfile
56
from pathlib import Path
67
from typing import TYPE_CHECKING, Literal, cast
@@ -123,6 +124,7 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
123124
local_executable: Path | str | None = None,
124125
docker_image: bool | str | None = None,
125126
use_host_network: bool = False,
127+
runas_host_user: bool = False,
126128
source_manifest: bool | dict | Path | str | None = None,
127129
install_if_missing: bool = True,
128130
install_root: Path | None = None,
@@ -236,6 +238,9 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
236238
if use_host_network is True:
237239
docker_cmd.extend(["--network", "host"])
238240

241+
if runas_host_user is True:
242+
docker_cmd.extend(["--user", f"{os.getuid()}:{os.getgid()}"])
243+
239244
docker_cmd.extend([docker_image])
240245

241246
return DockerExecutor(

airbyte/destinations/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def get_destination( # noqa: PLR0913 # Too many arguments
2828
local_executable: Path | str | None = None,
2929
docker_image: str | bool | None = None,
3030
use_host_network: bool = False,
31+
runas_host_user: bool = False,
3132
install_if_missing: bool = True,
3233
) -> Destination:
3334
"""Get a connector by name and version.
@@ -56,6 +57,9 @@ def get_destination( # noqa: PLR0913 # Too many arguments
5657
the host network. This is useful for connectors that need to access resources on
5758
the host machine, such as a local database. This parameter is ignored when
5859
`docker_image` is not set.
60+
runas_host_user: If set, along with docker_image, the connector will be executed using the
61+
host's user UID/GID. This is useful to handle container privileges (such as files
62+
permissions). This parameter is ignored when `docker_image` is not set.
5963
install_if_missing: Whether to install the connector if it is not available locally. This
6064
parameter is ignored when local_executable is set.
6165
"""
@@ -70,6 +74,7 @@ def get_destination( # noqa: PLR0913 # Too many arguments
7074
local_executable=local_executable,
7175
docker_image=docker_image,
7276
use_host_network=use_host_network,
77+
runas_host_user=runas_host_user,
7378
install_if_missing=install_if_missing,
7479
),
7580
)

airbyte/sources/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def get_source( # noqa: PLR0913 # Too many arguments
5555
local_executable: Path | str | None = None,
5656
docker_image: bool | str | None = None,
5757
use_host_network: bool = False,
58+
runas_host_user: bool = False,
5859
source_manifest: bool | dict | Path | str | None = None,
5960
install_if_missing: bool = True,
6061
install_root: Path | None = None,
@@ -95,6 +96,9 @@ def get_source( # noqa: PLR0913 # Too many arguments
9596
the host network. This is useful for connectors that need to access resources on
9697
the host machine, such as a local database. This parameter is ignored when
9798
`docker_image` is not set.
99+
runas_host_user: If set, along with docker_image, the connector will be executed using the
100+
host's user UID/GID. This is useful to handle container privileges (such as files
101+
permissions). This parameter is ignored when `docker_image` is not set.
98102
source_manifest: If set, the connector will be executed based on a declarative YAML
99103
source definition. This input can be `True` to attempt to auto-download a YAML spec,
100104
`dict` to accept a Python dictionary as the manifest, `Path` to pull a manifest from
@@ -116,6 +120,7 @@ def get_source( # noqa: PLR0913 # Too many arguments
116120
local_executable=local_executable,
117121
docker_image=docker_image,
118122
use_host_network=use_host_network,
123+
runas_host_user=runas_host_user,
119124
source_manifest=source_manifest,
120125
install_if_missing=install_if_missing,
121126
install_root=install_root,

0 commit comments

Comments
 (0)