Skip to content

Commit

Permalink
Fix for OCIRepository relative paths (#232)
Browse files Browse the repository at this point in the history
Issue #198
  • Loading branch information
allenporter authored Jun 11, 2023
1 parent 315119c commit 9cd949d
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions flux_local/git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,14 @@ async def kustomization_traversal(path_selector: PathSelector) -> list[Kustomiza
for kustomization in docs:
if not kustomization.source_path:
continue
_LOGGER.debug(
"Updating relative path: %s, %s, %s",
root,
path,
kustomization.source_path,
)
kustomization.source_path = str(
((root / path) / kustomization.source_path).relative_to(root)
)
_LOGGER.debug(
"Updated relative path: %s => %s",
node_name(kustomization),
kustomization.source_path,
)

visited |= set({path})

Expand All @@ -410,7 +409,14 @@ async def kustomization_traversal(path_selector: PathSelector) -> list[Kustomiza
for source in path_selector.sources or ():
if source.name == doc.source_name:
found_path = source.root / doc.path
doc.path = str(found_path)
_LOGGER.debug(
"Updated Source for OCIRepository %s: %s",
doc.name,
doc.path,
)
break

elif not doc.source_kind or doc.source_kind == GIT_REPO_KIND:
found_path = Path(doc.path)

Expand Down Expand Up @@ -458,23 +464,6 @@ def make_clusters(
"Kustomization did not have source path; Old kustomize?"
)

# OCIRepositories may be build pointed at a subset of the cluster which can
# only be determined based on input command line flags
if ks.source_kind == OCI_REPO_KIND:
if root := next(
map(
source_root, filter(has_source_name(ks.source_name or ""), sources)
),
None,
):
ks.path = str(root / ks.path)
_LOGGER.debug(
"Updated Source for OCIRepository %s: %s", ks.name, ks.path
)
else:
_LOGGER.debug("Excluding OCIRepository without source %s", ks.name)
continue

graph.add_node(node_name(ks), ks=ks)

# Find the parent Kustomization that produced this based on the
Expand Down

0 comments on commit 9cd949d

Please sign in to comment.