Skip to content

Commit

Permalink
Merge branch 'master' into support-python3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoVoges authored May 3, 2023
2 parents e6930af + ab7151f commit 1a1b052
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 300 deletions.
451 changes: 180 additions & 271 deletions docs/pages/external_dependencies.md

Large diffs are not rendered by default.

34 changes: 19 additions & 15 deletions kapitan/dependency_manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def fetch_dependencies(output_path, target_objs, save_dir, force, pool):

if full_output_path in deps_output_paths[source_uri]:
# if the output_path is duplicated for the same source_uri
logger.warning("Skipping duplicate output path for uri %s", source_uri)
logger.debug("Skipping duplicate output path for uri %s", source_uri)
continue
else:
deps_output_paths[source_uri].add(full_output_path)
Expand Down Expand Up @@ -124,10 +124,11 @@ def fetch_git_dependency(dep_mapping, save_dir, force, item_type="Dependency"):
"{} {}: subdir {} not found in repo".format(item_type, source, sub_dir)
)
if force:
copy_tree(copy_src_path, output_path)
copied = copy_tree(copy_src_path, output_path, verbose=0)
else:
safe_copy_tree(copy_src_path, output_path)
logger.info("%s %s: saved to %s", item_type, source, output_path)
copied = safe_copy_tree(copy_src_path, output_path)
if copied:
logger.info("%s %s: saved to %s", item_type, source, output_path)


def fetch_git_source(source, save_dir, item_type):
Expand All @@ -136,10 +137,10 @@ def fetch_git_source(source, save_dir, item_type):
if os.path.exists(save_dir):
rmtree(save_dir)
logger.debug("Removed %s", save_dir)
logger.info("%s %s: fetching now", item_type, source)
logger.debug("%s %s: fetching now", item_type, source)
try:
Repo.clone_from(source, save_dir)
logger.info("%s %s: successfully fetched", item_type, source)
logger.debug("%s %s: successfully fetched", item_type, source)
logger.debug("Git clone cached to %s", save_dir)
except GitCommandError as e:
logger.error(e)
Expand Down Expand Up @@ -194,7 +195,7 @@ def fetch_http_dependency(dep_mapping, save_dir, force, item_type="Dependency"):
copyfile(cached_source_path, output_path)
else:
safe_copy_file(cached_source_path, output_path)
logger.info("%s %s: saved to %s", item_type, source, output_path)
logger.debug("%s %s: saved to %s", item_type, source, output_path)


def fetch_http_source(source, save_path, item_type):
Expand All @@ -203,9 +204,9 @@ def fetch_http_source(source, save_path, item_type):
if os.path.exists(save_path):
os.remove(save_path)
logger.debug("Removed %s", save_path)
logger.info("%s %s: fetching now", item_type, source)
logger.debug("%s %s: fetching now", item_type, source)
content, content_type = make_request(source)
logger.info("%s %s: successfully fetched", item_type, source)
logger.debug("%s %s: successfully fetched", item_type, source)
if content is not None:
with open(save_path, "wb") as f:
f.write(content)
Expand Down Expand Up @@ -237,15 +238,18 @@ def fetch_helm_chart(dep_mapping, save_dir, force):
parent_dir = os.path.dirname(output_path)
if parent_dir != "":
os.makedirs(parent_dir, exist_ok=True)

if force:
copy_tree(cached_repo_path, output_path)
copied = copy_tree(cached_repo_path, output_path, verbose=0)
else:
safe_copy_tree(cached_repo_path, output_path)
logger.info("Dependency %s: saved to %s", source.chart_name, output_path)
copied = safe_copy_tree(cached_repo_path, output_path)

if copied:
logger.info("Dependency %s: saved to %s", source.chart_name, output_path)


def fetch_helm_archive(helm_path, repo, chart_name, version, save_path):
logger.info("Dependency helm chart %s and version %s: fetching now", chart_name, version or "latest")
logger.debug("Dependency helm chart %s and version %s: fetching now", chart_name, version or "latest")
# Fetch archive and untar it into parent dir
save_dir = os.path.dirname(save_path)
args = ["pull", "--destination", save_dir, "--untar"]
Expand All @@ -268,8 +272,8 @@ def fetch_helm_archive(helm_path, repo, chart_name, version, save_path):
else:
# rename chart to requested name
os.rename(os.path.join(save_dir, chart_name), save_path)
logger.info("Dependency helm chart %s and version %s: successfully fetched", chart_name, version)
logger.info("Dependency helm chart %s and version %s: saved to %s", chart_name, version, save_path)
logger.debug("Dependency helm chart %s and version %s: successfully fetched", chart_name, version)
logger.debug("Dependency helm chart %s and version %s: saved to %s", chart_name, version, save_path)


def exists_in_cache(item_path):
Expand Down
6 changes: 3 additions & 3 deletions kapitan/inputs/jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def compile_file(self, file_path, compile_path, ext_vars, **kwargs):
ext_vars will be passed as parameters to jsonnet_file()
kwargs:
output: default 'yaml', accepts 'json'
prune: default False, accepts True
prune_output: default False, accepts True
reveal: default False, set to reveal refs on compile
target_name: default None, set to current target being compiled
indent: default 2
Expand All @@ -97,12 +97,12 @@ def _search_imports(cwd, imp):
output_obj = json.loads(json_output)

output = kwargs.get("output", "yaml")
prune = kwargs.get("prune_output", False)
prune_output = kwargs.get("prune_output", False)
reveal = kwargs.get("reveal", False)
target_name = kwargs.get("target_name", None)
indent = kwargs.get("indent", 2)

if prune:
if prune_output:
output_obj = prune_empty(output_obj)
logger.debug("Pruned output for: %s", file_path)

Expand Down
6 changes: 3 additions & 3 deletions kapitan/inputs/kadet.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def compile_file(self, file_path, compile_path, ext_vars, **kwargs):
ext_vars is not used in Kadet
kwargs:
output: default 'yaml', accepts 'json'
prune_input: default False
prune_output: default False
reveal: default False, set to reveal refs on compile
target_name: default None, set to current target being compiled
indent: default 2
"""
output = kwargs.get("output", "yaml")
prune_input = kwargs.get("prune_input", False)
prune_output = kwargs.get("prune_output", False)
reveal = kwargs.get("reveal", False)
target_name = kwargs.get("target_name", None)
# inventory_path = kwargs.get("inventory_path", None)
Expand Down Expand Up @@ -135,7 +135,7 @@ def compile_file(self, file_path, compile_path, ext_vars, **kwargs):
raise CompileError(f"Could not load Kadet module: {spec.name[16:]}")

output_obj = _to_dict(output_obj)
if prune_input:
if prune_output:
output_obj = prune_empty(output_obj)

# Return None if output_obj has no output
Expand Down
2 changes: 1 addition & 1 deletion kapitan/reclass
Submodule reclass updated 0 files
2 changes: 1 addition & 1 deletion kapitan/remoteinventory/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def fetch_inventories(inventory_path, target_objs, save_dir, force, pool):

if output_path in inv_output_path[source_uri]:
# if the output_path is duplicated for the same source_uri
logger.warning("Skipping duplicate output path for uri %s", source_uri)
logger.debug("Skipping duplicate output path for uri %s", source_uri)
continue
else:
inv_output_path[source_uri].add(output_path)
Expand Down
7 changes: 4 additions & 3 deletions kapitan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def safe_copy_file(src, dst):
dir = os.path.dirname(dst)

if os.path.isfile(dst):
logger.warning("Not updating %s (file already exists)", dst)
logger.debug("Not updating %s (file already exists)", dst)
return (dst, 0)
_copy_file_contents(src, dst)
logger.debug("Copied %s to %s", src, dir)
Expand Down Expand Up @@ -627,7 +627,8 @@ def safe_copy_tree(src, dst):
outputs.extend(safe_copy_tree(src_name, dst_name))

else:
safe_copy_file(src_name, dst_name)
outputs.append(dst_name)
_, value = safe_copy_file(src_name, dst_name)
if value:
outputs.append(dst_name)

return outputs
2 changes: 1 addition & 1 deletion kapitan/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""Project description variables."""

PROJECT_NAME = "kapitan"
VERSION = "0.31.1rc3"
VERSION = "0.32.0rc0"
DESCRIPTION = "Generic templated configuration management for Kubernetes, Terraform and other things"
AUTHOR = "Ricardo Amaro"
AUTHOR_EMAIL = "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ nav:
- Documentation:
- Overview: pages/kapitan_overview.md
- Inventory:
- Introduction: /inventory/introduction.md
- Introduction: pages/inventory/introduction.md
- Targets: pages/inventory/targets.md
- Classes: pages/inventory/classes.md
- Parameters Interpolation: pages/inventory/parameters_interpolation.md
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
]
license = "Apache-2.0"
version = "0.31.1rc3"
version = "0.32.0rc0"
packages = [
{ include = "kapitan" },
{ include = "kapitan/reclass" },
Expand Down

0 comments on commit 1a1b052

Please sign in to comment.