diff --git a/pkg/goldpinger/pinger.go b/pkg/goldpinger/pinger.go index 6b06e3b..e83cd1e 100644 --- a/pkg/goldpinger/pinger.go +++ b/pkg/goldpinger/pinger.go @@ -86,6 +86,7 @@ func (p *Pinger) getClient() (*apiclient.Goldpinger, error) { p.resultsChan <- PingAllPodsResult{ podName: p.pod.Name, podResult: models.PodResult{ + PingTime: strfmt.DateTime(time.Now()), PodIP: p.podIPv4, HostIP: p.hostIPv4, OK: &OK, @@ -124,6 +125,7 @@ func (p *Pinger) Ping() { p.resultsChan <- PingAllPodsResult{ podName: p.pod.Name, podResult: models.PodResult{ + PingTime: strfmt.DateTime(start), PodIP: p.podIPv4, HostIP: p.hostIPv4, OK: &OK, @@ -137,6 +139,7 @@ func (p *Pinger) Ping() { p.resultsChan <- PingAllPodsResult{ podName: p.pod.Name, podResult: models.PodResult{ + PingTime: strfmt.DateTime(start), PodIP: p.podIPv4, HostIP: p.hostIPv4, OK: &OK, diff --git a/pkg/models/pod_result.go b/pkg/models/pod_result.go index ea5b553..589df02 100644 --- a/pkg/models/pod_result.go +++ b/pkg/models/pod_result.go @@ -24,6 +24,10 @@ type PodResult struct { // o k OK *bool `json:"OK,omitempty"` + // ping time + // Format: date-time + PingTime strfmt.DateTime `json:"PingTime,omitempty"` + // pod IP // Format: ipv4 PodIP strfmt.IPv4 `json:"PodIP,omitempty"` @@ -49,6 +53,10 @@ func (m *PodResult) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validatePingTime(formats); err != nil { + res = append(res, err) + } + if err := m.validatePodIP(formats); err != nil { res = append(res, err) } @@ -76,6 +84,19 @@ func (m *PodResult) validateHostIP(formats strfmt.Registry) error { return nil } +func (m *PodResult) validatePingTime(formats strfmt.Registry) error { + + if swag.IsZero(m.PingTime) { // not required + return nil + } + + if err := validate.FormatOf("PingTime", "body", "date-time", m.PingTime.String(), formats); err != nil { + return err + } + + return nil +} + func (m *PodResult) validatePodIP(formats strfmt.Registry) error { if swag.IsZero(m.PodIP) { // not required diff --git a/pkg/restapi/embedded_spec.go b/pkg/restapi/embedded_spec.go index b37bc1a..bc2d282 100644 --- a/pkg/restapi/embedded_spec.go +++ b/pkg/restapi/embedded_spec.go @@ -259,6 +259,10 @@ func init() { "type": "boolean", "default": false }, + "PingTime": { + "type": "string", + "format": "date-time" + }, "PodIP": { "type": "string", "format": "ipv4" @@ -527,6 +531,10 @@ func init() { "type": "boolean", "default": false }, + "PingTime": { + "type": "string", + "format": "date-time" + }, "PodIP": { "type": "string", "format": "ipv4" diff --git a/swagger.yml b/swagger.yml index 9f8d955..fd1dfd3 100644 --- a/swagger.yml +++ b/swagger.yml @@ -37,6 +37,9 @@ definitions: OK: type: boolean default: false + PingTime: + format: date-time + type: string PodIP: type: string format: ipv4