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)
| 659 | // carrying the access token as AccessToken. It clones the timestamps so the record never aliases the credential's |
| 660 | // *time.Time values. |
| 661 | func recordFromCredential(credential gh.Credential) refreshableTokenRecord { |
| 662 | return refreshableTokenRecord{ |
| 663 | AccessToken: credential.Token, |
| 664 | RefreshToken: credential.RefreshToken, |
| 665 | ExpiresIn: credential.ExpiresIn, |
| 666 | RefreshTokenExpiresIn: credential.RefreshTokenExpiresIn, |
| 667 | ExpiresAt: cloneTime(credential.ExpiresAt), |
| 668 | RefreshTokenExpiresAt: cloneTime(credential.RefreshTokenExpiresAt), |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | // cloneTime returns a pointer to a copy of t, or nil when t is nil, so callers moving timestamps between the record |
| 673 | // and gh.Credential never share the underlying *time.Time. |