(e Endpoint, method string)
| 30 | } |
| 31 | |
| 32 | func (c *sshCache) Resolve(e Endpoint, method string) (sshAuthResponse, error) { |
| 33 | if len(e.SSHMetadata.UserAndHost) == 0 { |
| 34 | return sshAuthResponse{}, nil |
| 35 | } |
| 36 | |
| 37 | key := strings.Join([]string{e.SSHMetadata.UserAndHost, e.SSHMetadata.Port, e.SSHMetadata.Path, method}, "//") |
| 38 | if res, ok := c.endpoints[key]; ok { |
| 39 | if _, expired := res.IsExpiredWithin(5 * time.Second); !expired { |
| 40 | tracerx.Printf("ssh cache: %s git-lfs-authenticate %s %s", |
| 41 | e.SSHMetadata.UserAndHost, e.SSHMetadata.Path, endpointOperation(e, method)) |
| 42 | return *res, nil |
| 43 | } else { |
| 44 | tracerx.Printf("ssh cache expired: %s git-lfs-authenticate %s %s", |
| 45 | e.SSHMetadata.UserAndHost, e.SSHMetadata.Path, endpointOperation(e, method)) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | res, err := c.ssh.Resolve(e, method) |
| 50 | if err == nil { |
| 51 | c.endpoints[key] = &res |
| 52 | } |
| 53 | return res, err |
| 54 | } |
| 55 | |
| 56 | type sshAuthResponse struct { |
| 57 | Message string `json:"-"` |
nothing calls this directly
no test coverage detected