Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pusher/git-store
Go git abstraction for use in Kubernetes Controllers
https://github.com/pusher/git-store
cloud-infrastructure
Last synced: 3 months ago
JSON representation
Go git abstraction for use in Kubernetes Controllers
- Host: GitHub
- URL: https://github.com/pusher/git-store
- Owner: pusher
- License: apache-2.0
- Created: 2018-08-08T12:24:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T13:18:05.000Z (about 5 years ago)
- Last Synced: 2024-07-20T03:18:56.799Z (4 months ago)
- Topics: cloud-infrastructure
- Language: Go
- Size: 447 KB
- Stars: 9
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Git Store
Git abstraction layer written in Go, mainly for use in Kubernetes Controllers.Git Store is based on [Go Git](https://github.com/src-d/go-git) and provides convenience methods
for cloning, fetching and checking out repository references and accessing file contents within a repository.## Usage
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("[email protected]:/...", someKey, "master")for file := range files {
doStuffWith(file.Contents())
}
```## Communication
* 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## Contributing
Please see our [Contributing](CONTRIBUTING.md) guidelines.## License
This project is licensed under Apache 2.0 and a copy of the license is available [here](LICENSE).