kubectl-mcp-server 1.14.0__py3-none-any.whl → 1.16.0__py3-none-any.whl
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.
- kubectl_mcp_server-1.16.0.dist-info/METADATA +1047 -0
- kubectl_mcp_server-1.16.0.dist-info/RECORD +61 -0
- kubectl_mcp_tool/__init__.py +1 -1
- kubectl_mcp_tool/crd_detector.py +247 -0
- kubectl_mcp_tool/k8s_config.py +304 -63
- kubectl_mcp_tool/mcp_server.py +27 -0
- kubectl_mcp_tool/tools/__init__.py +20 -0
- kubectl_mcp_tool/tools/backup.py +881 -0
- kubectl_mcp_tool/tools/capi.py +727 -0
- kubectl_mcp_tool/tools/certs.py +709 -0
- kubectl_mcp_tool/tools/cilium.py +582 -0
- kubectl_mcp_tool/tools/cluster.py +395 -121
- kubectl_mcp_tool/tools/core.py +157 -60
- kubectl_mcp_tool/tools/cost.py +97 -41
- kubectl_mcp_tool/tools/deployments.py +173 -56
- kubectl_mcp_tool/tools/diagnostics.py +40 -13
- kubectl_mcp_tool/tools/gitops.py +552 -0
- kubectl_mcp_tool/tools/helm.py +133 -46
- kubectl_mcp_tool/tools/keda.py +464 -0
- kubectl_mcp_tool/tools/kiali.py +652 -0
- kubectl_mcp_tool/tools/kubevirt.py +803 -0
- kubectl_mcp_tool/tools/networking.py +106 -32
- kubectl_mcp_tool/tools/operations.py +176 -50
- kubectl_mcp_tool/tools/pods.py +162 -50
- kubectl_mcp_tool/tools/policy.py +554 -0
- kubectl_mcp_tool/tools/rollouts.py +790 -0
- kubectl_mcp_tool/tools/security.py +89 -36
- kubectl_mcp_tool/tools/storage.py +35 -16
- tests/test_browser.py +2 -2
- tests/test_ecosystem.py +331 -0
- tests/test_tools.py +73 -10
- kubectl_mcp_server-1.14.0.dist-info/METADATA +0 -780
- kubectl_mcp_server-1.14.0.dist-info/RECORD +0 -49
- {kubectl_mcp_server-1.14.0.dist-info → kubectl_mcp_server-1.16.0.dist-info}/WHEEL +0 -0
- {kubectl_mcp_server-1.14.0.dist-info → kubectl_mcp_server-1.16.0.dist-info}/entry_points.txt +0 -0
- {kubectl_mcp_server-1.14.0.dist-info → kubectl_mcp_server-1.16.0.dist-info}/licenses/LICENSE +0 -0
- {kubectl_mcp_server-1.14.0.dist-info → kubectl_mcp_server-1.16.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
kubectl_mcp_server-1.16.0.dist-info/licenses/LICENSE,sha256=nH9Z0W0WNH2oQ4cPrBAU8ldDcHfeI6NUbkSGiazYWgQ,1070
|
|
2
|
+
kubectl_mcp_tool/__init__.py,sha256=lXt5nN5Weai2sekX8XGqgSgjZjVFf7FBG8xfvlbYruA,580
|
|
3
|
+
kubectl_mcp_tool/__main__.py,sha256=CE6cTD6PA71Ap0i5_gE17Pb9FcedOJmtGRNzZ5-TFSc,1490
|
|
4
|
+
kubectl_mcp_tool/crd_detector.py,sha256=xLZSyg3iIe_MjSMI3mESe2VK8wGJzu40rJ7F72fULBs,7139
|
|
5
|
+
kubectl_mcp_tool/diagnostics.py,sha256=uwolSoHadRkB-J8PAsabbexfj6sTNCIIRRrABBRXoTU,11776
|
|
6
|
+
kubectl_mcp_tool/k8s_config.py,sha256=tjP_VONsoqhd5qn0LPB25aKhiPw2qCYhJ_B52NbRYDo,15746
|
|
7
|
+
kubectl_mcp_tool/mcp_server.py,sha256=rHz8yuA-SlnuuajVytqeEOMryQAHCTL1CWrQw85CbMM,22674
|
|
8
|
+
kubectl_mcp_tool/auth/__init__.py,sha256=ot8ivZZkDtV8Rg0y1UYruwobKCPyxX1svqh35wWxKvY,347
|
|
9
|
+
kubectl_mcp_tool/auth/config.py,sha256=wi3wuJNMyDqMeluDHL0MaJyedIFv5CFVxiUaEVaTvzk,2267
|
|
10
|
+
kubectl_mcp_tool/auth/scopes.py,sha256=KPmuGO0SrTkjzlElWFOV29ie9apTdMklOCkiA-965lI,6147
|
|
11
|
+
kubectl_mcp_tool/auth/verifier.py,sha256=ChZM-UsZJgZc3LjSfw8VfSydkKqKBZ1s8es71LlB_A0,2431
|
|
12
|
+
kubectl_mcp_tool/cli/__init__.py,sha256=NDd1-7_Ira9vx0uNVOUqhkK7S53IOTu0WUBWOKCtap8,1348
|
|
13
|
+
kubectl_mcp_tool/cli/__main__.py,sha256=OxhHqW8YsTd565acTDlZknljPAw6FN9JW7pNtgWIcFE,196
|
|
14
|
+
kubectl_mcp_tool/cli/cli.py,sha256=qy2mQ0uDrQ9qzv5LP_w9sJ2y_yt3Qzx5m2pzh1i-u4o,19694
|
|
15
|
+
kubectl_mcp_tool/cli/errors.py,sha256=nCvopWH9bt8wGRt6RTDoXo7IsKwsdwzRMvJ5OM2a1Eg,9018
|
|
16
|
+
kubectl_mcp_tool/cli/output.py,sha256=N1AUoRDiBe3lA27l96ZSdIA7pa4GqXLOP3PBdyoLHsQ,10060
|
|
17
|
+
kubectl_mcp_tool/prompts/__init__.py,sha256=BacBNfoVxow6aci8Zzcfam3m1oM7yYzM0IRT1L3uCOQ,77
|
|
18
|
+
kubectl_mcp_tool/prompts/prompts.py,sha256=ZfmTCio8NqOYYxF8VVo9f6VWGCS34J8tvmBfhNblr58,22942
|
|
19
|
+
kubectl_mcp_tool/resources/__init__.py,sha256=ERkn0ErlaGi9-dybv4wrAaT8WretvNp6K002h7Agjno,83
|
|
20
|
+
kubectl_mcp_tool/resources/resources.py,sha256=kvK4OM3Ox5cFvWDqJBTXOfBgnRYdoqdvvjsdCg0PJfY,12713
|
|
21
|
+
kubectl_mcp_tool/tools/__init__.py,sha256=DgFcaXxqMf7dgXcYWXl0-zKBJTUSF7Y__Cqsd79hRBA,1761
|
|
22
|
+
kubectl_mcp_tool/tools/backup.py,sha256=ToZABafXvrBQy-Hlc31xzVX5shWaB71JeqD3xq-4kh0,30423
|
|
23
|
+
kubectl_mcp_tool/tools/browser.py,sha256=OvXUHzEuciRQInnwLLC16iObOOdniu09b9RT81y7sdc,25338
|
|
24
|
+
kubectl_mcp_tool/tools/capi.py,sha256=mPCm6wUI3Sr5Mg9RjWSKBR5uwWn02Byyx42Cc1Fo7IE,25738
|
|
25
|
+
kubectl_mcp_tool/tools/certs.py,sha256=7Qdsx3IwCI3_mgcPrypzF6MFL5jZjKkVXsXUohAbfh8,25720
|
|
26
|
+
kubectl_mcp_tool/tools/cilium.py,sha256=ku5E-fQ9vS4MhSnaZA_rli6ebXXLCHBuKhZBrEo221c,19973
|
|
27
|
+
kubectl_mcp_tool/tools/cluster.py,sha256=Xyb18x7d1Eg3l0XZ2JMmCOb0c0IbtVCpk2RH2rKgKDY,20944
|
|
28
|
+
kubectl_mcp_tool/tools/core.py,sha256=67Cx1z4DqV0Qd26yXkF1eBXbUIlBB3Qj2W8rOInvb54,17801
|
|
29
|
+
kubectl_mcp_tool/tools/cost.py,sha256=fcFlIv-bsMdKESw-l-T6ECsUplDukNHaqM76JCYVHvQ,29629
|
|
30
|
+
kubectl_mcp_tool/tools/deployments.py,sha256=e138KV30DQhLCnvXntrofx1XdLH0dC0_mlODbzkluKk,18329
|
|
31
|
+
kubectl_mcp_tool/tools/diagnostics.py,sha256=LGpW-cx2ui40IIq4pZPT2O8nVzKCpOEVnnQ1OGUSVt0,7864
|
|
32
|
+
kubectl_mcp_tool/tools/gitops.py,sha256=YMsSL0vzzz-XtFXRgney3yKwVfIfuYTSOsLbbLUEI5w,20497
|
|
33
|
+
kubectl_mcp_tool/tools/helm.py,sha256=v_d1aH79VCKJmFi-kXG1LwzZRw6OFToyVC7D9tEp99A,61658
|
|
34
|
+
kubectl_mcp_tool/tools/keda.py,sha256=Et7NSRIH2FSIG2iJ0LyLcQTsFqdeVsKTUr1KKT4tmso,16155
|
|
35
|
+
kubectl_mcp_tool/tools/kiali.py,sha256=ThUF3d_PBEpu9aVSg8gVw9WtPGwkwJlmn6R8sj-BgqM,21932
|
|
36
|
+
kubectl_mcp_tool/tools/kubevirt.py,sha256=yN5ilsGEEFTKJ7h5iAONr4CVFqj_wKjHBcdijGx2DWU,26878
|
|
37
|
+
kubectl_mcp_tool/tools/networking.py,sha256=5I-2SHp2kK9OyGJJ9KUU0hetlYoREIfin1J6CJA6HVQ,14309
|
|
38
|
+
kubectl_mcp_tool/tools/operations.py,sha256=c7j1quXwRDoB9pMkmnLZ5Mk4QoCAuEzWVXJl_hmg2tc,24862
|
|
39
|
+
kubectl_mcp_tool/tools/pods.py,sha256=PsjqbudCUEgZdJmBBeHX3qg-mObn9mlVOCpJOU8XBd8,27271
|
|
40
|
+
kubectl_mcp_tool/tools/policy.py,sha256=T4zf6EvOdIOtqLfnn4wE1QR7nzIeYOkG-vIvXNcu4nc,21769
|
|
41
|
+
kubectl_mcp_tool/tools/rollouts.py,sha256=K1VpvnMIE36I0kWB0Bo338UNQhctkIdmtmcdkt3ddhE,26224
|
|
42
|
+
kubectl_mcp_tool/tools/security.py,sha256=d7WLj-JZwr-0opzkRNWyPdMykvBjdsDCBSZHovDIPLo,13971
|
|
43
|
+
kubectl_mcp_tool/tools/storage.py,sha256=ILI3X5GYXASCETqg3A7X33B7PjwD5UsxL-iDG7yTi_8,5676
|
|
44
|
+
kubectl_mcp_tool/tools/ui.py,sha256=HHi0KM2JTvZFpQjo5V6XkJf02hxFoasec7uyNY5wuuo,39702
|
|
45
|
+
kubectl_mcp_tool/utils/__init__.py,sha256=CHBCpaXwt994DlqyRFkkRky2TK8OmmDl0Gyc28369gI,348
|
|
46
|
+
kubectl_mcp_tool/utils/helpers.py,sha256=W--wiVSKKqmjpxxdLT0J6rmhOQcp1OFk9jLrtQUVpGw,2444
|
|
47
|
+
tests/__init__.py,sha256=qZPXYXv3whkkWhi61Ngzj09GHnIFlVSZrajE0XRk55o,290
|
|
48
|
+
tests/conftest.py,sha256=6054YlpuGleV3Wg8BnVj4lnKWhGk-Eqc9JYTXxOmsXs,10782
|
|
49
|
+
tests/test_auth.py,sha256=PoESfWiN92wSGUdVwLL3Z1AP6C1zUsVmgTI7Q8ZdlxM,11074
|
|
50
|
+
tests/test_browser.py,sha256=6rB6Atqq3b2-xWnKzFdCVFHbF2Q3nt2Dy8Rp4ZwIgNk,20621
|
|
51
|
+
tests/test_cli.py,sha256=G-f9uByWooe-yUOH0ahBdoft4uz8TC0R0OzDs1Lom-4,10014
|
|
52
|
+
tests/test_ecosystem.py,sha256=SkxDWAASELIxzaYWu0d-Rw1HaKSSlyMMenwwF2HWvSA,13227
|
|
53
|
+
tests/test_prompts.py,sha256=3TcJUvSNxhTqfySW6DCrW9MwiMDumciLQRjjbucwqlA,17803
|
|
54
|
+
tests/test_resources.py,sha256=Z0Ex8WdRz-B3VZa1s0eAaDDGbhy7dRdqy1uFVOe2Qbo,12689
|
|
55
|
+
tests/test_server.py,sha256=lLvgbqutnivSgQMNrki0O48whBQt0UXjdwT047nf0nw,14415
|
|
56
|
+
tests/test_tools.py,sha256=g3moVSpiFgqC107M4tBAQ6xU600rlYMPhnknyYhnTIc,34792
|
|
57
|
+
kubectl_mcp_server-1.16.0.dist-info/METADATA,sha256=3WRkJkEGNeW15Xu_xJSlbp-NU1RVMYYsBIAVDFHhxJM,38116
|
|
58
|
+
kubectl_mcp_server-1.16.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
59
|
+
kubectl_mcp_server-1.16.0.dist-info/entry_points.txt,sha256=zeOxQGaNC4r58deEmqsLCU5hfMjF0VqFUt9P5wWsKEM,109
|
|
60
|
+
kubectl_mcp_server-1.16.0.dist-info/top_level.txt,sha256=o5IpfOGG-lqU8rVWJeK9aYC0r4f6qEX09QiBhZlYbkQ,23
|
|
61
|
+
kubectl_mcp_server-1.16.0.dist-info/RECORD,,
|
kubectl_mcp_tool/__init__.py
CHANGED
|
@@ -7,7 +7,7 @@ with Kubernetes clusters through natural language commands.
|
|
|
7
7
|
For more information, see: https://github.com/rohitg00/kubectl-mcp-server
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
__version__ = "1.
|
|
10
|
+
__version__ = "1.16.0"
|
|
11
11
|
|
|
12
12
|
from .mcp_server import MCPServer
|
|
13
13
|
from .diagnostics import run_diagnostics, check_kubectl_installation, check_cluster_connection
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"""CRD Auto-Discovery Framework for kubectl-mcp-server.
|
|
2
|
+
|
|
3
|
+
Detects installed CRDs in the cluster and enables/disables toolsets accordingly.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import subprocess
|
|
7
|
+
import json
|
|
8
|
+
from typing import Dict, List, Optional, Set
|
|
9
|
+
from functools import lru_cache
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
from .k8s_config import _get_kubectl_context_args
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
CRD_GROUPS = {
|
|
16
|
+
"flux": [
|
|
17
|
+
"kustomizations.kustomize.toolkit.fluxcd.io",
|
|
18
|
+
"helmreleases.helm.toolkit.fluxcd.io",
|
|
19
|
+
"gitrepositories.source.toolkit.fluxcd.io",
|
|
20
|
+
"helmrepositories.source.toolkit.fluxcd.io",
|
|
21
|
+
],
|
|
22
|
+
"argocd": [
|
|
23
|
+
"applications.argoproj.io",
|
|
24
|
+
"applicationsets.argoproj.io",
|
|
25
|
+
"appprojects.argoproj.io",
|
|
26
|
+
],
|
|
27
|
+
"certmanager": [
|
|
28
|
+
"certificates.cert-manager.io",
|
|
29
|
+
"issuers.cert-manager.io",
|
|
30
|
+
"clusterissuers.cert-manager.io",
|
|
31
|
+
"certificaterequests.cert-manager.io",
|
|
32
|
+
"orders.acme.cert-manager.io",
|
|
33
|
+
"challenges.acme.cert-manager.io",
|
|
34
|
+
],
|
|
35
|
+
"kyverno": [
|
|
36
|
+
"clusterpolicies.kyverno.io",
|
|
37
|
+
"policies.kyverno.io",
|
|
38
|
+
"policyreports.wgpolicyk8s.io",
|
|
39
|
+
"clusterpolicyreports.wgpolicyk8s.io",
|
|
40
|
+
],
|
|
41
|
+
"gatekeeper": [
|
|
42
|
+
"constrainttemplates.templates.gatekeeper.sh",
|
|
43
|
+
"configs.config.gatekeeper.sh",
|
|
44
|
+
],
|
|
45
|
+
"velero": [
|
|
46
|
+
"backups.velero.io",
|
|
47
|
+
"restores.velero.io",
|
|
48
|
+
"schedules.velero.io",
|
|
49
|
+
"backupstoragelocations.velero.io",
|
|
50
|
+
],
|
|
51
|
+
"keda": [
|
|
52
|
+
"scaledobjects.keda.sh",
|
|
53
|
+
"scaledjobs.keda.sh",
|
|
54
|
+
"triggerauthentications.keda.sh",
|
|
55
|
+
],
|
|
56
|
+
"cilium": [
|
|
57
|
+
"ciliumnetworkpolicies.cilium.io",
|
|
58
|
+
"ciliumclusterwidenetworkpolicies.cilium.io",
|
|
59
|
+
"ciliumendpoints.cilium.io",
|
|
60
|
+
],
|
|
61
|
+
"istio": [
|
|
62
|
+
"virtualservices.networking.istio.io",
|
|
63
|
+
"destinationrules.networking.istio.io",
|
|
64
|
+
"gateways.networking.istio.io",
|
|
65
|
+
],
|
|
66
|
+
"argorollouts": [
|
|
67
|
+
"rollouts.argoproj.io",
|
|
68
|
+
"analysistemplates.argoproj.io",
|
|
69
|
+
],
|
|
70
|
+
"kubevirt": [
|
|
71
|
+
"virtualmachines.kubevirt.io",
|
|
72
|
+
"virtualmachineinstances.kubevirt.io",
|
|
73
|
+
],
|
|
74
|
+
"capi": [
|
|
75
|
+
"clusters.cluster.x-k8s.io",
|
|
76
|
+
"machines.cluster.x-k8s.io",
|
|
77
|
+
"machinedeployments.cluster.x-k8s.io",
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
_crd_cache: Dict[str, Dict[str, bool]] = {}
|
|
83
|
+
_cache_timestamp: Dict[str, float] = {}
|
|
84
|
+
CACHE_TTL = 300
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _get_cluster_crds(context: str = "") -> Set[str]:
|
|
88
|
+
"""Get all CRDs installed in the cluster."""
|
|
89
|
+
try:
|
|
90
|
+
cmd = ["kubectl"] + _get_kubectl_context_args(context) + [
|
|
91
|
+
"get", "crds", "-o", "jsonpath={.items[*].metadata.name}"
|
|
92
|
+
]
|
|
93
|
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
|
|
94
|
+
if result.returncode == 0:
|
|
95
|
+
return set(result.stdout.split())
|
|
96
|
+
return set()
|
|
97
|
+
except Exception:
|
|
98
|
+
return set()
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def detect_crds(context: str = "", force_refresh: bool = False) -> Dict[str, bool]:
|
|
102
|
+
"""Detect which CRD groups are installed in the cluster.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
context: Kubernetes context to use
|
|
106
|
+
force_refresh: Force refresh the cache
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Dict mapping CRD group name to installed status
|
|
110
|
+
"""
|
|
111
|
+
cache_key = context or "default"
|
|
112
|
+
|
|
113
|
+
if not force_refresh and cache_key in _crd_cache:
|
|
114
|
+
if time.time() - _cache_timestamp.get(cache_key, 0) < CACHE_TTL:
|
|
115
|
+
return _crd_cache[cache_key]
|
|
116
|
+
|
|
117
|
+
installed_crds = _get_cluster_crds(context)
|
|
118
|
+
|
|
119
|
+
result = {}
|
|
120
|
+
for group_name, crds in CRD_GROUPS.items():
|
|
121
|
+
result[group_name] = any(crd in installed_crds for crd in crds)
|
|
122
|
+
|
|
123
|
+
_crd_cache[cache_key] = result
|
|
124
|
+
_cache_timestamp[cache_key] = time.time()
|
|
125
|
+
|
|
126
|
+
return result
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def crd_exists(crd_name: str, context: str = "") -> bool:
|
|
130
|
+
"""Check if a specific CRD exists in the cluster.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
crd_name: Full CRD name (e.g., "certificates.cert-manager.io")
|
|
134
|
+
context: Kubernetes context to use
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
True if CRD exists, False otherwise
|
|
138
|
+
"""
|
|
139
|
+
try:
|
|
140
|
+
cmd = ["kubectl"] + _get_kubectl_context_args(context) + [
|
|
141
|
+
"get", "crd", crd_name, "-o", "name"
|
|
142
|
+
]
|
|
143
|
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
|
144
|
+
return result.returncode == 0
|
|
145
|
+
except Exception:
|
|
146
|
+
return False
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def get_enabled_toolsets(context: str = "") -> List[str]:
|
|
150
|
+
"""Get list of toolsets that should be enabled based on detected CRDs.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
context: Kubernetes context to use
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
List of enabled toolset names
|
|
157
|
+
"""
|
|
158
|
+
crds = detect_crds(context)
|
|
159
|
+
enabled = []
|
|
160
|
+
|
|
161
|
+
if crds.get("flux") or crds.get("argocd"):
|
|
162
|
+
enabled.append("gitops")
|
|
163
|
+
if crds.get("certmanager"):
|
|
164
|
+
enabled.append("certs")
|
|
165
|
+
if crds.get("kyverno") or crds.get("gatekeeper"):
|
|
166
|
+
enabled.append("policy")
|
|
167
|
+
if crds.get("velero"):
|
|
168
|
+
enabled.append("backup")
|
|
169
|
+
if crds.get("keda"):
|
|
170
|
+
enabled.append("keda")
|
|
171
|
+
if crds.get("cilium"):
|
|
172
|
+
enabled.append("cilium")
|
|
173
|
+
if crds.get("argorollouts"):
|
|
174
|
+
enabled.append("rollouts")
|
|
175
|
+
if crds.get("kubevirt"):
|
|
176
|
+
enabled.append("kubevirt")
|
|
177
|
+
if crds.get("capi"):
|
|
178
|
+
enabled.append("capi")
|
|
179
|
+
if crds.get("istio"):
|
|
180
|
+
enabled.append("istio")
|
|
181
|
+
|
|
182
|
+
return enabled
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def get_crd_status_summary(context: str = "") -> Dict:
|
|
186
|
+
"""Get a summary of CRD detection status.
|
|
187
|
+
|
|
188
|
+
Args:
|
|
189
|
+
context: Kubernetes context to use
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
Summary dict with detected CRDs and enabled toolsets
|
|
193
|
+
"""
|
|
194
|
+
crds = detect_crds(context)
|
|
195
|
+
enabled = get_enabled_toolsets(context)
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
"context": context or "current",
|
|
199
|
+
"crd_groups": crds,
|
|
200
|
+
"enabled_toolsets": enabled,
|
|
201
|
+
"total_groups_detected": sum(1 for v in crds.values() if v),
|
|
202
|
+
"total_toolsets_enabled": len(enabled),
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class FeatureNotInstalledError(Exception):
|
|
207
|
+
"""Raised when required CRDs are not installed."""
|
|
208
|
+
|
|
209
|
+
def __init__(self, toolset: str, required_crds: List[str]):
|
|
210
|
+
self.toolset = toolset
|
|
211
|
+
self.required_crds = required_crds
|
|
212
|
+
super().__init__(
|
|
213
|
+
f"{toolset} toolset requires one of these CRDs: {', '.join(required_crds)}. "
|
|
214
|
+
f"Install the required operator to use this feature."
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def require_crd(crd_name: str, toolset: str, context: str = ""):
|
|
219
|
+
"""Check if a CRD exists and raise an error if not.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
crd_name: CRD name to check
|
|
223
|
+
toolset: Toolset name for error message
|
|
224
|
+
context: Kubernetes context
|
|
225
|
+
|
|
226
|
+
Raises:
|
|
227
|
+
FeatureNotInstalledError: If CRD is not installed
|
|
228
|
+
"""
|
|
229
|
+
if not crd_exists(crd_name, context):
|
|
230
|
+
raise FeatureNotInstalledError(toolset, [crd_name])
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def require_any_crd(crd_names: List[str], toolset: str, context: str = ""):
|
|
234
|
+
"""Check if any of the CRDs exist and raise an error if none are found.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
crd_names: List of CRD names to check
|
|
238
|
+
toolset: Toolset name for error message
|
|
239
|
+
context: Kubernetes context
|
|
240
|
+
|
|
241
|
+
Raises:
|
|
242
|
+
FeatureNotInstalledError: If no CRDs are installed
|
|
243
|
+
"""
|
|
244
|
+
for crd in crd_names:
|
|
245
|
+
if crd_exists(crd, context):
|
|
246
|
+
return
|
|
247
|
+
raise FeatureNotInstalledError(toolset, crd_names)
|