From 36dbcc3d02895f28f629e5ddfc216625a4f99a71 Mon Sep 17 00:00:00 2001 From: Marcia Schulman Date: Mon, 21 Oct 2024 13:54:09 -0400 Subject: [PATCH] update all date formats to RFC3339Nano --- upload-server/internal/appconfig/appconfig.go | 2 +- upload-server/internal/metadata/metadata.go | 2 +- upload-server/internal/ui/ui.go | 9 ++++++--- upload-server/pkg/azureinspector/azure.go | 3 ++- upload-server/pkg/fileinspector/file.go | 3 ++- upload-server/pkg/fileinspector/status.go | 6 +++--- upload-server/pkg/reports/builder.go | 4 ++-- upload-server/pkg/s3inspector/s3.go | 3 ++- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/upload-server/internal/appconfig/appconfig.go b/upload-server/internal/appconfig/appconfig.go index 6ed5f0c5f..dd1e00a87 100644 --- a/upload-server/internal/appconfig/appconfig.go +++ b/upload-server/internal/appconfig/appconfig.go @@ -102,7 +102,7 @@ func (conf *AppConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) { System: "DEX", DexProduct: "UPLOAD API", DexApp: "upload server", - ServerTime: time.Now().Format(time.RFC3339), + ServerTime: time.Now().Format(time.RFC3339Nano), }) // .jsonResp if err != nil { errMsg := "error marshal json for root response" diff --git a/upload-server/internal/metadata/metadata.go b/upload-server/internal/metadata/metadata.go index c5a42f5ba..3cd715150 100644 --- a/upload-server/internal/metadata/metadata.go +++ b/upload-server/internal/metadata/metadata.go @@ -436,7 +436,7 @@ func WithPreCreateManifestTransforms(event handler.HookEvent, resp hooks.HookRes tuid := Uid() resp.ChangeFileInfo.ID = tuid - timestamp := time.Now().UTC().Format(time.RFC3339) + timestamp := time.Now().UTC().Format(time.RFC3339Nano) logger.Info("adding global timestamp", "timestamp", timestamp) manifest := event.Upload.MetaData diff --git a/upload-server/internal/ui/ui.go b/upload-server/internal/ui/ui.go index b3f1145a3..143a7b0d8 100644 --- a/upload-server/internal/ui/ui.go +++ b/upload-server/internal/ui/ui.go @@ -52,10 +52,13 @@ func FormatDateTime(dateTimeString string) string { return "" } - date, err := time.Parse(time.RFC3339, dateTimeString) + date, err := time.Parse(time.RFC3339Nano, dateTimeString) if err != nil { - return "" + date, err = time.Parse(time.RFC3339, dateTimeString) + if err != nil { + return "" + } } return date.UTC().Format(time.RFC850) @@ -128,7 +131,7 @@ func GetRouter(uploadUrl string, infoUrl string) *mux.Router { dataStreamRoute := r.FormValue("data_stream_route") configId := v2.ConfigIdentification{ - DataStreamID: dataStream, + DataStreamID: dataStream, DataStreamRoute: dataStreamRoute, } diff --git a/upload-server/pkg/azureinspector/azure.go b/upload-server/pkg/azureinspector/azure.go index 6141f42f1..d7434a0a1 100644 --- a/upload-server/pkg/azureinspector/azure.go +++ b/upload-server/pkg/azureinspector/azure.go @@ -6,6 +6,7 @@ import ( "errors" "io" "net/http" + "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container" @@ -59,7 +60,7 @@ func (aui *AzureUploadInspector) InspectUploadedFile(c context.Context, id strin } uploadedFileInfo := map[string]any{ - "updated_at": propertiesResponse.LastModified, + "updated_at": propertiesResponse.LastModified.Format(time.RFC3339Nano), "size_bytes": propertiesResponse.ContentLength, } diff --git a/upload-server/pkg/fileinspector/file.go b/upload-server/pkg/fileinspector/file.go index fa4e7a16b..3e0a5a232 100644 --- a/upload-server/pkg/fileinspector/file.go +++ b/upload-server/pkg/fileinspector/file.go @@ -7,6 +7,7 @@ import ( "github.com/cdcgov/data-exchange-upload/upload-server/pkg/info" "os" "path/filepath" + "time" ) type FileSystemUploadInspector struct { @@ -48,7 +49,7 @@ func (fsui *FileSystemUploadInspector) InspectUploadedFile(c context.Context, id return nil, errors.Join(err, info.ErrNotFound) } uploadedFileInfo := map[string]any{ - "updated_at": fi.ModTime(), + "updated_at": fi.ModTime().Format(time.RFC3339Nano), "size_bytes": fi.Size(), } return uploadedFileInfo, nil diff --git a/upload-server/pkg/fileinspector/status.go b/upload-server/pkg/fileinspector/status.go index ce183e971..a1ba05a87 100644 --- a/upload-server/pkg/fileinspector/status.go +++ b/upload-server/pkg/fileinspector/status.go @@ -71,7 +71,7 @@ func (fsusi *FileSystemUploadStatusInspector) InspectFileUploadStatus(ctx contex // if there are no errors, then the upload-complete file has been created // we can stop here and set the status to Complete and set the last chunk received // to the time the file was created, no other calculations are needed - lastChunkReceived := uploadCompletedFileInfo.ModTime().UTC().Format(time.RFC3339) + lastChunkReceived := uploadCompletedFileInfo.ModTime().UTC().Format(time.RFC3339Nano) return info.FileUploadStatus{ Status: info.UploadComplete, LastChunkReceived: lastChunkReceived, @@ -107,7 +107,7 @@ func (fsusi *FileSystemUploadStatusInspector) InspectFileUploadStatus(ctx contex uploadStartedModTime := uploadStartedFileInfo.ModTime() uploadStatusModTime := uploadStatusReportFileInfo.ModTime() - lastChunkReceived := uploadStatusModTime.UTC().Format(time.RFC3339) + lastChunkReceived := uploadStatusModTime.UTC().Format(time.RFC3339Nano) if uploadStartedModTime.Unix() == uploadStatusModTime.Unix() { // when the file upload is initiated the upload-started and upload-status reports @@ -128,5 +128,5 @@ func (fsusi *FileSystemUploadStatusInspector) InspectFileUploadStatus(ctx contex }, nil } - return info.FileUploadStatus{}, errors.New("Unable to determine the status of the upload") + return info.FileUploadStatus{}, errors.New("unable to determine the status of the upload") } diff --git a/upload-server/pkg/reports/builder.go b/upload-server/pkg/reports/builder.go index 2870cc63c..9e8d7023a 100644 --- a/upload-server/pkg/reports/builder.go +++ b/upload-server/pkg/reports/builder.go @@ -250,8 +250,8 @@ func (b *ReportBuilder[T]) Build() *Report { Service: "UPLOAD API", Version: fmt.Sprintf("%s_%s", version.LatestReleaseVersion, version.GitShortSha), Status: b.Status, - StartProcessTime: b.StartTime.Format(time.RFC3339), - EndProcessTime: b.EndTime.Format(time.RFC3339), + StartProcessTime: b.StartTime.Format(time.RFC3339Nano), + EndProcessTime: b.EndTime.Format(time.RFC3339Nano), }, Content: b.Content, } diff --git a/upload-server/pkg/s3inspector/s3.go b/upload-server/pkg/s3inspector/s3.go index 3f18b0554..81c059a93 100644 --- a/upload-server/pkg/s3inspector/s3.go +++ b/upload-server/pkg/s3inspector/s3.go @@ -6,6 +6,7 @@ import ( "errors" "io" "strings" + "time" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/types" @@ -73,7 +74,7 @@ func (sui *S3UploadInspector) InspectUploadedFile(c context.Context, id string) } return map[string]any{ - "updated_at": output.LastModified, + "updated_at": output.LastModified.Format(time.RFC3339Nano), "size_bytes": output.ObjectSize, }, nil }