···
Value: "http://localhost:5444",
-
Name: "repoguard-path",
-
Usage: "path to the repoguard binary",
-
Value: "/home/git/repoguard",
Usage: "base directory for git repos",
···
func Run(ctx context.Context, cmd *cli.Command) error {
internalApi := cmd.String("internal-api")
-
repoguardPath := cmd.String("repoguard-path")
gitDir := cmd.String("git-dir")
logPath := cmd.String("log-path")
output := cmd.String("output")
-
l := log.FromContext(ctx)
resp, err := http.Get(internalApi + "/keys")
···
-
formatted := formatKeyData(repoguardPath, gitDir, logPath, internalApi, data)
_, err := os.Stdout.Write([]byte(formatted))
l.Error("error writing to stdout", "error", err)
···
-
func formatKeyData(repoguardPath, gitDir, logPath, endpoint string, data []map[string]any) string {
for _, entry := range data {
-
`command="%s -base-dir %s -user %s -log-path %s -internal-api %s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s`+"\n",
-
repoguardPath, gitDir, entry["did"], logPath, endpoint, entry["key"])
···
Value: "http://localhost:5444",
Usage: "base directory for git repos",
···
func Run(ctx context.Context, cmd *cli.Command) error {
+
l := log.FromContext(ctx)
internalApi := cmd.String("internal-api")
gitDir := cmd.String("git-dir")
logPath := cmd.String("log-path")
output := cmd.String("output")
+
executablePath, err := os.Executable()
+
l.Error("error getting path of executable", "error", err)
resp, err := http.Get(internalApi + "/keys")
···
+
formatted := formatKeyData(executablePath, gitDir, logPath, internalApi, data)
_, err := os.Stdout.Write([]byte(formatted))
l.Error("error writing to stdout", "error", err)
···
+
func formatKeyData(executablePath, gitDir, logPath, endpoint string, data []map[string]any) string {
for _, entry := range data {
+
`command="%s guard -git-dir %s -user %s -log-path %s -internal-api %s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s`+"\n",
+
executablePath, gitDir, entry["did"], logPath, endpoint, entry["key"])