Skip to content

Conversation

@jkoelker
Copy link

Add --ignore-paths flag to CLI and actions.

Some repositories may contain yaml files that are not kustomize or cluster resources. Allow skipping those paths.

Fixes: #211

@jkoelker jkoelker changed the title Gfeat(are): add --ignore-paths support feat(are): add --ignore-paths support Oct 22, 2025
@jkoelker jkoelker changed the title feat(are): add --ignore-paths support feat: add --ignore-paths support Oct 22, 2025

kinds = [CLUSTER_KUSTOMIZE_KIND, CONFIG_MAP_KIND, SECRET_KIND]

def _normalize_patterns(patterns: list[str]) -> list[str]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this section here and below seem extremely complicated for implementing this feature. It seems like it only needs to be like 5 line change. There are now 3 copies of essentially the same code, so I'd like to decline this, unless it can be 10x smaller.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totes, yea admittedly I just vibed this out last night when i hit the issue of having yaml in a generated configmap being processed again. I'll rework this portion manually as yea it just vomited.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into the same problem it looks like codex did, since kustomize cfg grep doesn't support anything other than .krmignore, plumbing through to flux any ignore-paths fails on the kustomize call searching for the flux GitRepository. I first tried generating a temporary .krmignore but then this has the side effect that it could overwrite and existing one, which we could then look to merge in, but that then could accidentally get committed to a repo, so I abandoned that line.

I too then implemented the search in the case of ignores manually, but I believe a bit more manageable and maintainable, leveraging pathspec which was already a transitive dependency to walk the tree and apply the filters for us. I kept the change gated such that only if ignore-paths is specified will it use the python based search, if there are no ignore-paths it continues to use kustomize cfg grep.

If you'd like I can make the python walking the only one. I've tested it on a fairly large private repository and it completed the task around the same as shelling out to kustomize.

There is similar walking code in the flux-local diagnostics code, if you want I can look at combining the two into a single walking support with filtering, but I didn't eagerly do that to keep the diff smaller.

Add `--ignore-paths` flag to CLI and actions.

Some repositories may contain yaml files that are not kustomize or
cluster resources. Allow skipping those paths.

Fixes: allenporter#211

# Initialize git repository
repo = git.Repo.init(repo_path)
repo = git.Repo.init(repo_path, initial_branch='master')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally test_git_repository_branch_reconciliation was failing for me since it was getting inited with main as the branch name, where the test expects it to be master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support GitRepository source controller exclusions

2 participants