(ctx context.Context)
| 35 | } |
| 36 | |
| 37 | func (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 | } |
nothing calls this directly
no test coverage detected