Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE]: Path finder #21

Open
damsien opened this issue Oct 17, 2024 · 0 comments
Open

[FE]: Path finder #21

damsien opened this issue Oct 17, 2024 · 0 comments
Labels
feature A feature that is listed in the roadmap good first issue Good for newcomers

Comments

@damsien
Copy link
Collaborator

damsien commented Oct 17, 2024

Roadmap 2025/02 Path finder : if an object already exists in any form in the remote repo, then replace it
As an application DevOps, I want my RemoteSyncer to automatically find if the object already exists in my repo with a custom path. If it does not exists, then keep the default behavior (namespace/group/apiVersion/kind/name).

What to do

Create a new pathFinder() function that returns the path if found or an empty string if not found. The function will be called in the pathConstructor() function before the line #L104.

func (gp *GitPusher) pathConstructor(w *git.Worktree) (string, error) {
gvr := gp.interceptedGVR
tempPath := ""

The function can be implemented using the DFS (depth first search) algorithm. For each file found (a leaf of a graph), open it and check the metadata of the object. If the Group, Version (eg. apiVersion: apps/v1) & Kind (eg. kind: Deployment) (GVK) is the same, then check the namespace and the name. If they are the same as well, then the resource is found and the path is the path of the current file.

If the the pathFinder() function does not return an empty string, then the pathConstructor() function can directly returns the output of the pathFinder() function.

Additional context

If you have any questions, please tag @damsien.

@damsien damsien added enhancement Request for enhancement good first issue Good for newcomers feature A feature that is listed in the roadmap labels Oct 17, 2024
@damsien damsien removed the enhancement Request for enhancement label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature that is listed in the roadmap good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant