ccproxy.docker.models¶
ccproxy.docker.models
¶
Docker-specific models for cross-domain operations.
DockerUserContext
¶
Bases: BaseModel
Docker user context for volume permission handling.
Represents user information needed for Docker --user flag to solve volume permission issues when mounting host directories.
validate_positive_ids
classmethod
¶
Validate that UID/GID are positive integers.
validate_username
classmethod
¶
Validate username is not empty.
detect_current_user
classmethod
¶
Detect current user context from system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
home_path
|
DockerPath | None
|
Optional home directory DockerPath override |
None
|
workspace_path
|
DockerPath | None
|
Optional workspace directory DockerPath override |
None
|
Returns:
Name | Type | Description |
---|---|---|
DockerUserContext |
DockerUserContext
|
Current user's context |
Raises:
Type | Description |
---|---|
RuntimeError
|
If user detection fails or platform unsupported |
Source code in ccproxy/docker/models.py
create_manual
classmethod
¶
Create manual user context with custom values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
int
|
User ID for Docker --user flag |
required |
gid
|
int
|
Group ID for Docker --user flag |
required |
username
|
str
|
Username for reference |
required |
home_path
|
DockerPath | None
|
Optional home directory DockerPath |
None
|
workspace_path
|
DockerPath | None
|
Optional workspace directory DockerPath |
None
|
enable_user_mapping
|
bool
|
Whether to enable --user flag in Docker commands |
True
|
Returns:
Name | Type | Description |
---|---|---|
DockerUserContext |
DockerUserContext
|
Manual user context |
Raises:
Type | Description |
---|---|
ValueError
|
If validation fails for any parameter |
Source code in ccproxy/docker/models.py
get_docker_user_flag
¶
Get Docker --user flag value.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Docker user flag in format "uid:gid" |
is_supported_platform
¶
Check if current platform supports user mapping.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if platform supports user mapping |
should_use_user_mapping
¶
Check if user mapping should be used.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if user mapping is enabled and platform is supported |
get_environment_variables
¶
Get environment variables for home and workspace directory configuration.
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str, str]: Environment variables to set in container |
Source code in ccproxy/docker/models.py
get_volumes
¶
Get Docker volume mappings for home and workspace directories.
Returns:
Type | Description |
---|---|
list[tuple[str, str]]
|
list[tuple[str, str]]: List of (host_path, container_path) tuples |
Source code in ccproxy/docker/models.py
get_home_volumes
¶
Get Docker volume mappings for home directory only (for backwards compatibility).
Returns:
Type | Description |
---|---|
list[tuple[str, str]]
|
list[tuple[str, str]]: List of (host_path, container_path) tuples |
Source code in ccproxy/docker/models.py
describe_context
¶
Get human-readable description of user context.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Description of user context for debugging |