update time format of audit log (#12629)

fixes #11522

use the format: date-time as the format of audit op_time, then it could be rendered by FF and Chrome.

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
Wang Yan 2020-07-30 17:29:25 +08:00 committed by GitHub
parent e14e6938da
commit 9ce29c9dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -1672,6 +1672,8 @@ definitions:
description: The operation against the repository in this log entry.
op_time:
type: string
format: date-time
example: '2006-01-02T15:04:05'
description: The time when this operation is triggered.
Metadata:
type: object

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/goharbor/harbor/src/common/rbac"
"github.com/goharbor/harbor/src/common/security"
"github.com/goharbor/harbor/src/common/security/local"
@ -78,7 +79,7 @@ func (a *auditlogAPI) ListAuditLogs(ctx context.Context, params auditlog.ListAud
ResourceType: log.ResourceType,
Username: log.Username,
Operation: log.Operation,
OpTime: log.OpTime.String(),
OpTime: strfmt.DateTime(log.OpTime),
})
}
return operation.NewListAuditLogsOK().

View File

@ -3,6 +3,7 @@ package handler
import (
"context"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/goharbor/harbor/src/common/rbac"
"github.com/goharbor/harbor/src/controller/project"
"github.com/goharbor/harbor/src/pkg/audit"
@ -54,7 +55,7 @@ func (a *projectAPI) GetLogs(ctx context.Context, params operation.GetLogsParams
ResourceType: log.ResourceType,
Username: log.Username,
Operation: log.Operation,
OpTime: log.OpTime.String(),
OpTime: strfmt.DateTime(log.OpTime),
})
}
return operation.NewGetLogsOK().