diff --git a/client/operations/get_workflow_status_responses.go b/client/operations/get_workflow_status_responses.go index c3bf639..a75a429 100644 --- a/client/operations/get_workflow_status_responses.go +++ b/client/operations/get_workflow_status_responses.go @@ -689,6 +689,9 @@ type GetWorkflowStatusOKBodyProgress struct { // run started at RunStartedAt *string `json:"run_started_at,omitempty"` + // run stopped at + RunStoppedAt *string `json:"run_stopped_at,omitempty"` + // running Running *GetWorkflowStatusOKBodyProgressRunning `json:"running,omitempty"` diff --git a/client/operations/get_workflows_responses.go b/client/operations/get_workflows_responses.go index 3ecf930..ea0c7f7 100644 --- a/client/operations/get_workflows_responses.go +++ b/client/operations/get_workflows_responses.go @@ -860,6 +860,9 @@ type GetWorkflowsOKBodyItemsItems0Progress struct { // run started at RunStartedAt *string `json:"run_started_at,omitempty"` + // run stopped at + RunStoppedAt *string `json:"run_stopped_at,omitempty"` + // running Running *GetWorkflowsOKBodyItemsItems0ProgressRunning `json:"running,omitempty"` diff --git a/client/operations/launch_responses.go b/client/operations/launch_responses.go index 717c552..48ba549 100644 --- a/client/operations/launch_responses.go +++ b/client/operations/launch_responses.go @@ -401,22 +401,125 @@ swagger:model LaunchOKBody type LaunchOKBody struct { // message - Message string `json:"message,omitempty"` + // Required: true + Message *string `json:"message"` + + // validation warnings + ValidationWarnings *LaunchOKBodyValidationWarnings `json:"validation_warnings,omitempty"` // workflow id - WorkflowID string `json:"workflow_id,omitempty"` + // Required: true + WorkflowID *string `json:"workflow_id"` // workflow name - WorkflowName string `json:"workflow_name,omitempty"` + // Required: true + WorkflowName *string `json:"workflow_name"` } // Validate validates this launch o k body func (o *LaunchOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateMessage(formats); err != nil { + res = append(res, err) + } + + if err := o.validateValidationWarnings(formats); err != nil { + res = append(res, err) + } + + if err := o.validateWorkflowID(formats); err != nil { + res = append(res, err) + } + + if err := o.validateWorkflowName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *LaunchOKBody) validateMessage(formats strfmt.Registry) error { + + if err := validate.Required("launchOK"+"."+"message", "body", o.Message); err != nil { + return err + } + + return nil +} + +func (o *LaunchOKBody) validateValidationWarnings(formats strfmt.Registry) error { + if swag.IsZero(o.ValidationWarnings) { // not required + return nil + } + + if o.ValidationWarnings != nil { + if err := o.ValidationWarnings.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("launchOK" + "." + "validation_warnings") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("launchOK" + "." + "validation_warnings") + } + return err + } + } + + return nil +} + +func (o *LaunchOKBody) validateWorkflowID(formats strfmt.Registry) error { + + if err := validate.Required("launchOK"+"."+"workflow_id", "body", o.WorkflowID); err != nil { + return err + } + return nil } -// ContextValidate validates this launch o k body based on context it is used +func (o *LaunchOKBody) validateWorkflowName(formats strfmt.Registry) error { + + if err := validate.Required("launchOK"+"."+"workflow_name", "body", o.WorkflowName); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this launch o k body based on the context it is used func (o *LaunchOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateValidationWarnings(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *LaunchOKBody) contextValidateValidationWarnings(ctx context.Context, formats strfmt.Registry) error { + + if o.ValidationWarnings != nil { + + if swag.IsZero(o.ValidationWarnings) { // not required + return nil + } + + if err := o.ValidationWarnings.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("launchOK" + "." + "validation_warnings") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("launchOK" + "." + "validation_warnings") + } + return err + } + } + return nil } @@ -437,3 +540,41 @@ func (o *LaunchOKBody) UnmarshalBinary(b []byte) error { *o = res return nil } + +/* +LaunchOKBodyValidationWarnings Dictionary of validation warnings, if any. Each key is a property that was not correctly validated. +swagger:model LaunchOKBodyValidationWarnings +*/ +type LaunchOKBodyValidationWarnings struct { + + // additional properties + AdditionalProperties []string `json:"additional_properties"` +} + +// Validate validates this launch o k body validation warnings +func (o *LaunchOKBodyValidationWarnings) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this launch o k body validation warnings based on context it is used +func (o *LaunchOKBodyValidationWarnings) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *LaunchOKBodyValidationWarnings) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *LaunchOKBodyValidationWarnings) UnmarshalBinary(b []byte) error { + var res LaunchOKBodyValidationWarnings + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/cmd/list.go b/cmd/list.go index 4025302..5fb7625 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -255,6 +255,7 @@ func displayListPayload( value, err = workflows.GetDuration( workflow.Progress.RunStartedAt, workflow.Progress.RunFinishedAt, + workflow.Progress.RunStoppedAt, ) if err != nil { return err diff --git a/cmd/status.go b/cmd/status.go index 2ad27a3..1856fb2 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -153,6 +153,7 @@ func displayStatusPayload( value, err = workflows.GetDuration( p.Progress.RunStartedAt, p.Progress.RunFinishedAt, + p.Progress.RunStoppedAt, ) if err != nil { return err diff --git a/pkg/workflows/utils.go b/pkg/workflows/utils.go index df3a973..3be8c54 100644 --- a/pkg/workflows/utils.go +++ b/pkg/workflows/utils.go @@ -27,7 +27,7 @@ func GetNameAndRunNumber(workflowName string) (string, string) { } // GetDuration calculates and returns the duration the workflow, based on the given timestamps. -func GetDuration(runStartedAt, runFinishedAt *string) (any, error) { +func GetDuration(runStartedAt, runFinishedAt *string, runStoppedAt *string) (any, error) { if runStartedAt == nil { return nil, nil } @@ -43,6 +43,11 @@ func GetDuration(runStartedAt, runFinishedAt *string) (any, error) { if err != nil { return nil, err } + } else if runStoppedAt != nil { + endTime, err = datautils.FromIsoToTimestamp(*runStoppedAt) + if err != nil { + return nil, err + } } else { endTime = time.Now() } diff --git a/pkg/workflows/utils_test.go b/pkg/workflows/utils_test.go index 1fe4660..ea70a21 100644 --- a/pkg/workflows/utils_test.go +++ b/pkg/workflows/utils_test.go @@ -45,16 +45,33 @@ func TestGetDuration(t *testing.T) { tests := map[string]struct { runStartedAt *string runFinishedAt *string + runStoppedAt *string want any wantError bool }{ "finished instantly": {runStartedAt: &curTime, runFinishedAt: &curTime, want: 0.0}, "finished in 1 second": {runStartedAt: &curTime, runFinishedAt: &future, want: 1.0}, "finished before start": {runStartedAt: &curTime, runFinishedAt: &past, want: -1.0}, - "nil arguments": {runStartedAt: nil, runFinishedAt: nil, want: nil}, - "nil start": {runStartedAt: nil, runFinishedAt: &curTime, want: nil}, - "nil finish": {runStartedAt: &curTime, runFinishedAt: nil}, - "bad start format": {runStartedAt: &badFormat, wantError: true}, + "stopped in 1 second": { + runStartedAt: &curTime, + runFinishedAt: nil, + runStoppedAt: &future, + want: 1.0, + }, + "nil arguments": { + runStartedAt: nil, + runFinishedAt: nil, + runStoppedAt: nil, + want: nil, + }, + "nil start": {runStartedAt: nil, runFinishedAt: &curTime, want: nil}, + "nil finish": {runStartedAt: &curTime, runFinishedAt: nil}, + "bad start format": {runStartedAt: &badFormat, wantError: true}, + "bad stop format": { + runStartedAt: &curTime, + runStoppedAt: &badFormat, + wantError: true, + }, "bad finish format": { runStartedAt: &curTime, runFinishedAt: &badFormat, @@ -63,7 +80,7 @@ func TestGetDuration(t *testing.T) { } for name, test := range tests { t.Run(name, func(t *testing.T) { - got, err := GetDuration(test.runStartedAt, test.runFinishedAt) + got, err := GetDuration(test.runStartedAt, test.runFinishedAt, test.runStoppedAt) if test.wantError { if err == nil { t.Errorf("Expected error, got nil")