Skip to content

Commit 95e3d95

Browse files
committed
HMS-5390: omit null values in upload response
1 parent 5a7601d commit 95e3d95

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

pkg/api/uploads.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ type UploadChunkRequest struct {
2525
}
2626

2727
type UploadResponse struct {
28-
ArtifactHref *string `json:"artifact_href"` // Artifact href if one exists (on create only)
29-
CompletedChecksums []string `json:"completed_checksums"` // A list of already completed checksums
30-
UploadUuid *string `json:"upload_uuid"` // Upload UUID
31-
Created *time.Time `json:"created"` // Timestamp of creation
32-
LastUpdated *time.Time `json:"last_updated"` // Timestamp of last update
33-
Size int64 `json:"size"` // Size of the upload in bytes
34-
Completed *time.Time `json:"completed,omitempty"` // Timestamp when upload is committed
28+
ArtifactHref *string `json:"artifact_href,omitempty"` // Artifact href if one exists (on create only)
29+
CompletedChecksums []string `json:"completed_checksums,omitempty"` // A list of already completed checksums
30+
UploadUuid *string `json:"upload_uuid"` // Upload UUID
31+
Created *time.Time `json:"created,omitempty"` // Timestamp of creation
32+
LastUpdated *time.Time `json:"last_updated,omitempty"` // Timestamp of last update
33+
Size int64 `json:"size"` // Size of the upload in bytes
34+
Completed *time.Time `json:"completed,omitempty"` // Timestamp when upload is committed
3535

3636
}

pkg/handler/repositories.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ func (rh *RepositoryHandler) createUpload(c echo.Context) error {
609609
if artifactHref != nil {
610610
resp := &api.UploadResponse{
611611
ArtifactHref: artifactHref,
612+
Size: req.Size,
612613
}
613614

614615
return c.JSON(http.StatusCreated, resp)
@@ -623,16 +624,14 @@ func (rh *RepositoryHandler) createUpload(c echo.Context) error {
623624
if existingUUID != "" {
624625
resp := &api.UploadResponse{
625626
UploadUuid: &existingUUID,
626-
Size: req.ChunkSize,
627+
Size: req.Size,
627628
CompletedChecksums: completedChunks,
628-
ArtifactHref: utils.Ptr(""),
629629
}
630630

631631
return c.JSON(http.StatusCreated, resp)
632632
}
633633

634634
pulpResp, err := ph.createUploadInternal(c, req)
635-
636635
if err != nil {
637636
return err
638637
}
@@ -643,13 +642,11 @@ func (rh *RepositoryHandler) createUpload(c echo.Context) error {
643642
}
644643

645644
resp := &api.UploadResponse{
646-
UploadUuid: &uploadUuid,
647-
Created: pulpResp.PulpCreated,
648-
LastUpdated: pulpResp.PulpLastUpdated,
649-
Size: pulpResp.Size,
650-
Completed: pulpResp.Completed,
651-
ArtifactHref: utils.Ptr(""),
652-
CompletedChecksums: make([]string, 0),
645+
UploadUuid: &uploadUuid,
646+
Created: pulpResp.PulpCreated,
647+
LastUpdated: pulpResp.PulpLastUpdated,
648+
Size: pulpResp.Size,
649+
Completed: pulpResp.Completed,
653650
}
654651

655652
return c.JSON(http.StatusCreated, resp)

0 commit comments

Comments
 (0)