utils_devops 0.1.148__tar.gz → 0.1.149__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {utils_devops-0.1.148 → utils_devops-0.1.149}/PKG-INFO +1 -1
- {utils_devops-0.1.148 → utils_devops-0.1.149}/pyproject.toml +1 -1
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/envs.py +3 -3
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/ssh_ops.py +33 -2
- {utils_devops-0.1.148 → utils_devops-0.1.149}/README.md +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/__init__.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/__init__.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/datetimes.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/files.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/logs.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/script_helpers.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/strings.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/core/systems.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/__init__.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/aws_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/docker_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/git_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/interaction_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/metrics_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/network_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/nginx_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/notification_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/performance_ops.py +0 -0
- {utils_devops-0.1.148 → utils_devops-0.1.149}/src/utils_devops/extras/vault_ops.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utils_devops
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.149
|
|
4
4
|
Summary: Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: devops,automation,nginx,cli,jinja2,yaml,config,diff,templating,logging,docker,compose,file-ops
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "utils_devops"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.149" # Bumped for new string features + diffing
|
|
4
4
|
description = "Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools"
|
|
5
5
|
authors = ["Hamed Sheikhan <sh.sheikhan.m@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Environment operations for utils_devops (
|
|
2
|
+
Environment operations for utils_devops (envs module).
|
|
3
3
|
|
|
4
4
|
Provides utilities to manage .env files and system environment variables,
|
|
5
5
|
run commands with specific env settings, and safely update env files with
|
|
@@ -66,13 +66,13 @@ class EnvOpsError(Exception):
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
def help() -> None:
|
|
69
|
-
"""Print a short index of the
|
|
69
|
+
"""Print a short index of the envs API for interactive use."""
|
|
70
70
|
print(
|
|
71
71
|
"""
|
|
72
72
|
DevOps Utils — Environment Operations Module
|
|
73
73
|
Key functions:
|
|
74
74
|
EnvOpsError: Custom exception for environment operations failures.
|
|
75
|
-
help() -> None: Print a short index of the
|
|
75
|
+
help() -> None: Print a short index of the envs API for interactive use.
|
|
76
76
|
|
|
77
77
|
Loading Environment Files:
|
|
78
78
|
load_env_file(file_path: Union[str, Path], as_dict: bool = True) -> Union[Dict[str, str], List[str]]: Load a .env file and return a dict of key->value or list of lines.
|
|
@@ -528,6 +528,37 @@ def _resolve_ssh_key(key_input: Optional[Union[str, Path]]) -> Tuple[Optional[Pa
|
|
|
528
528
|
# **IMPORTANT**: Preserve any newlines in the content
|
|
529
529
|
return None, key_input_str
|
|
530
530
|
|
|
531
|
+
def _inject_environment_variables(
|
|
532
|
+
environment: Optional[Dict[str, str]] = None,
|
|
533
|
+
base_command: str = ""
|
|
534
|
+
) -> str:
|
|
535
|
+
"""
|
|
536
|
+
Creates a command string that safely injects environment variables.
|
|
537
|
+
Works for both Windows and Linux remote targets.
|
|
538
|
+
"""
|
|
539
|
+
if not environment:
|
|
540
|
+
return base_command
|
|
541
|
+
|
|
542
|
+
# Create a temporary script to set environment and run the command
|
|
543
|
+
env_lines = []
|
|
544
|
+
if systems.is_linux :
|
|
545
|
+
# Linux syntax: export VAR='value'
|
|
546
|
+
for key, value in environment.items():
|
|
547
|
+
escaped_value = value.replace("'", "'\"'\"'")
|
|
548
|
+
env_lines.append(f"export {key}='{escaped_value}'")
|
|
549
|
+
env_setup = " && ".join(env_lines)
|
|
550
|
+
prefix = f"{env_setup} && "
|
|
551
|
+
elif systems.is_windows :
|
|
552
|
+
# Windows syntax (PowerShell)
|
|
553
|
+
for key, value in environment.items():
|
|
554
|
+
# Escape for PowerShell
|
|
555
|
+
escaped_value = value.replace("'", "''").replace("`", "``")
|
|
556
|
+
env_lines.append(f"$env:{key}='{escaped_value}'")
|
|
557
|
+
env_setup = "; ".join(env_lines)
|
|
558
|
+
prefix = f"{env_setup}; "
|
|
559
|
+
|
|
560
|
+
return f"{prefix}{base_command}"
|
|
561
|
+
|
|
531
562
|
def ssh_execute_command(
|
|
532
563
|
host: str,
|
|
533
564
|
command: Union[str, List[str]],
|
|
@@ -569,10 +600,10 @@ def ssh_execute_command(
|
|
|
569
600
|
else:
|
|
570
601
|
command_str = command
|
|
571
602
|
|
|
603
|
+
|
|
572
604
|
# Add environment variables
|
|
573
605
|
if environment:
|
|
574
|
-
|
|
575
|
-
command_str = f"{env_vars}; {command_str}"
|
|
606
|
+
command_str = _inject_environment_variables(environment, command_str)
|
|
576
607
|
|
|
577
608
|
# Add sudo
|
|
578
609
|
if sudo:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|