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

#UPLOAD-1826 update all date formats to RFC3339Nano #538

Merged
merged 1 commit into from
Oct 22, 2024
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
2 changes: 1 addition & 1 deletion upload-server/internal/appconfig/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion upload-server/internal/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions upload-server/internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion upload-server/pkg/azureinspector/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion upload-server/pkg/fileinspector/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cdcgov/data-exchange-upload/upload-server/pkg/info"
"os"
"path/filepath"
"time"
)

type FileSystemUploadInspector struct {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions upload-server/pkg/fileinspector/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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")
}
4 changes: 2 additions & 2 deletions upload-server/pkg/reports/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion upload-server/pkg/s3inspector/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Loading