Skip to content

Commit

Permalink
Merge pull request #582 from equinor/return-null-for-empty-time
Browse files Browse the repository at this point in the history
send nullable time instead of empty string
  • Loading branch information
emirgens committed Jan 3, 2024
2 parents 0034fdd + 73765f9 commit 84413c4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: go mod download
- name: Run Tests
run: go test -cover `go list ./... | grep -v 'pkg/client'`
run: go test -cover `go list ./...`

test-swagger:
name: Test Swagger
Expand Down
2 changes: 1 addition & 1 deletion api/jobs/job_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (s *JobHandlerTestSuite) Test_GetApplicationJob() {
//nolint:staticcheck // SA1019 we want to make sure that Components is populated for backward compatibility (at least for a while)
s.ElementsMatch(slice.PointersOf(expectedComponents), actualJob.Components)
expectedSteps := []jobModels.Step{
{Name: step1Name, PodName: step1Pod, Status: string(step1Condition), Started: radixutils.FormatTime(&step1Started), Ended: radixutils.FormatTime(&step1Ended), Components: step1Components},
{Name: step1Name, PodName: step1Pod, Status: string(step1Condition), Started: &step1Started.Time, Ended: &step1Ended.Time, Components: step1Components},
{Name: step2Name},
}
s.ElementsMatch(expectedSteps, actualJob.Steps)
Expand Down
5 changes: 3 additions & 2 deletions api/jobs/models/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,16 @@ func GetJobFromRadixJob(job *radixv1.RadixJob, jobDeployments []*deploymentModel
// GetJobStepsFromRadixJob Gets the steps from a Radix job
func GetJobStepsFromRadixJob(job *radixv1.RadixJob) []Step {
var steps []Step

for _, jobStep := range job.Status.Steps {
step := Step{
Name: jobStep.Name,
Status: string(jobStep.Condition),
Started: radixutils.FormatTime(jobStep.Started),
Ended: radixutils.FormatTime(jobStep.Ended),
PodName: jobStep.PodName,
Components: jobStep.Components,
}
if jobStep.Started != nil {step.Started = &jobStep.Started.Time}
if jobStep.Ended != nil {step.Ended = &jobStep.Ended.Time}

steps = append(steps, step)
}
Expand Down
8 changes: 6 additions & 2 deletions api/jobs/models/step.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models

import "time"

// Step holds general information about job step
// swagger:model Step
type Step struct {
Expand All @@ -19,14 +21,16 @@ type Step struct {
// Started timestamp
//
// required: false
// swagger:strfmt date-time
// example: 2006-01-02T15:04:05Z
Started string `json:"started"`
Started *time.Time `json:"started"`

// Ended timestamp
//
// required: false
// swagger:strfmt date-time
// example: 2006-01-02T15:04:05Z
Ended string `json:"ended"`
Ended *time.Time `json:"ended"`

// Pod name
//
Expand Down
8 changes: 4 additions & 4 deletions swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7330,8 +7330,8 @@
"ended": {
"description": "Ended timestamp",
"type": "string",
"x-go-name": "Ended",
"example": "2006-01-02T15:04:05Z"
"format": "date-time",
"x-go-name": "Ended"
},
"name": {
"description": "Name of the step",
Expand All @@ -7342,8 +7342,8 @@
"started": {
"description": "Started timestamp",
"type": "string",
"x-go-name": "Started",
"example": "2006-01-02T15:04:05Z"
"format": "date-time",
"x-go-name": "Started"
},
"status": {
"description": "Status of the step",
Expand Down

0 comments on commit 84413c4

Please sign in to comment.