kubernator 1.0.19__py3-none-any.whl → 1.0.20__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.
Potentially problematic release.
This version of kubernator might be problematic. Click here for more details.
- kubernator/__init__.py +1 -1
- kubernator/api.py +24 -7
- kubernator/plugins/helm.py +26 -9
- kubernator/plugins/k8s_api.py +9 -14
- kubernator/plugins/template.py +2 -2
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/METADATA +4 -4
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/RECORD +12 -12
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/WHEEL +1 -1
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/entry_points.txt +0 -0
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/namespace_packages.txt +0 -0
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/top_level.txt +0 -0
- {kubernator-1.0.19.dist-info → kubernator-1.0.20.dist-info}/zip-safe +0 -0
kubernator/__init__.py
CHANGED
kubernator/api.py
CHANGED
|
@@ -39,6 +39,7 @@ from typing import Optional, Union, MutableSequence
|
|
|
39
39
|
import requests
|
|
40
40
|
import yaml
|
|
41
41
|
from diff_match_patch import diff_match_patch
|
|
42
|
+
from gevent import sleep
|
|
42
43
|
from jinja2 import (Environment,
|
|
43
44
|
ChainableUndefined,
|
|
44
45
|
make_logging_undefined,
|
|
@@ -108,13 +109,29 @@ def _load_file(logger, path: Path, file_type: FileType, source=None) -> Iterable
|
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
def _download_remote_file(url, file_name, cache: dict):
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
retry_delay = 0
|
|
113
|
+
while True:
|
|
114
|
+
if retry_delay:
|
|
115
|
+
sleep(retry_delay)
|
|
116
|
+
|
|
117
|
+
with requests.get(url, headers=cache, stream=True) as r:
|
|
118
|
+
if r.status_code == 429:
|
|
119
|
+
if not retry_delay:
|
|
120
|
+
retry_delay = 0.2
|
|
121
|
+
else:
|
|
122
|
+
retry_delay *= 2.0
|
|
123
|
+
if retry_delay > 2.5:
|
|
124
|
+
retry_delay = 2.5
|
|
125
|
+
continue
|
|
126
|
+
|
|
127
|
+
r.raise_for_status()
|
|
128
|
+
if r.status_code != 304:
|
|
129
|
+
with open(file_name, "wb") as out:
|
|
130
|
+
for chunk in r.iter_content(chunk_size=65535):
|
|
131
|
+
out.write(chunk)
|
|
132
|
+
return dict(r.headers)
|
|
133
|
+
else:
|
|
134
|
+
return None
|
|
118
135
|
|
|
119
136
|
|
|
120
137
|
def get_app_cache_dir():
|
kubernator/plugins/helm.py
CHANGED
|
@@ -27,7 +27,7 @@ from shutil import which, copy
|
|
|
27
27
|
from typing import Sequence
|
|
28
28
|
|
|
29
29
|
import yaml
|
|
30
|
-
from jsonschema import Draft7Validator
|
|
30
|
+
from jsonschema import Draft7Validator
|
|
31
31
|
|
|
32
32
|
from kubernator.api import (KubernatorPlugin, Globs, StripNL,
|
|
33
33
|
scan_dir,
|
|
@@ -85,12 +85,12 @@ HELM_SCHEMA = {
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"type": "object",
|
|
88
|
-
"required": ["
|
|
88
|
+
"required": ["chart", "name", "namespace"]
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
Draft7Validator.check_schema(HELM_SCHEMA)
|
|
92
92
|
HELM_VALIDATOR_CLS = validator_with_defaults(Draft7Validator)
|
|
93
|
-
HELM_VALIDATOR = HELM_VALIDATOR_CLS(HELM_SCHEMA, format_checker=
|
|
93
|
+
HELM_VALIDATOR = HELM_VALIDATOR_CLS(HELM_SCHEMA, format_checker=Draft7Validator.FORMAT_CHECKER)
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
class HelmPlugin(KubernatorPlugin):
|
|
@@ -130,7 +130,7 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
130
130
|
helm_tar = tarfile.open(helm_file_dl)
|
|
131
131
|
helm_tar.extractall(self.helm_dir.name)
|
|
132
132
|
|
|
133
|
-
copy(Path(self.helm_dir.name)/f"{get_golang_os()}-{get_golang_machine()}"/"helm", helm_file)
|
|
133
|
+
copy(Path(self.helm_dir.name) / f"{get_golang_os()}-{get_golang_machine()}" / "helm", helm_file)
|
|
134
134
|
|
|
135
135
|
os.chmod(helm_file, 0o500)
|
|
136
136
|
prepend_os_path(self.helm_dir.name)
|
|
@@ -215,17 +215,34 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
215
215
|
|
|
216
216
|
return repository_hash
|
|
217
217
|
|
|
218
|
-
def _internal_add_helm(self, source, *,
|
|
219
|
-
values=None, values_file=None):
|
|
218
|
+
def _internal_add_helm(self, source, *, chart, name, namespace, include_crds,
|
|
219
|
+
values=None, values_file=None, repository=None, version=None):
|
|
220
220
|
if values and values_file:
|
|
221
221
|
raise RuntimeError(f"In {source} either values or values file may be specified, but not both")
|
|
222
222
|
|
|
223
|
+
if (repository and chart and chart.startswith("oci://") or
|
|
224
|
+
not repository and chart and not chart.startswith("oci://")):
|
|
225
|
+
raise RuntimeError(
|
|
226
|
+
f"In {source} either repository must be specified or OCI-chart must be used, but not both")
|
|
227
|
+
|
|
228
|
+
if not version and repository:
|
|
229
|
+
raise RuntimeError(f"In {source} version must be specified unless OCI-chart is used")
|
|
230
|
+
|
|
223
231
|
if values_file:
|
|
224
232
|
values_file = Path(values_file)
|
|
225
233
|
if not values_file.is_absolute():
|
|
226
234
|
values_file = self.context.app.cwd / values_file
|
|
227
235
|
|
|
228
|
-
|
|
236
|
+
version_spec = []
|
|
237
|
+
if repository:
|
|
238
|
+
repository_hash = self._add_repository(repository)
|
|
239
|
+
chart_name = f"{repository_hash}/{chart}"
|
|
240
|
+
else:
|
|
241
|
+
chart_name = chart
|
|
242
|
+
|
|
243
|
+
if version:
|
|
244
|
+
version_spec = ["--version", version]
|
|
245
|
+
|
|
229
246
|
stdin = DEVNULL
|
|
230
247
|
|
|
231
248
|
if values:
|
|
@@ -237,11 +254,11 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
237
254
|
resources = self.context.app.run_capturing_out(self.stanza() +
|
|
238
255
|
["template",
|
|
239
256
|
name,
|
|
240
|
-
|
|
241
|
-
"--version", version,
|
|
257
|
+
chart_name,
|
|
242
258
|
"-n", namespace,
|
|
243
259
|
"-a", ",".join(self.context.k8s.get_api_versions())
|
|
244
260
|
] +
|
|
261
|
+
version_spec +
|
|
245
262
|
(["--include-crds"] if include_crds else []) +
|
|
246
263
|
(["-f", values_file] if values_file else []) +
|
|
247
264
|
(["-f", "-"] if values else []),
|
kubernator/plugins/k8s_api.py
CHANGED
|
@@ -29,11 +29,10 @@ from typing import Union, Optional
|
|
|
29
29
|
|
|
30
30
|
import yaml
|
|
31
31
|
from jsonschema._format import FormatChecker
|
|
32
|
-
from jsonschema.
|
|
33
|
-
from jsonschema._validators import required
|
|
32
|
+
from jsonschema._keywords import required
|
|
34
33
|
from jsonschema.exceptions import ValidationError
|
|
35
|
-
from jsonschema.validators import extend, Draft7Validator
|
|
36
|
-
from openapi_schema_validator import
|
|
34
|
+
from jsonschema.validators import extend, Draft7Validator
|
|
35
|
+
from openapi_schema_validator import OAS31Validator
|
|
37
36
|
|
|
38
37
|
from kubernator.api import load_file, FileType, load_remote_file, calling_frame_source
|
|
39
38
|
|
|
@@ -89,11 +88,11 @@ def is_integer(instance):
|
|
|
89
88
|
# bool inherits from int, so ensure bools aren't reported as ints
|
|
90
89
|
if isinstance(instance, bool):
|
|
91
90
|
return False
|
|
92
|
-
return isinstance(instance,
|
|
91
|
+
return isinstance(instance, int)
|
|
93
92
|
|
|
94
93
|
|
|
95
94
|
def is_string(instance):
|
|
96
|
-
return isinstance(instance,
|
|
95
|
+
return isinstance(instance, str)
|
|
97
96
|
|
|
98
97
|
|
|
99
98
|
def type_validator(validator, data_type, instance, schema):
|
|
@@ -107,7 +106,7 @@ def type_validator(validator, data_type, instance, schema):
|
|
|
107
106
|
yield ValidationError("%r is not of type %s" % (instance, data_type))
|
|
108
107
|
|
|
109
108
|
|
|
110
|
-
K8SValidator = extend(
|
|
109
|
+
K8SValidator = extend(OAS31Validator, validators={
|
|
111
110
|
"type": type_validator,
|
|
112
111
|
"required": required
|
|
113
112
|
})
|
|
@@ -148,10 +147,6 @@ def check_int_or_string(value):
|
|
|
148
147
|
return check_int32(value) if is_integer(value) else is_string(value)
|
|
149
148
|
|
|
150
149
|
|
|
151
|
-
# def make_api_version(group, version):
|
|
152
|
-
# return f"{group}/{version}" if group else version
|
|
153
|
-
|
|
154
|
-
|
|
155
150
|
def to_group_and_version(api_version):
|
|
156
151
|
group, _, version = api_version.partition("/")
|
|
157
152
|
if not version:
|
|
@@ -663,10 +658,8 @@ class K8SResourcePluginMixin:
|
|
|
663
658
|
yield error
|
|
664
659
|
else:
|
|
665
660
|
rdef = error
|
|
666
|
-
# schema = ChainMap(manifest, self.resource_definitions_schema)
|
|
667
661
|
k8s_validator = K8SValidator(rdef.schema,
|
|
668
|
-
format_checker=k8s_format_checker
|
|
669
|
-
resolver=RefResolver.from_schema(self.resource_definitions_schema))
|
|
662
|
+
format_checker=k8s_format_checker)
|
|
670
663
|
yield from k8s_validator.iter_errors(manifest)
|
|
671
664
|
|
|
672
665
|
def _get_manifest_rdef(self, manifest):
|
|
@@ -744,6 +737,8 @@ class K8SResourcePluginMixin:
|
|
|
744
737
|
rdef_paths[path] = actions
|
|
745
738
|
|
|
746
739
|
for k, schema in k8s_def["definitions"].items():
|
|
740
|
+
# This short-circuits the resolution of the references to the top of the document
|
|
741
|
+
schema["definitions"] = k8s_def["definitions"]
|
|
747
742
|
for key in k8s_resource_def_key(schema):
|
|
748
743
|
for rdef in K8SResourceDef.from_manifest(key, schema, self.resource_paths):
|
|
749
744
|
self.resource_definitions[key] = rdef
|
kubernator/plugins/template.py
CHANGED
|
@@ -20,7 +20,7 @@ import logging
|
|
|
20
20
|
from collections.abc import Mapping
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
|
|
23
|
-
from jsonschema import Draft7Validator
|
|
23
|
+
from jsonschema import Draft7Validator
|
|
24
24
|
|
|
25
25
|
from kubernator.api import (KubernatorPlugin, Globs, scan_dir, load_file, FileType, calling_frame_source,
|
|
26
26
|
validator_with_defaults, TemplateEngine, Template)
|
|
@@ -86,7 +86,7 @@ TEMPLATE_SCHEMA = {
|
|
|
86
86
|
|
|
87
87
|
Draft7Validator.check_schema(TEMPLATE_SCHEMA)
|
|
88
88
|
TEMPLATE_VALIDATOR_CLS: type[Draft7Validator] = validator_with_defaults(Draft7Validator)
|
|
89
|
-
TEMPLATE_VALIDATOR: Draft7Validator = TEMPLATE_VALIDATOR_CLS(TEMPLATE_SCHEMA, format_checker=
|
|
89
|
+
TEMPLATE_VALIDATOR: Draft7Validator = TEMPLATE_VALIDATOR_CLS(TEMPLATE_SCHEMA, format_checker=Draft7Validator.FORMAT_CHECKER)
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
class TemplatePlugin(KubernatorPlugin):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kubernator
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.20
|
|
4
4
|
Summary: Kubernator is the a pluggable framework for K8S provisioning
|
|
5
5
|
Home-page: https://github.com/karellen/kubernator
|
|
6
6
|
Author: Express Systems USA, Inc.
|
|
@@ -38,9 +38,9 @@ Requires-Dist: durationpy>=0.7
|
|
|
38
38
|
Requires-Dist: gevent>=21.1.2
|
|
39
39
|
Requires-Dist: jinja2~=3.1
|
|
40
40
|
Requires-Dist: json-log-formatter~=0.3
|
|
41
|
-
Requires-Dist: jsonpatch~=1.
|
|
42
|
-
Requires-Dist: jsonpath-ng~=1.
|
|
43
|
-
Requires-Dist: jsonschema
|
|
41
|
+
Requires-Dist: jsonpatch~=1.33
|
|
42
|
+
Requires-Dist: jsonpath-ng~=1.7.0
|
|
43
|
+
Requires-Dist: jsonschema~=4.23
|
|
44
44
|
Requires-Dist: kubernetes~=32.0
|
|
45
45
|
Requires-Dist: openapi-schema-validator~=0.1
|
|
46
46
|
Requires-Dist: openapi-spec-validator~=0.3
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
kubernator/LICENSE,sha256=wKKdOCMTCPQRV5gDkVLAsXX8qSnRJ5owk7yWPO1KZNo,11387
|
|
2
|
-
kubernator/__init__.py,sha256=
|
|
2
|
+
kubernator/__init__.py,sha256=IRy34yWTWIg1ryLQHJqaB_ZoDZsFiv521TOZwhNFPiU,915
|
|
3
3
|
kubernator/__main__.py,sha256=f0S60wgpLu--1UlOhzfWail-xt8zyIuODodX98_yPN0,707
|
|
4
4
|
kubernator/_json_path.py,sha256=pjQKXxgbpQWETYBIrIuJZHgugF92IbEAM19AC7JUmAQ,3162
|
|
5
5
|
kubernator/_k8s_client_patches.py,sha256=PEeWPInnW38NDyK7G24_Dmw-x7xHpN3vJWZeckdqgK0,76892
|
|
6
|
-
kubernator/api.py,sha256=
|
|
6
|
+
kubernator/api.py,sha256=cU_dsS4PcTkRUcQqnRxsaqzeoApjhwRd2-l4CfwFZpU,27201
|
|
7
7
|
kubernator/app.py,sha256=ZtQm60Cb1z2SkD338B6nue3wLOo_auRqZRW5ou_-d84,20949
|
|
8
8
|
kubernator/merge.py,sha256=eW5fajnDdI2n8aUqRfTmdG6GWDvDtcVKPKsp3fiB5Nk,5882
|
|
9
9
|
kubernator/proc.py,sha256=8YlgbppyHic_51fVTPD7OP8x5yuRuL8j1kThR8MJjNI,5119
|
|
10
10
|
kubernator/plugins/__init__.py,sha256=h9TLYK8UFEi53ipZSZsTBjp0ljKhisWsgPpt_PkWrO8,670
|
|
11
11
|
kubernator/plugins/awscli.py,sha256=S6X7-qFiaZ7NDVDl2Jg0t-ih9KAJ45cUjjzd5Qe93ZM,4252
|
|
12
12
|
kubernator/plugins/eks.py,sha256=xe7vyPHNwuP8gEYDSzPyBkm-RkAtP64wCOqs9U5I7xI,2273
|
|
13
|
-
kubernator/plugins/helm.py,sha256=
|
|
13
|
+
kubernator/plugins/helm.py,sha256=R5hrDDhQ8b5BYYswvxJaM9-KsHKWPBKqHVtTRa1eSuA,11122
|
|
14
14
|
kubernator/plugins/istio.py,sha256=oERwbVtIk9vMJp_miBXK3-XJKF6SDbh6PPe0p3QIekY,14924
|
|
15
15
|
kubernator/plugins/k8s.py,sha256=Zj3q_bUmbOADfjSHy2X0BhgrbXuH-fM8Vq75sYFy0nE,24496
|
|
16
|
-
kubernator/plugins/k8s_api.py,sha256=
|
|
16
|
+
kubernator/plugins/k8s_api.py,sha256=PDa7MB9q3WMm_9tr8T6LY_ojrHpyGYiNTlvBZinbgFY,27379
|
|
17
17
|
kubernator/plugins/kops.py,sha256=QsrQJUF6wGJo2QRVqP92pG5vmOTYQIc25PD_DWCzrAA,9635
|
|
18
18
|
kubernator/plugins/kubeconfig.py,sha256=uwtHmF2I6LiTPrC3M88G5SfYxDWtuh0MqcMfrHHoNRA,2178
|
|
19
19
|
kubernator/plugins/kubectl.py,sha256=IgNghW1Q6s8V2o08eNY2NWfkkdV9Z6X2A3YFQinFr4g,4028
|
|
20
20
|
kubernator/plugins/minikube.py,sha256=FFGW8Rkap4CPEydEgxXhIuK3A263khjli0adC5j09MA,10393
|
|
21
|
-
kubernator/plugins/template.py,sha256=
|
|
21
|
+
kubernator/plugins/template.py,sha256=542nyS4ZNgdwJHEoIA5aLP1d4C312ydd7sPM9ZFbHuI,8357
|
|
22
22
|
kubernator/plugins/terraform.py,sha256=a1MPl9G8Rznjd28uMRdYWrjpFDLlFAVmLFH4hFEsMsQ,5285
|
|
23
23
|
kubernator/plugins/terragrunt.py,sha256=-qN8tTqPUXJ9O7CEiJVUB0GSUQU3DUTkv-aWdIIsm7Q,5051
|
|
24
|
-
kubernator-1.0.
|
|
25
|
-
kubernator-1.0.
|
|
26
|
-
kubernator-1.0.
|
|
27
|
-
kubernator-1.0.
|
|
28
|
-
kubernator-1.0.
|
|
29
|
-
kubernator-1.0.
|
|
30
|
-
kubernator-1.0.
|
|
24
|
+
kubernator-1.0.20.dist-info/METADATA,sha256=F8vyynX8hw__zZG9y36Yew_bD81DtclrBjsgxGpr_9g,10851
|
|
25
|
+
kubernator-1.0.20.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
26
|
+
kubernator-1.0.20.dist-info/entry_points.txt,sha256=IWDtHzyTleRqDSuVRXEr5GImrI7z_kh21t5DWZ8ldcQ,47
|
|
27
|
+
kubernator-1.0.20.dist-info/namespace_packages.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
28
|
+
kubernator-1.0.20.dist-info/top_level.txt,sha256=_z1CxWeKMI55ckf2vC8HqjbCn_E2Y_P5RdrhE_QWcIs,11
|
|
29
|
+
kubernator-1.0.20.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
30
|
+
kubernator-1.0.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|