Files
kopia/internal/server/api_cli.go
Jarek Kowalski 9cba4a97be refactor(repository): major server code refactoring (#1837)
This removes big shared lock held for for the duration of each request
and replaces it with trivially short lock to capture the current
state of the server/repository before passing it to handlers.

Handlers are now limited to only accessing a small subset of Server
functionality to be able to better reason about them.
2022-03-19 22:01:38 -07:00

29 lines
523 B
Go

package server
import (
"context"
"os"
"strings"
"github.com/kopia/kopia/internal/serverapi"
)
func handleCLIInfo(ctx context.Context, rc requestContext) (interface{}, *apiError) {
executable, err := os.Executable()
if err != nil {
executable = "kopia"
}
return &serverapi.CLIInfo{
Executable: maybeQuote(executable) + " --config-file=" + maybeQuote(rc.srv.getOptions().ConfigFile) + "",
}, nil
}
func maybeQuote(s string) string {
if !strings.Contains(s, " ") {
return s
}
return "\"" + s + "\""
}