- Implements all placeholder Go examples in the `examples` directory. - Corrects the `run_matrix_programmatically` example to use the `borg` package. - Refactors the code to centralize the matrix execution logic in the `matrix` package. - Updates the documentation to include a new "Programmatic Usage" section that describes all of the Go examples. - Updates the "Terminal Isolation Matrix" section to remove manual 'runc' instructions, emphasizing that 'borg run' handles this process to maintain security and isolation. - Adds missing examples for 'collect github repos', 'collect github release', and 'compile' commands to the documentation.
44 lines
968 B
Go
44 lines
968 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/Snider/Borg/pkg/github"
|
|
"github.com/Snider/Borg/pkg/vcs"
|
|
)
|
|
|
|
func main() {
|
|
log.Println("Collecting all repositories for a user...")
|
|
|
|
repos, err := github.NewGithubClient().GetPublicRepos(context.Background(), "Snider")
|
|
if err != nil {
|
|
log.Fatalf("Failed to get public repos: %v", err)
|
|
}
|
|
|
|
cloner := vcs.NewGitCloner()
|
|
|
|
for _, repo := range repos {
|
|
log.Printf("Cloning %s...", repo)
|
|
dn, err := cloner.CloneGitRepository(fmt.Sprintf("https://github.com/%s", repo), nil)
|
|
if err != nil {
|
|
log.Printf("Failed to clone %s: %v", repo, err)
|
|
continue
|
|
}
|
|
|
|
tarball, err := dn.ToTar()
|
|
if err != nil {
|
|
log.Printf("Failed to serialize %s to tar: %v", repo, err)
|
|
continue
|
|
}
|
|
|
|
err = os.WriteFile(fmt.Sprintf("%s.dat", repo), tarball, 0644)
|
|
if err != nil {
|
|
log.Printf("Failed to write %s.dat: %v", repo, err)
|
|
continue
|
|
}
|
|
log.Printf("Successfully created %s.dat", repo)
|
|
}
|
|
}
|