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

send nullable time instead of empty string #582

Merged
merged 4 commits into from
Jan 3, 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 .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
Loading