recordFromCredential projects a gh.Credential onto the persisted record shape, dropping the runtime-only Source and carrying the access token as AccessToken. It clones the timestamps so the record never aliases the credential's *time.Time values.
(credential gh.Credential)
| 580 | // carrying the access token as AccessToken. It clones the timestamps so the record never aliases the credential's |
| 581 | // *time.Time values. |
| 582 | func recordFromCredential(credential gh.Credential) refreshableTokenRecord { |
| 583 | return refreshableTokenRecord{ |
| 584 | AccessToken: credential.Token, |
| 585 | RefreshToken: credential.RefreshToken, |
| 586 | ExpiresIn: credential.ExpiresIn, |
| 587 | RefreshTokenExpiresIn: credential.RefreshTokenExpiresIn, |
| 588 | ExpiresAt: cloneTime(credential.ExpiresAt), |
| 589 | RefreshTokenExpiresAt: cloneTime(credential.RefreshTokenExpiresAt), |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | // cloneTime returns a pointer to a copy of t, or nil when t is nil, so callers moving timestamps between the record |
| 594 | // and gh.Credential never share the underlying *time.Time. |