summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-06-24 21:29:31 +0200
committerValentin Rothberg <rothberg@redhat.com>2019-06-24 21:29:31 +0200
commit2388222e98462fdbbe44f3e091b2b79d80956a9a (patch)
tree17078d861c20a3e48b19c750c6864c5f59248386 /vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
parenta1a4a75abee2c381483a218e1660621ee416ef7c (diff)
downloadpodman-2388222e98462fdbbe44f3e091b2b79d80956a9a.tar.gz
podman-2388222e98462fdbbe44f3e091b2b79d80956a9a.tar.bz2
podman-2388222e98462fdbbe44f3e091b2b79d80956a9a.zip
update dependencies
Ran a `go get -u` and bumped K8s deps to 1.15.0. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
index 5041954f7..fe510ed9e 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
@@ -20,7 +20,7 @@ import (
"encoding/json"
"time"
- "github.com/google/gofuzz"
+ fuzz "github.com/google/gofuzz"
)
// Time is a wrapper around time.Time which supports correct
@@ -41,11 +41,6 @@ func (t *Time) DeepCopyInto(out *Time) {
*out = *t
}
-// String returns the representation of the time.
-func (t Time) String() string {
- return t.Time.String()
-}
-
// NewTime returns a wrapped instance of the provided time
func NewTime(time time.Time) Time {
return Time{time}
@@ -72,7 +67,10 @@ func (t *Time) IsZero() bool {
// Before reports whether the time instant t is before u.
func (t *Time) Before(u *Time) bool {
- return t.Time.Before(u.Time)
+ if t != nil && u != nil {
+ return t.Time.Before(u.Time)
+ }
+ return false
}
// Equal reports whether the time instant t is equal to u.
@@ -106,7 +104,10 @@ func (t *Time) UnmarshalJSON(b []byte) error {
}
var str string
- json.Unmarshal(b, &str)
+ err := json.Unmarshal(b, &str)
+ if err != nil {
+ return err
+ }
pt, err := time.Parse(time.RFC3339, str)
if err != nil {
@@ -144,8 +145,12 @@ func (t Time) MarshalJSON() ([]byte, error) {
// Encode unset/nil objects as JSON's "null".
return []byte("null"), nil
}
-
- return json.Marshal(t.UTC().Format(time.RFC3339))
+ buf := make([]byte, 0, len(time.RFC3339)+2)
+ buf = append(buf, '"')
+ // time cannot contain non escapable JSON characters
+ buf = t.UTC().AppendFormat(buf, time.RFC3339)
+ buf = append(buf, '"')
+ return buf, nil
}
// OpenAPISchemaType is used by the kube-openapi generator when constructing