kubernetes-watch 0.1.8__tar.gz → 0.1.9__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.
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/PKG-INFO +1 -1
- kubernetes_watch-0.1.9/kube_watch/modules/providers/git.py +121 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/pyproject.toml +1 -1
- kubernetes_watch-0.1.8/kube_watch/modules/providers/git.py +0 -33
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/LICENSE +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/README.md +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/enums/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/enums/kube.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/enums/logic.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/enums/providers.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/enums/workflow.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/models/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/models/common.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/models/workflow.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/clusters/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/clusters/kube.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/database/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/database/model.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/database/postgre.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/actions.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/checks.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/load.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/merge.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/scheduler.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/logic/trasnform.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/mock/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/mock/mock_generator.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/providers/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/providers/aws.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/providers/github.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/modules/providers/vault.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/standalone/metarecogen/ckan_to_gn.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/watch/__init__.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/watch/helpers.py +0 -0
- {kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/watch/workflow.py +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from git import Repo
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import tempfile
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from prefect import get_run_logger
|
|
9
|
+
|
|
10
|
+
logger = get_run_logger()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def clone_ssh_repo(
|
|
14
|
+
git_url: str,
|
|
15
|
+
clone_base_path: str,
|
|
16
|
+
repo_dir_name: str = "manifest-repo",
|
|
17
|
+
depth: int = 1,
|
|
18
|
+
ssh_key_env: str = "GIT_SSH_PRIVATE_KEY",
|
|
19
|
+
known_hosts_env: str = "GIT_SSH_KNOWN_HOSTS",
|
|
20
|
+
) -> Path:
|
|
21
|
+
"""
|
|
22
|
+
Clone or update a Git repo using an SSH private key & known_hosts provided via env vars.
|
|
23
|
+
|
|
24
|
+
Env vars:
|
|
25
|
+
- GIT_SSH_PRIVATE_KEY: the full private key (RSA/ED25519) including BEGIN/END lines
|
|
26
|
+
- GIT_SSH_KNOWN_HOSTS: one or more known_hosts lines (from `ssh-keyscan github.com`)
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
git_url: SSH URL like 'git@github.com:your-org/your-repo.git'
|
|
30
|
+
clone_base_path: directory where repo_dir_name will be created
|
|
31
|
+
repo_dir_name: folder name for the clone
|
|
32
|
+
depth: shallow clone depth (1 == latest)
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Path to the cloned/updated repository.
|
|
36
|
+
"""
|
|
37
|
+
if not git_url.startswith("git@"):
|
|
38
|
+
raise ValueError("git_url must be an SSH URL like 'git@github.com:org/repo.git'")
|
|
39
|
+
|
|
40
|
+
priv_key = os.environ.get(ssh_key_env)
|
|
41
|
+
kh_data = os.environ.get(known_hosts_env)
|
|
42
|
+
if not priv_key:
|
|
43
|
+
raise ValueError(f"Missing env var {ssh_key_env}")
|
|
44
|
+
if not kh_data:
|
|
45
|
+
raise ValueError(f"Missing env var {known_hosts_env}")
|
|
46
|
+
|
|
47
|
+
base = Path(clone_base_path).expanduser().resolve()
|
|
48
|
+
base.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
repo_path = base / repo_dir_name
|
|
50
|
+
|
|
51
|
+
# Secure temp dir for SSH material
|
|
52
|
+
tmpdir = Path(tempfile.mkdtemp(prefix="git_ssh_"))
|
|
53
|
+
key_path = tmpdir / "id_rsa"
|
|
54
|
+
kh_path = tmpdir / "known_hosts"
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
key_path.write_text(priv_key, encoding="utf-8")
|
|
58
|
+
kh_path.write_text(kh_data, encoding="utf-8")
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
os.chmod(key_path, 0o600)
|
|
62
|
+
except PermissionError:
|
|
63
|
+
pass # Windows quirk
|
|
64
|
+
|
|
65
|
+
ssh_cmd = (
|
|
66
|
+
f"ssh -i {key_path} -o IdentitiesOnly=yes "
|
|
67
|
+
f"-o UserKnownHostsFile={kh_path} "
|
|
68
|
+
f"-o StrictHostKeyChecking=yes -o StrictModes=no"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
env = os.environ.copy()
|
|
72
|
+
env["GIT_SSH_COMMAND"] = ssh_cmd
|
|
73
|
+
|
|
74
|
+
if not repo_path.exists():
|
|
75
|
+
cmd = ["git", "clone"]
|
|
76
|
+
if depth and depth > 0:
|
|
77
|
+
cmd += ["--depth", str(depth)]
|
|
78
|
+
cmd += [git_url, str(repo_path)]
|
|
79
|
+
subprocess.check_call(cmd, env=env)
|
|
80
|
+
else:
|
|
81
|
+
if not (repo_path / ".git").exists():
|
|
82
|
+
raise RuntimeError(f"Path exists but is not a git repo: {repo_path}")
|
|
83
|
+
subprocess.check_call(["git", "remote", "set-url", "origin", git_url], cwd=repo_path, env=env)
|
|
84
|
+
subprocess.check_call(["git", "fetch", "--all", "--prune"], cwd=repo_path, env=env)
|
|
85
|
+
subprocess.check_call(["git", "pull", "--ff-only", "origin"], cwd=repo_path, env=env)
|
|
86
|
+
|
|
87
|
+
return repo_path
|
|
88
|
+
|
|
89
|
+
finally:
|
|
90
|
+
try:
|
|
91
|
+
shutil.rmtree(tmpdir)
|
|
92
|
+
except Exception:
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def clone_pat_repo(git_pat, git_url, clone_base_path):
|
|
97
|
+
# Retrieve environment variables
|
|
98
|
+
access_token = git_pat # os.environ.get('GIT_PAT')
|
|
99
|
+
repo_url = git_url # os.environ.get('GIT_URL')
|
|
100
|
+
|
|
101
|
+
if not access_token or not repo_url:
|
|
102
|
+
raise ValueError("Environment variables GIT_PAT or GIT_URL are not set")
|
|
103
|
+
|
|
104
|
+
# Correctly format the URL with the PAT
|
|
105
|
+
if 'https://' in repo_url:
|
|
106
|
+
# Splitting the URL and inserting the PAT
|
|
107
|
+
parts = repo_url.split('https://', 1)
|
|
108
|
+
repo_url = f'https://{access_token}@{parts[1]}'
|
|
109
|
+
else:
|
|
110
|
+
raise ValueError("URL must begin with https:// for PAT authentication")
|
|
111
|
+
|
|
112
|
+
# Directory where the repo will be cloned
|
|
113
|
+
repo_path = os.path.join(clone_base_path, 'manifest-repo')
|
|
114
|
+
|
|
115
|
+
# Clone the repository
|
|
116
|
+
if not os.path.exists(repo_path):
|
|
117
|
+
logger.info(f"Cloning repository into {repo_path}")
|
|
118
|
+
repo = Repo.clone_from(repo_url, repo_path)
|
|
119
|
+
logger.info("Repository cloned successfully.")
|
|
120
|
+
else:
|
|
121
|
+
logger.info(f"Repository already exists at {repo_path}")
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from git import Repo
|
|
3
|
-
|
|
4
|
-
from prefect import get_run_logger
|
|
5
|
-
|
|
6
|
-
logger = get_run_logger()
|
|
7
|
-
|
|
8
|
-
def clone_repo(git_pat, git_url, clone_base_path):
|
|
9
|
-
# Retrieve environment variables
|
|
10
|
-
access_token = git_pat # os.environ.get('GIT_PAT')
|
|
11
|
-
repo_url = git_url # os.environ.get('GIT_URL')
|
|
12
|
-
|
|
13
|
-
if not access_token or not repo_url:
|
|
14
|
-
raise ValueError("Environment variables GIT_PAT or GIT_URL are not set")
|
|
15
|
-
|
|
16
|
-
# Correctly format the URL with the PAT
|
|
17
|
-
if 'https://' in repo_url:
|
|
18
|
-
# Splitting the URL and inserting the PAT
|
|
19
|
-
parts = repo_url.split('https://', 1)
|
|
20
|
-
repo_url = f'https://{access_token}@{parts[1]}'
|
|
21
|
-
else:
|
|
22
|
-
raise ValueError("URL must begin with https:// for PAT authentication")
|
|
23
|
-
|
|
24
|
-
# Directory where the repo will be cloned
|
|
25
|
-
repo_path = os.path.join(clone_base_path, 'manifest-repo')
|
|
26
|
-
|
|
27
|
-
# Clone the repository
|
|
28
|
-
if not os.path.exists(repo_path):
|
|
29
|
-
logger.info(f"Cloning repository into {repo_path}")
|
|
30
|
-
repo = Repo.clone_from(repo_url, repo_path)
|
|
31
|
-
logger.info("Repository cloned successfully.")
|
|
32
|
-
else:
|
|
33
|
-
logger.info(f"Repository already exists at {repo_path}")
|
|
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
|
|
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
|
{kubernetes_watch-0.1.8 → kubernetes_watch-0.1.9}/kube_watch/standalone/metarecogen/ckan_to_gn.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|