Git abstraction layer written in Go, mainly for use in Kubernetes Controllers.
Git Store is based on Go Git and provides convenience methods for cloning, fetching and checking out repository references and accessing file contents within a repository.
To get a slice of all yaml and json file from a repository at a given reference:
func getFilesFromRepo(url string, privateKey []byte, gitReference string) ([]*gitstore.File, error) {
store := gitstore.NewRepoStore()
repo, err := store.Get(&gistore.RepoRef{
URL: url,
PrivateKey: privateKey,
})
err = repo.Checkout(gitReference)
globbedSubPath := strings.TrimPrefix(gt.Spec.SubPath, "/") + "{**/*,*}.{yaml,yml,json}"
files, err := repo.GetAllFiles(globbedSubPath, true)
return files, err
}
Then, to work with these files:
files, err := getFilesFromRepo("git@github.com:/...", someKey, "master")
for file := range files {
doStuffWith(file.Contents())
}
- Found a bug? Please open an issue.
- Have a feature request. Please open an issue.
- If you want to contribute, please submit a pull request
Please see our Contributing guidelines.
This project is licensed under Apache 2.0 and a copy of the license is available here.