forked from tangled.org/core
this repo has no description

keyfetch: remove all mentions of repoguard

replace with `knot guard` instead.

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by Tangled f7d68908 ecf175c5

Changed files
+11 -11
keyfetch
+11 -11
keyfetch/keyfetch.go
··· 31 31 Value: "http://localhost:5444", 32 32 }, 33 33 &cli.StringFlag{ 34 - Name: "repoguard-path", 35 - Usage: "path to the repoguard binary", 36 - Value: "/home/git/repoguard", 37 - }, 38 - &cli.StringFlag{ 39 34 Name: "git-dir", 40 35 Usage: "base directory for git repos", 41 36 Value: "/home/git", ··· 50 45 } 51 46 52 47 func Run(ctx context.Context, cmd *cli.Command) error { 48 + l := log.FromContext(ctx) 49 + 53 50 internalApi := cmd.String("internal-api") 54 - repoguardPath := cmd.String("repoguard-path") 55 51 gitDir := cmd.String("git-dir") 56 52 logPath := cmd.String("log-path") 57 53 output := cmd.String("output") 58 54 59 - l := log.FromContext(ctx) 55 + executablePath, err := os.Executable() 56 + if err != nil { 57 + l.Error("error getting path of executable", "error", err) 58 + return err 59 + } 60 60 61 61 resp, err := http.Get(internalApi + "/keys") 62 62 if err != nil { ··· 91 91 return err 92 92 } 93 93 case "authorized-keys": 94 - formatted := formatKeyData(repoguardPath, gitDir, logPath, internalApi, data) 94 + formatted := formatKeyData(executablePath, gitDir, logPath, internalApi, data) 95 95 _, err := os.Stdout.Write([]byte(formatted)) 96 96 if err != nil { 97 97 l.Error("error writing to stdout", "error", err) ··· 110 110 return nil 111 111 } 112 112 113 - func formatKeyData(repoguardPath, gitDir, logPath, endpoint string, data []map[string]any) string { 113 + func formatKeyData(executablePath, gitDir, logPath, endpoint string, data []map[string]any) string { 114 114 var result string 115 115 for _, entry := range data { 116 116 result += fmt.Sprintf( 117 - `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", 118 - repoguardPath, gitDir, entry["did"], logPath, endpoint, entry["key"]) 117 + `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", 118 + executablePath, gitDir, entry["did"], logPath, endpoint, entry["key"]) 119 119 } 120 120 return result 121 121 }