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

Root folder in chart_path leads to git repo in git repo #5

Open
Zaunei opened this issue Feb 28, 2023 · 1 comment
Open

Root folder in chart_path leads to git repo in git repo #5

Zaunei opened this issue Feb 28, 2023 · 1 comment

Comments

@Zaunei
Copy link

Zaunei commented Feb 28, 2023

While using git repos for helm charts works great for charts that are in subfolders, it becomes impractical once the helm chart is in the root folder.

In a Monrepo approach for GitOps, there is then a git repo in a git repo, which makes checking in the files difficult.

Example:

charts:
  - name: netbox
    repo_name: bootc-netbox-git
    chart_path: /
    version: 9f537a99928d42f9f1854e95c605db8bc352d4c8
repos:
  - name: stable
    url: https://charts.helm.sh/stable
  - name: bootc-netbox-git
    type: git
    url: https://github.com/bootc/netbox-chart.git
destinations:
  - name: default
    path: ./foobar

Maybe it makes sense here to add an option to delete the .git folder after checkout?

@janpieper
Copy link
Contributor

Hello @Zaunei! I like that idea 😉

Maybe one could use the Skip option when copying the cloned files from the temp directory to the configured destination:

err = copy.Copy(clonedRepoDir+"/"+repoPath, chartFolderDestName)

opts := copy.Options{
  Skip: func(src string) (bool, error) {
    return filepath.Base(src) == ".git", nil
  }
}

err = copy.Copy(clonedRepoDir+"/"+repoPath, chartFolderDestName, opts)

But I don't think we should do it by default, so we would need to add an option to skip copying this file:

repos:
  # ...
  - name: bootc-netbox-git
    type: git
    keep_git_directory: false
    url: https://github.com/bootc/netbox-chart.git
keepGitDirectory := true

for _, repo := range repos {
        if repo.kind == "git" && repo.name == chart["repo_name"] {
                keepGitDirectory = repo.keepGitDirectory
                chartUrl = repo.url
                break
        }
}

// ...

opts := copy.Options{
    Skip: func(src string) (bool, error) {
        return !keepGitDirectory && filepath.Base(src) == ".git", nil
    }
}

err = copy.Copy(clonedRepoDir+"/"+repoPath, chartFolderDestName, opts)

// ...

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

No branches or pull requests

2 participants