utils_devops 0.1.174__tar.gz → 0.1.191__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.
Files changed (25) hide show
  1. {utils_devops-0.1.174 → utils_devops-0.1.191}/PKG-INFO +13 -2
  2. utils_devops-0.1.191/README.txt +12 -0
  3. {utils_devops-0.1.174 → utils_devops-0.1.191}/pyproject.toml +2 -2
  4. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/docker_ops.py +28 -14
  5. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/nginx_ops.py +6 -0
  6. utils_devops-0.1.174/README.md +0 -0
  7. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/__init__.py +0 -0
  8. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/__init__.py +0 -0
  9. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/datetimes.py +0 -0
  10. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/envs.py +0 -0
  11. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/files.py +0 -0
  12. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/logs.py +0 -0
  13. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/script_helpers.py +0 -0
  14. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/strings.py +0 -0
  15. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/core/systems.py +0 -0
  16. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/__init__.py +0 -0
  17. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/aws_ops.py +0 -0
  18. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/git_ops.py +0 -0
  19. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/interaction_ops.py +0 -0
  20. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/metrics_ops.py +0 -0
  21. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/network_ops.py +0 -0
  22. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/notification_ops.py +0 -0
  23. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/performance_ops.py +0 -0
  24. {utils_devops-0.1.174 → utils_devops-0.1.191}/src/utils_devops/extras/ssh_ops.py +0 -0
  25. {utils_devops-0.1.174 → utils_devops-0.1.191}/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.174
3
+ Version: 0.1.191
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
@@ -40,6 +40,17 @@ Requires-Dist: slack-sdk (>=3.37.0,<4.0.0)
40
40
  Requires-Dist: sshtunnel (>=0.4.0,<0.5.0)
41
41
  Requires-Dist: tenacity (>=9.0,<10.0)
42
42
  Requires-Dist: typer (>=0.12.5,<0.13.0)
43
- Description-Content-Type: text/markdown
43
+ Description-Content-Type: text/plain
44
44
 
45
+ utils_devops
46
+ ============
45
47
 
48
+ A utilities package for DevOps tasks.
49
+
50
+ Installation:
51
+ pip install utils_devops
52
+
53
+ Usage:
54
+ import utils_devops
55
+
56
+ License: MIT
@@ -0,0 +1,12 @@
1
+ utils_devops
2
+ ============
3
+
4
+ A utilities package for DevOps tasks.
5
+
6
+ Installation:
7
+ pip install utils_devops
8
+
9
+ Usage:
10
+ import utils_devops
11
+
12
+ License: MIT
@@ -1,10 +1,10 @@
1
1
  [tool.poetry]
2
2
  name = "utils_devops"
3
- version = "0.1.174" # Bumped for new string features + diffing
3
+ version = "0.1.191" # 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"
7
- readme = "README.md"
7
+ readme = "README.txt"
8
8
  keywords = [
9
9
  "devops",
10
10
  "automation",
@@ -123,7 +123,7 @@ def _detect_compose_command() -> str:
123
123
  raise DockerOpsError("Neither 'docker compose' nor 'docker-compose' is available. Please install Docker Compose.")
124
124
 
125
125
  def run_docker_command(cmd: List[str], capture: bool = True, timeout: Optional[int] = None,
126
- input_text: Optional[str] = None,logger: Optional[logger] = None) -> ExecResult:
126
+ input_text: Optional[str] = None,stream: Optional[bool] = True,logger: Optional[logger] = None) -> ExecResult:
127
127
  """Run docker command and return result with detailed logging"""
128
128
  logger = logger or DEFAULT_LOGGER
129
129
  try:
@@ -131,9 +131,9 @@ def run_docker_command(cmd: List[str], capture: bool = True, timeout: Optional[i
131
131
 
132
132
  # Remove timeout parameter since systems.run doesn't support it
133
133
  if input_text:
134
- result = systems.run(cmd, capture=capture, input_text=input_text,logger=logger,stream=True)
134
+ result = systems.run(cmd, capture=capture, input_text=input_text,logger=logger,stream=stream)
135
135
  else:
136
- result = systems.run(cmd, capture=capture,logger=logger,stream=True)
136
+ result = systems.run(cmd, capture=capture,logger=logger,stream=stream)
137
137
 
138
138
  # Log the full output for debugging
139
139
  if result.returncode != 0:
@@ -1086,7 +1086,8 @@ def _update_env_version(
1086
1086
  Update version in .env file based on git information.
1087
1087
 
1088
1088
  Sources:
1089
- - 'git': Use git tag, fallback to branch name + commit hash
1089
+ - 'git': Use branch name + commit hash
1090
+ - 'git_Tag': Use git tag, fallback to branch name + commit hash
1090
1091
  - 'branch': Use branch name only
1091
1092
  - 'commit': Use commit hash only
1092
1093
  """
@@ -1114,6 +1115,8 @@ def _update_env_version(
1114
1115
  # Get new version based on source
1115
1116
  if source == 'git':
1116
1117
  new_version = _get_git_based_version()
1118
+ elif source == 'git_tag':
1119
+ new_version = _get_git_based_version(use_tag = True)
1117
1120
  elif source == 'branch':
1118
1121
  new_version = _get_current_branch()
1119
1122
  elif source == 'commit':
@@ -1144,12 +1147,13 @@ def _update_env_version(
1144
1147
  logger.error(f"Failed to update version: {e}")
1145
1148
  return None
1146
1149
 
1147
- def _get_git_based_version() -> Optional[str]:
1150
+ def _get_git_based_version(use_tag : Optional[bool] = False) -> Optional[str]:
1148
1151
  """Get version from git tag, branch, or commit."""
1149
1152
  # Try to get git tag first (from CI/CD or local)
1150
- git_tag = _get_git_tag()
1151
- if git_tag:
1152
- return git_tag
1153
+ if use_tag :
1154
+ git_tag = _get_git_tag()
1155
+ if git_tag:
1156
+ return git_tag
1153
1157
 
1154
1158
  # If no tag, try branch name + commit hash
1155
1159
  branch = _get_current_branch()
@@ -1170,7 +1174,7 @@ def _get_git_tag() -> Optional[str]:
1170
1174
  """Get current git tag from environment or git command."""
1171
1175
  # First check CI/CD environment variables
1172
1176
  ci_vars = [
1173
- 'CI_COMMIT_TAG','GIT_TAG', 'TRAVIS_TAG', 'CIRCLE_TAG',
1177
+ 'GIT_TAG', 'CI_COMMIT_TAG', 'TRAVIS_TAG', 'CIRCLE_TAG',
1174
1178
  'BUILD_SOURCEBRANCH', 'DRONE_TAG'
1175
1179
  ]
1176
1180
 
@@ -1180,6 +1184,8 @@ def _get_git_tag() -> Optional[str]:
1180
1184
  # Clean the tag (remove refs/tags/ prefix if present)
1181
1185
  if tag.startswith('refs/tags/'):
1182
1186
  tag = tag[10:]
1187
+
1188
+ logger.info(f"Vesion Found in system env : {tag} ")
1183
1189
  return tag
1184
1190
 
1185
1191
  # Try git command as fallback
@@ -2946,7 +2952,8 @@ def build_compose(
2946
2952
  # Additional options
2947
2953
  project_name: Optional[str] = None,
2948
2954
  dry_run: bool = False,
2949
- logger: Optional[logger] = None
2955
+ logger: Optional[logger] = None,
2956
+ stream: Optional[bool] = True,
2950
2957
 
2951
2958
  ) -> Dict[str, Any]:
2952
2959
  """
@@ -4005,11 +4012,12 @@ def get_compose_status(compose_file: str, env_file: Optional[str] = None) -> Dic
4005
4012
 
4006
4013
  def cleanup_old_images_by_compose(keep_count: int = 3, dry_run: bool = False, compose_file: Optional[str] = None, env_file: Optional[str] = None) -> List[str]:
4007
4014
  """Clean up old Docker images, optionally limited to those in a compose file from compose"""
4015
+ logger = DEFAULT_LOGGER
4008
4016
  removed = []
4009
4017
 
4010
4018
  try:
4011
4019
  # Get all images
4012
- result = run_docker_command(["docker", "images", "--format", "{{.ID}}|{{.Repository}}|{{.Tag}}|{{.CreatedAt}}"])
4020
+ result = run_docker_command(["docker", "images", "--format", "{{.ID}}|{{.Repository}}|{{.Tag}}|{{.CreatedAt}}"],stream=False)
4013
4021
 
4014
4022
  images = []
4015
4023
  for line in result.stdout.strip().splitlines():
@@ -4041,7 +4049,10 @@ def cleanup_old_images_by_compose(keep_count: int = 3, dry_run: bool = False, co
4041
4049
 
4042
4050
  compose_repos = set()
4043
4051
  for service in services:
4044
- image = get_service_image(compose_file, service, env_file)
4052
+ #image = get_service_image(compose_file, service, env_file)
4053
+ service_config = compose_data.get('services', {}).get(service, {})
4054
+ image = service_config.get('image')
4055
+ logger.info(f"IMAGES in COMPOSE : {image} " )
4045
4056
  if image:
4046
4057
  repo_tag = image.split(':')
4047
4058
  repo = repo_tag[0]
@@ -4067,7 +4078,10 @@ def cleanup_old_images_by_compose(keep_count: int = 3, dry_run: bool = False, co
4067
4078
  if dry_run:
4068
4079
  logger.info(f"Would remove: {old_img['repository']}:{old_img['tag']}")
4069
4080
  else:
4070
- remove_result = run_docker_command(["docker", "rmi", old_img['id']])
4081
+ logger.info(f"CLEAN UP : Would remove: {old_img['repository']}:{old_img['tag']}")
4082
+ #remove_result = run_docker_command(["docker", "rmi", old_img['id'],"-f"])
4083
+ image_to_remove_with_tag = (f"{old_img['repository']}:{old_img['tag']}")
4084
+ remove_result = run_docker_command(["docker", "rmi", image_to_remove_with_tag ,"-f"])
4071
4085
  if remove_result.rc == 0:
4072
4086
  removed.append(f"{old_img['repository']}:{old_img['tag']}")
4073
4087
 
@@ -5351,4 +5365,4 @@ Example:
5351
5365
 
5352
5366
  }
5353
5367
  """
5354
- print(help.__doc__)
5368
+ print(help.__doc__)
@@ -496,6 +496,12 @@ class NginxManager:
496
496
  placement="server_443_out",
497
497
  context_adjuster=lambda ctx, mgr, site, val: ctx | {"SITE": site.name}
498
498
  ),
499
+ "inner-ssl": Flag(
500
+ "inner-ssl",
501
+ template="inner-ssl.conf",
502
+ placement="server_443_out",
503
+ context_adjuster=lambda ctx, mgr, site, val: ctx | {"SITE": site.name}
504
+ ),
499
505
  "dns": Flag(
500
506
  "dns",
501
507
  template="dns.conf",
File without changes