MCPcopy
hub / github.com/kopia/kopia / run

Method run

cli/command_repository_connect_server.go:37–76  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

35}
36
37func (c *commandRepositoryConnectServer) run(ctx context.Context) error {
38 localCacheKeyDerivationAlgorithm := c.connectAPIServerLocalCacheKeyDerivationAlgorithm
39
40 as := &repo.APIServerInfo{
41 BaseURL: strings.TrimSuffix(c.connectAPIServerURL, "/"),
42 TrustedServerCertificateFingerprint: strings.ToLower(c.connectAPIServerCertFingerprint),
43 LocalCacheKeyDerivationAlgorithm: localCacheKeyDerivationAlgorithm,
44 }
45
46 configFile := c.svc.repositoryConfigFileName()
47 opt := c.co.toRepoConnectOptions()
48
49 u := opt.Username
50 if u == "" {
51 u = repo.GetDefaultUserName(ctx)
52 }
53
54 h := opt.Hostname
55 if h == "" {
56 h = repo.GetDefaultHostName(ctx)
57 }
58
59 log(ctx).Infof("Connecting to server '%v' as '%v@%v'...", as.BaseURL, u, h)
60
61 pass, err := c.svc.getPasswordFromFlags(ctx, false, false)
62 if err != nil {
63 return errors.Wrap(err, "getting password")
64 }
65
66 if err := passwordpersist.OnSuccess(
67 ctx, repo.ConnectAPIServer(ctx, configFile, as, pass, opt),
68 c.svc.passwordPersistenceStrategy(), configFile, pass); err != nil {
69 return errors.Wrap(err, "error connecting to API server")
70 }
71
72 log(ctx).Info("Connected to repository API Server.")
73 c.svc.maybeInitializeUpdateCheck(ctx, c.co)
74
75 return nil
76}

Callers

nothing calls this directly

Calls 10

GetDefaultUserNameFunction · 0.92
GetDefaultHostNameFunction · 0.92
OnSuccessFunction · 0.92
ConnectAPIServerFunction · 0.92
toRepoConnectOptionsMethod · 0.80
InfoMethod · 0.80
getPasswordFromFlagsMethod · 0.65

Tested by

no test coverage detected