diff options
author | 2018-01-03 19:11:28 +0800 | |
---|---|---|
committer | 2018-01-03 11:11:28 +0000 | |
commit | 7fe5b0bb1f34735859d611e170fa8709adac73ea (patch) | |
tree | 9757c7e2a724a0e1ed885ef7bca470c56075e4a6 /vendor/github.com/go-openapi/strfmt/date.go | |
parent | bce7f5fbecbc68950dfb2b96b5f85d03a8bf07eb (diff) | |
download | coredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.tar.gz coredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.tar.zst coredns-7fe5b0bb1f34735859d611e170fa8709adac73ea.zip |
Update k8s client-go to v6.0.0 (#1340)
* Update k8s client-go to v6.0.0
This fix updates k8s client-go to v6.0.0 as CoreDNS is supported
in 1.9 and v6.0.0 is the recommended version.
There are quite some massive changes that need to be made:
1. k8s.io/client-go/pkg/api/v1 has been changed to k8s.io/api/v1 (repo changed from `client-go` to `api`)
2. kubernetes.Clientset adds one extra layer, so that `kubernetes.Clientset.Services()` and like has been changed to `kubernetes.Clientset.CoreV1().Services()`
Also, we have to stick with specific commits of `k8s.io/apimachinery` and the newly introduced `k8s.io/api`
because go dep still could not figure out the right version to fetch.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* Update vendor with `dep ensure --update` and `dep prune`
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'vendor/github.com/go-openapi/strfmt/date.go')
-rw-r--r-- | vendor/github.com/go-openapi/strfmt/date.go | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/vendor/github.com/go-openapi/strfmt/date.go b/vendor/github.com/go-openapi/strfmt/date.go deleted file mode 100644 index 24a11db26..000000000 --- a/vendor/github.com/go-openapi/strfmt/date.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package strfmt - -import ( - "database/sql/driver" - "errors" - "fmt" - "regexp" - "time" - - "gopkg.in/mgo.v2/bson" - - "github.com/mailru/easyjson/jlexer" - "github.com/mailru/easyjson/jwriter" -) - -func init() { - d := Date{} - Default.Add("date", &d, IsDate) -} - -// IsDate returns true when the string is a valid date -func IsDate(str string) bool { - matches := rxDate.FindAllStringSubmatch(str, -1) - if len(matches) == 0 || len(matches[0]) == 0 { - return false - } - m := matches[0] - return !(m[2] < "01" || m[2] > "12" || m[3] < "01" || m[3] > "31") -} - -const ( - // RFC3339FullDate represents a full-date as specified by RFC3339 - // See: http://goo.gl/xXOvVd - RFC3339FullDate = "2006-01-02" - // DatePattern pattern to match for the date format from http://tools.ietf.org/html/rfc3339#section-5.6 - DatePattern = `^([0-9]{4})-([0-9]{2})-([0-9]{2})` -) - -var ( - rxDate = regexp.MustCompile(DatePattern) -) - -// Date represents a date from the API -// -// swagger:strfmt date -type Date time.Time - -// String converts this date into a string -func (d Date) String() string { - return time.Time(d).Format(RFC3339FullDate) -} - -// UnmarshalText parses a text representation into a date type -func (d *Date) UnmarshalText(text []byte) error { - if len(text) == 0 { - return nil - } - dd, err := time.Parse(RFC3339FullDate, string(text)) - if err != nil { - return err - } - *d = Date(dd) - return nil -} - -// MarshalText serializes this date type to string -func (d Date) MarshalText() ([]byte, error) { - return []byte(d.String()), nil -} - -// Scan scans a Date value from database driver type. -func (d *Date) Scan(raw interface{}) error { - switch v := raw.(type) { - case []byte: - return d.UnmarshalText(v) - case string: - return d.UnmarshalText([]byte(v)) - case time.Time: - *d = Date(v) - return nil - case nil: - *d = Date{} - return nil - default: - return fmt.Errorf("cannot sql.Scan() strfmt.Date from: %#v", v) - } -} - -// Value converts Date to a primitive value ready to written to a database. -func (d Date) Value() (driver.Value, error) { - return driver.Value(d.String()), nil -} - -func (t Date) MarshalJSON() ([]byte, error) { - var w jwriter.Writer - t.MarshalEasyJSON(&w) - return w.BuildBytes() -} - -func (t Date) MarshalEasyJSON(w *jwriter.Writer) { - w.String(time.Time(t).Format(RFC3339FullDate)) -} - -func (t *Date) UnmarshalJSON(data []byte) error { - l := jlexer.Lexer{Data: data} - t.UnmarshalEasyJSON(&l) - return l.Error() -} - -func (t *Date) UnmarshalEasyJSON(in *jlexer.Lexer) { - if data := in.String(); in.Ok() { - tt, err := time.Parse(RFC3339FullDate, data) - if err != nil { - in.AddError(err) - return - } - *t = Date(tt) - } -} - -func (t *Date) GetBSON() (interface{}, error) { - return bson.M{"data": t.String()}, nil -} - -func (t *Date) SetBSON(raw bson.Raw) error { - var m bson.M - if err := raw.Unmarshal(&m); err != nil { - return err - } - - if data, ok := m["data"].(string); ok { - rd, err := time.Parse(RFC3339FullDate, data) - *t = Date(rd) - return err - } - - return errors.New("couldn't unmarshal bson raw value as Duration") -} |