Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc: Read timestamps from timestamppb fields instead of int64 fields #7121

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions grpc/pb-marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func PBToChallenge(in *corepb.Challenge) (challenge core.Challenge, err error) {
return core.Challenge{}, err
}
var validated *time.Time
if in.ValidatedNS != 0 {
val := time.Unix(0, in.ValidatedNS).UTC()
if in.Validated != nil && !in.Validated.AsTime().IsZero() {
val := in.Validated.AsTime()
pgporada marked this conversation as resolved.
Show resolved Hide resolved
validated = &val
}
ch := core.Challenge{
Expand Down Expand Up @@ -275,8 +275,8 @@ func PbToRegistration(pb *corepb.Registration) (core.Registration, error) {
return core.Registration{}, err
}
var createdAt *time.Time
if pb.CreatedAtNS != 0 {
c := time.Unix(0, pb.CreatedAtNS).UTC()
if pb.CreatedAt != nil && !pb.CreatedAt.AsTime().IsZero() {
c := pb.CreatedAt.AsTime()
createdAt = &c
}
var contacts *[]string
Expand Down Expand Up @@ -344,8 +344,8 @@ func PBToAuthz(pb *corepb.Authorization) (core.Authorization, error) {
challs[i] = chall
}
var expires *time.Time
if pb.ExpiresNS != 0 {
c := time.Unix(0, pb.ExpiresNS).UTC()
if pb.Expires != nil && !pb.Expires.AsTime().IsZero() {
c := pb.Expires.AsTime()
expires = &c
}
authz := core.Authorization{
Expand Down Expand Up @@ -396,8 +396,8 @@ func PBToCert(pb *corepb.Certificate) core.Certificate {
Serial: pb.Serial,
Digest: pb.Digest,
DER: pb.Der,
Issued: time.Unix(0, pb.IssuedNS),
Expires: time.Unix(0, pb.ExpiresNS),
Issued: pb.Issued.AsTime(),
Expires: pb.Expires.AsTime(),
}
}

Expand All @@ -423,11 +423,11 @@ func PBToCertStatus(pb *corepb.CertificateStatus) core.CertificateStatus {
return core.CertificateStatus{
Serial: pb.Serial,
Status: core.OCSPStatus(pb.Status),
OCSPLastUpdated: time.Unix(0, pb.OcspLastUpdatedNS),
RevokedDate: time.Unix(0, pb.RevokedDateNS),
OCSPLastUpdated: pb.OcspLastUpdated.AsTime(),
RevokedDate: pb.RevokedDate.AsTime(),
RevokedReason: revocation.Reason(pb.RevokedReason),
LastExpirationNagSent: time.Unix(0, pb.LastExpirationNagSentNS),
NotAfter: time.Unix(0, pb.NotAfterNS),
LastExpirationNagSent: pb.LastExpirationNagSent.AsTime(),
NotAfter: pb.NotAfter.AsTime(),
IsExpired: pb.IsExpired,
IssuerNameID: pb.IssuerID,
}
Expand Down
2 changes: 1 addition & 1 deletion grpc/pb-marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func TestAuthz(t *testing.T) {
}

func TestCert(t *testing.T) {
now := time.Now().Round(0)
now := time.Now().Round(0).UTC()
cert := core.Certificate{
RegistrationID: 1,
Serial: "serial",
Expand Down