From 3cb27a1d42e633c9969f6fc6b246c809476bdb01 Mon Sep 17 00:00:00 2001 From: lgtm <1gtm@users.noreply.github.com> Date: Wed, 14 Oct 2020 00:28:01 -0700 Subject: [PATCH] Update Kubernetes v1.18.9 dependencies (#157) Signed-off-by: 1gtm <1gtm@appscode.com> --- go.mod | 2 +- go.sum | 4 +- .../go/encoding/json/types/array_or_int.go | 55 -- .../go/encoding/json/types/array_or_string.go | 57 -- .../go/encoding/json/types/bool_yo.go | 33 -- .../appscode/go/encoding/json/types/doc.go | 2 - .../go/encoding/json/types/int_hash.go | 193 ------- .../go/encoding/json/types/str_to_bool.go | 44 -- .../appscode/go/encoding/json/types/str_yo.go | 43 -- .../appscode/go/encoding/json/types/urlamp.go | 105 ---- .../appscode/go/encoding/json/types/urlset.go | 97 ---- vendor/github.com/appscode/go/sets/BUILD | 72 --- vendor/github.com/appscode/go/sets/README.md | 1 - vendor/github.com/appscode/go/sets/byte.go | 203 ------- vendor/github.com/appscode/go/sets/doc.go | 20 - vendor/github.com/appscode/go/sets/empty.go | 23 - vendor/github.com/appscode/go/sets/int.go | 203 ------- vendor/github.com/appscode/go/sets/int64.go | 203 ------- vendor/github.com/appscode/go/sets/string.go | 203 ------- .../appscode/go/types/convert_types.go | 501 ------------------ vendor/github.com/appscode/go/types/doc.go | 7 - vendor/kmodules.xyz/client-go/meta/hash.go | 37 +- vendor/modules.txt | 5 +- 23 files changed, 22 insertions(+), 2091 deletions(-) delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/array_or_int.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/array_or_string.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/bool_yo.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/doc.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/int_hash.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/str_to_bool.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/str_yo.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/urlamp.go delete mode 100644 vendor/github.com/appscode/go/encoding/json/types/urlset.go delete mode 100644 vendor/github.com/appscode/go/sets/BUILD delete mode 100644 vendor/github.com/appscode/go/sets/README.md delete mode 100644 vendor/github.com/appscode/go/sets/byte.go delete mode 100644 vendor/github.com/appscode/go/sets/doc.go delete mode 100644 vendor/github.com/appscode/go/sets/empty.go delete mode 100644 vendor/github.com/appscode/go/sets/int.go delete mode 100644 vendor/github.com/appscode/go/sets/int64.go delete mode 100644 vendor/github.com/appscode/go/sets/string.go delete mode 100644 vendor/github.com/appscode/go/types/convert_types.go delete mode 100644 vendor/github.com/appscode/go/types/doc.go diff --git a/go.mod b/go.mod index 34f7e8793..ee060f7f3 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( k8s.io/client-go v0.18.9 k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 k8s.io/utils v0.0.0-20200414100711-2df71ebbae66 // indirect - kmodules.xyz/client-go v0.0.0-20201011221802-3180ab67d845 + kmodules.xyz/client-go v0.0.0-20201013083546-b17c1e15f1a3 kmodules.xyz/crd-schema-fuzz v0.0.0-20200922204806-c1426cd7fcf4 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 04c0cb2a8..0eb24850a 100644 --- a/go.sum +++ b/go.sum @@ -619,8 +619,8 @@ k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOEC k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -kmodules.xyz/client-go v0.0.0-20201011221802-3180ab67d845 h1:7ytqOvrfdq5Ul5SicCyy0s1YnnBSGu33hSZaBEcTbXs= -kmodules.xyz/client-go v0.0.0-20201011221802-3180ab67d845/go.mod h1:pnRh7gtJ6ErPJQBkQeRlpD95KRtxhD4eGrYagZEU8RM= +kmodules.xyz/client-go v0.0.0-20201013083546-b17c1e15f1a3 h1:vP8h3s+JdqXQHhhmvoTgKZOtpraF4X1NxA/y4OFTn+I= +kmodules.xyz/client-go v0.0.0-20201013083546-b17c1e15f1a3/go.mod h1:pnRh7gtJ6ErPJQBkQeRlpD95KRtxhD4eGrYagZEU8RM= kmodules.xyz/crd-schema-fuzz v0.0.0-20200922204806-c1426cd7fcf4 h1:NWWv+Qju8xzHZT9hIk1+BbgQtIytNOoCU4g4vqUmh3M= kmodules.xyz/crd-schema-fuzz v0.0.0-20200922204806-c1426cd7fcf4/go.mod h1:WrO3fryNyFCgqqyWnwI89lnzWA7kN072Ehya7ELGfzE= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7 h1:uuHDyjllyzRyCIvvn0OBjiRB0SgBZGqHNYAmjR7fO50= diff --git a/vendor/github.com/appscode/go/encoding/json/types/array_or_int.go b/vendor/github.com/appscode/go/encoding/json/types/array_or_int.go deleted file mode 100644 index 9494ff1db..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/array_or_int.go +++ /dev/null @@ -1,55 +0,0 @@ -package types - -import ( - "bytes" - "encoding/json" - "errors" - "strconv" -) - -/* - GO => Json - [] => `[]` - [1] => `1` -[1, 2] => `[1,2]` -*/ -type ArrayOrInt []int - -func (m *ArrayOrInt) MarshalJSON() ([]byte, error) { - a := *m - n := len(a) - var buf bytes.Buffer - if n == 1 { - buf.WriteString(strconv.Itoa(a[0])) - } else { - buf.WriteString(`[`) - - for i := 0; i < n; i++ { - if i > 0 { - buf.WriteString(`,`) - } - buf.WriteString(strconv.Itoa(a[i])) - } - - buf.WriteString(`]`) - } - return buf.Bytes(), nil -} - -func (m *ArrayOrInt) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.ArrayOrInt: UnmarshalJSON on nil pointer") - } - var err error - if data[0] == '[' { - var a []int - err = json.Unmarshal(data, &a) - if err == nil { - *m = a - } - } else { - v, _ := strconv.Atoi(string(data)) - *m = append((*m)[0:0], v) - } - return err -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/array_or_string.go b/vendor/github.com/appscode/go/encoding/json/types/array_or_string.go deleted file mode 100644 index 10015f145..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/array_or_string.go +++ /dev/null @@ -1,57 +0,0 @@ -package types - -import ( - "bytes" - "encoding/json" - "errors" -) - -/* - GO => Json - [] => `[]` - ["a"] => `"a"` -["a", "b"] => `["a","b"]` -*/ -type ArrayOrString []string - -func (m *ArrayOrString) MarshalJSON() ([]byte, error) { - a := *m - n := len(a) - var buf bytes.Buffer - if n == 1 { - buf.WriteString(`"`) - buf.WriteString(a[0]) - buf.WriteString(`"`) - } else { - buf.WriteString(`[`) - - for i := 0; i < n; i++ { - if i > 0 { - buf.WriteString(`,`) - } - buf.WriteString(`"`) - buf.WriteString(a[i]) - buf.WriteString(`"`) - } - - buf.WriteString(`]`) - } - return buf.Bytes(), nil -} - -func (m *ArrayOrString) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.ArrayOrString: UnmarshalJSON on nil pointer") - } - var err error - if data[0] == '[' { - var a []string - err = json.Unmarshal(data, &a) - if err == nil { - *m = a - } - } else { - *m = append((*m)[0:0], string(data[1:len(data)-1])) - } - return err -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/bool_yo.go b/vendor/github.com/appscode/go/encoding/json/types/bool_yo.go deleted file mode 100644 index ea8395430..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/bool_yo.go +++ /dev/null @@ -1,33 +0,0 @@ -package types - -import ( - "errors" - "strconv" -) - -type BoolYo bool - -func (m *BoolYo) MarshalJSON() ([]byte, error) { - a := *m - if a { - return []byte(`"true"`), nil - } - return []byte(`"false"`), nil -} - -func (m *BoolYo) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.BoolYo: UnmarshalJSON on nil pointer") - } - - n := len(data) - var in string - if data[0] == '"' && data[n-1] == '"' { - in = string(data[1 : n-1]) - } else { - in = string(data) - } - v, err := strconv.ParseBool(in) - *m = BoolYo(v) - return err -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/doc.go b/vendor/github.com/appscode/go/encoding/json/types/doc.go deleted file mode 100644 index d3ca266e2..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package types provides a collection of Golang types with JSON marshaling support -package types diff --git a/vendor/github.com/appscode/go/encoding/json/types/int_hash.go b/vendor/github.com/appscode/go/encoding/json/types/int_hash.go deleted file mode 100644 index 7ad701cbb..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/int_hash.go +++ /dev/null @@ -1,193 +0,0 @@ -package types - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "reflect" - "strconv" - "strings" - - "github.com/appscode/go/types" -) - -/* -IntHash represents as int64 Generation and string Hash. It is json serialized into $. -*/ -// +k8s:openapi-gen=true -type IntHash struct { - generation int64 - hash string -} - -func ParseIntHash(v interface{}) (*IntHash, error) { - switch m := v.(type) { - case nil: - return &IntHash{}, nil - case int: - return &IntHash{generation: int64(m)}, nil - case int64: - return &IntHash{generation: m}, nil - case *int64: - return &IntHash{generation: types.Int64(m)}, nil - case IntHash: - return &m, nil - case *IntHash: - return m, nil - case string: - return parseStringIntoIntHash(m) - case *string: - return parseStringIntoIntHash(types.String(m)) - default: - return nil, fmt.Errorf("failed to parse type %s into IntHash", reflect.TypeOf(v).String()) - } -} - -func parseStringIntoIntHash(s string) (*IntHash, error) { - if s == "" { - return &IntHash{}, nil - } - - idx := strings.IndexRune(s, '$') - switch { - case idx <= 0: - return nil, errors.New("missing generation") - case idx == len(s)-1: - return nil, errors.New("missing hash") - default: - i, err := strconv.ParseInt(s[:idx], 10, 64) - if err != nil { - return nil, err - } - h := s[idx+1:] - return &IntHash{generation: i, hash: h}, nil - } -} - -func NewIntHash(i int64, h string) *IntHash { return &IntHash{generation: i, hash: h} } - -func IntHashForGeneration(i int64) *IntHash { return &IntHash{generation: i} } - -func IntHashForHash(h string) *IntHash { return &IntHash{hash: h} } - -func (m IntHash) Generation() int64 { - return m.generation -} - -func (m IntHash) Hash() string { - return m.hash -} - -// IsZero returns true if the value is nil or time is zero. -func (m *IntHash) IsZero() bool { - if m == nil { - return true - } - return m.generation == 0 && m.hash == "" -} - -func (m *IntHash) Equal(u *IntHash) bool { - if m == nil { - return u == nil - } - if u == nil { // t != nil - return false - } - if m == u { - return true - } - if m.generation == u.generation { - return m.hash == u.hash - } - return false -} - -func (m *IntHash) MatchGeneration(u *IntHash) bool { - if m == nil { - return u == nil - } - if u == nil { // t != nil - return false - } - if m == u { - return true - } - return m.generation == u.generation -} - -func (m *IntHash) DeepCopyInto(out *IntHash) { - *out = *m -} - -func (m *IntHash) DeepCopy() *IntHash { - if m == nil { - return nil - } - out := new(IntHash) - m.DeepCopyInto(out) - return out -} - -func (m IntHash) String() string { - return fmt.Sprintf(`%d$%s`, m.generation, m.hash) -} - -func (m *IntHash) MarshalJSON() ([]byte, error) { - if m == nil { - return nil, nil - } - if m.hash == "" { - return json.Marshal(m.generation) - } - return json.Marshal(m.String()) -} - -func (m *IntHash) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.IntHash: UnmarshalJSON on nil pointer") - } - - if data[0] == '"' { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - ih, err := ParseIntHash(s) - if err != nil { - return err - } - *m = *ih - return nil - } else if bytes.Equal(data, []byte("null")) { - return nil - } - - var i int64 - err := json.Unmarshal(data, &i) - if err != nil { - return err - } - m.generation = i - return nil -} - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ IntHash) OpenAPISchemaType() []string { return []string{"string"} } - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ IntHash) OpenAPISchemaFormat() string { return "" } - -// MarshalQueryParameter converts to a URL query parameter value -func (m IntHash) MarshalQueryParameter() (string, error) { - if m.IsZero() { - // Encode unset/nil objects as an empty string - return "", nil - } - return m.String(), nil -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/str_to_bool.go b/vendor/github.com/appscode/go/encoding/json/types/str_to_bool.go deleted file mode 100644 index b8fcc7169..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/str_to_bool.go +++ /dev/null @@ -1,44 +0,0 @@ -package types - -import ( - "errors" -) - -/* -StrToBool turns strings into bool when marshaled to Json. Empty strings are converted to false. Non-empty string, eg, -`"false"` will become True bool value. If already a json bool, then no change is made. - -This can be used to turn a string to bool if you have existing Json data. -*/ -type StrToBool bool - -func (m *StrToBool) MarshalJSON() ([]byte, error) { - a := *m - if a { - return []byte("true"), nil - } - return []byte("false"), nil -} - -func (m *StrToBool) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.StrToBool: UnmarshalJSON on nil pointer") - } - var err error - if data[0] == '"' { - // non empty string == true - *m = (len(data) - 2) > 0 - } else { - switch string(data) { - case "true": - *m = true - err = nil - case "false": - *m = false - err = nil - default: - err = errors.New("jsontypes.StrToBool: UnmarshalJSON failed for " + string(data)) - } - } - return err -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/str_yo.go b/vendor/github.com/appscode/go/encoding/json/types/str_yo.go deleted file mode 100644 index 1dd083f12..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/str_yo.go +++ /dev/null @@ -1,43 +0,0 @@ -package types - -import ( - "bytes" - "encoding/json" - "errors" - "unicode/utf8" -) - -/* -StrYo turns non-strings into into a string by adding quotes around it into bool, -when marshaled to Json. If input is already string, no change is done. -*/ -type StrYo string - -func (m *StrYo) UnmarshalJSON(data []byte) error { - if m == nil { - return errors.New("jsontypes.StrYo: UnmarshalJSON on nil pointer") - } - - if data[0] == '"' { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - *m = StrYo(s) - return nil - } else if data[0] == '{' { - return errors.New("jsontypes.StrYo: Expected string, found object") - } else if data[0] == '[' { - return errors.New("jsontypes.StrYo: Expected string, found array") - } else if bytes.Equal(data, []byte("null")) { - *m = "" - return nil - } - d := string(data) - if utf8.ValidString(d) { - *m = StrYo(d) - return nil - } - return errors.New("jsontypes.StrYo: Found invalid utf8 byte array") -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/urlamp.go b/vendor/github.com/appscode/go/encoding/json/types/urlamp.go deleted file mode 100644 index 49cf04d89..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/urlamp.go +++ /dev/null @@ -1,105 +0,0 @@ -package types - -import ( - "bytes" - "errors" - "fmt" - "net/url" - "reflect" - "sort" - "strconv" - "strings" -) - -type URLMap struct { - Scheme string - Hosts map[string]string - Port int -} - -func NewURLMap(scheme string, port int) *URLMap { - return &URLMap{ - Scheme: scheme, - Hosts: map[string]string{}, - Port: port, - } -} - -func (um *URLMap) Insert(name, host string) { - um.Hosts[name] = host -} - -func (um *URLMap) Delete(hosts ...string) { - for _, host := range hosts { - delete(um.Hosts, host) - } -} - -func (um *URLMap) Has(host string) bool { - _, contained := um.Hosts[host] - return contained -} - -func (um URLMap) Equal(s2 URLMap) bool { - return um.Scheme == s2.Scheme && - um.Port == s2.Port && - reflect.DeepEqual(um.Hosts, s2.Hosts) -} - -func (um *URLMap) MarshalJSON() ([]byte, error) { - var b bytes.Buffer - b.WriteRune('"') - if um != nil { - names := make([]string, 0, len(um.Hosts)) - for name := range um.Hosts { - names = append(names, name) - } - sort.Strings(names) - - for i, name := range names { - if i > 0 { - b.WriteRune(',') - } - b.WriteString(name) - b.WriteRune('=') - b.WriteString(um.Scheme) - b.WriteString("://") - b.WriteString(um.Hosts[name]) - b.WriteString(":") - b.WriteString(strconv.Itoa(um.Port)) - } - } - b.WriteRune('"') - return []byte(b.String()), nil -} - -func (um *URLMap) UnmarshalJSON(data []byte) error { - if um == nil { - return errors.New("jsontypes.URLMap: UnmarshalJSON on nil pointer") - } - - n := len(data) - if n < 2 { - return fmt.Errorf("jsontypes.URLMap: UnmarshalJSON on invalid data %s", string(data)) - } - if n == 2 && string(data) == `""` { - return nil - } - um.Hosts = map[string]string{} - - entries := strings.Split(string(data[1:n-1]), ",") - for _, entry := range entries { - parts := strings.Split(entry, "=") - if u, err := url.Parse(parts[1]); err == nil { - um.Scheme = u.Scheme - um.Hosts[parts[0]] = u.Hostname() - um.Port, err = strconv.Atoi(u.Port()) - if err != nil { - return err - } - } else { - return err - } - } - return nil -} diff --git a/vendor/github.com/appscode/go/encoding/json/types/urlset.go b/vendor/github.com/appscode/go/encoding/json/types/urlset.go deleted file mode 100644 index eacaa896a..000000000 --- a/vendor/github.com/appscode/go/encoding/json/types/urlset.go +++ /dev/null @@ -1,97 +0,0 @@ -package types - -import ( - "errors" - "fmt" - "net/url" - "sort" - "strconv" - "strings" - - "bytes" - - "github.com/appscode/go/sets" -) - -type URLSet struct { - Scheme string - Hosts sets.String - Port int -} - -func NewURLSet(scheme string, port int) *URLSet { - return &URLSet{ - Scheme: scheme, - Hosts: sets.NewString(), - Port: port, - } -} - -func (us *URLSet) Insert(hosts ...string) { - us.Hosts.Insert(hosts...) -} - -func (us *URLSet) Delete(hosts ...string) { - us.Hosts.Delete(hosts...) -} - -func (us *URLSet) Has(host string) bool { - return us.Hosts.Has(host) -} - -func (s1 URLSet) Equal(s2 URLSet) bool { - return s1.Scheme == s2.Scheme && - s1.Port == s2.Port && - s1.Hosts.Equal(s2.Hosts) -} - -func (us *URLSet) MarshalJSON() ([]byte, error) { - var b bytes.Buffer - b.WriteRune('"') - if us != nil { - urls := us.Hosts.List() - sort.Strings(urls) - for i, h := range urls { - if i > 0 { - b.WriteRune(',') - } - b.WriteString(us.Scheme) - b.WriteString("://") - b.WriteString(h) - b.WriteString(":") - b.WriteString(strconv.Itoa(us.Port)) - } - } - b.WriteRune('"') - return []byte(b.String()), nil -} - -func (us *URLSet) UnmarshalJSON(data []byte) error { - if us == nil { - return errors.New("jsontypes.URLSet: UnmarshalJSON on nil pointer") - } - - n := len(data) - if n < 2 { - return fmt.Errorf("jsontypes.URLSet: UnmarshalJSON on invalid data %s", string(data)) - } - if n == 2 && string(data) == `""` { - return nil - } - us.Hosts = sets.NewString() - - urls := strings.Split(string(data[1:n-1]), ",") - for _, rawurl := range urls { - if u, err := url.Parse(rawurl); err == nil { - us.Scheme = u.Scheme - us.Hosts.Insert(u.Hostname()) - us.Port, err = strconv.Atoi(u.Port()) - if err != nil { - return err - } - } else { - return err - } - } - return nil -} diff --git a/vendor/github.com/appscode/go/sets/BUILD b/vendor/github.com/appscode/go/sets/BUILD deleted file mode 100644 index 5a6175ad4..000000000 --- a/vendor/github.com/appscode/go/sets/BUILD +++ /dev/null @@ -1,72 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("@io_kubernetes_build//defs:go.bzl", "go_genrule") -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) - -go_library( - name = "go_default_library", - srcs = [ - "byte.go", - "doc.go", - "empty.go", - "int.go", - "int64.go", - "string.go", - ], - importpath = "k8s.io/apimachinery/pkg/util/sets", -) - -go_genrule( - name = "set-gen", - srcs = [ - "//hack/boilerplate:boilerplate.go.txt", - ], - outs = [ - "byte.go", - "doc.go", - "empty.go", - "int.go", - "int64.go", - "string.go", - ], - cmd = """ -$(location //vendor/k8s.io/code-generator/cmd/set-gen) \ - --input-dirs ./vendor/k8s.io/apimachinery/pkg/util/sets/types \ - --output-base $$(dirname $$(dirname $(location :byte.go))) \ - --go-header-file $(location //hack/boilerplate:boilerplate.go.txt) \ - --output-package sets - """, - go_deps = [ - "//vendor/k8s.io/apimachinery/pkg/util/sets/types:go_default_library", - ], - tools = [ - "//vendor/k8s.io/code-generator/cmd/set-gen", - ], -) - -go_test( - name = "go_default_test", - srcs = ["set_test.go"], - importpath = "k8s.io/apimachinery/pkg/util/sets", - library = ":go_default_library", -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [ - ":package-srcs", - "//staging/src/k8s.io/apimachinery/pkg/util/sets/types:all-srcs", - ], - tags = ["automanaged"], -) diff --git a/vendor/github.com/appscode/go/sets/README.md b/vendor/github.com/appscode/go/sets/README.md deleted file mode 100644 index 288edde48..000000000 --- a/vendor/github.com/appscode/go/sets/README.md +++ /dev/null @@ -1 +0,0 @@ -Forked from https://github.com/kubernetes/apimachinery/blob/20bbfef868144faf29af69ddb2f01646ead5c1a1/pkg/util/sets/byte.go#L19 diff --git a/vendor/github.com/appscode/go/sets/byte.go b/vendor/github.com/appscode/go/sets/byte.go deleted file mode 100644 index a460e4b1f..000000000 --- a/vendor/github.com/appscode/go/sets/byte.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -package sets - -import ( - "reflect" - "sort" -) - -// sets.Byte is a set of bytes, implemented via map[byte]struct{} for minimal memory consumption. -type Byte map[byte]Empty - -// New creates a Byte from a list of values. -func NewByte(items ...byte) Byte { - ss := Byte{} - ss.Insert(items...) - return ss -} - -// ByteKeySet creates a Byte from a keys of a map[byte](? extends interface{}). -// If the value passed in is not actually a map, this will panic. -func ByteKeySet(theMap interface{}) Byte { - v := reflect.ValueOf(theMap) - ret := Byte{} - - for _, keyValue := range v.MapKeys() { - ret.Insert(keyValue.Interface().(byte)) - } - return ret -} - -// Insert adds items to the set. -func (s Byte) Insert(items ...byte) { - for _, item := range items { - s[item] = Empty{} - } -} - -// Delete removes all items from the set. -func (s Byte) Delete(items ...byte) { - for _, item := range items { - delete(s, item) - } -} - -// Has returns true if and only if item is contained in the set. -func (s Byte) Has(item byte) bool { - _, contained := s[item] - return contained -} - -// HasAll returns true if and only if all items are contained in the set. -func (s Byte) HasAll(items ...byte) bool { - for _, item := range items { - if !s.Has(item) { - return false - } - } - return true -} - -// HasAny returns true if any items are contained in the set. -func (s Byte) HasAny(items ...byte) bool { - for _, item := range items { - if s.Has(item) { - return true - } - } - return false -} - -// Difference returns a set of objects that are not in s2 -// For example: -// s1 = {a1, a2, a3} -// s2 = {a1, a2, a4, a5} -// s1.Difference(s2) = {a3} -// s2.Difference(s1) = {a4, a5} -func (s Byte) Difference(s2 Byte) Byte { - result := NewByte() - for key := range s { - if !s2.Has(key) { - result.Insert(key) - } - } - return result -} - -// Union returns a new set which includes items in either s1 or s2. -// For example: -// s1 = {a1, a2} -// s2 = {a3, a4} -// s1.Union(s2) = {a1, a2, a3, a4} -// s2.Union(s1) = {a1, a2, a3, a4} -func (s1 Byte) Union(s2 Byte) Byte { - result := NewByte() - for key := range s1 { - result.Insert(key) - } - for key := range s2 { - result.Insert(key) - } - return result -} - -// Intersection returns a new set which includes the item in BOTH s1 and s2 -// For example: -// s1 = {a1, a2} -// s2 = {a2, a3} -// s1.Intersection(s2) = {a2} -func (s1 Byte) Intersection(s2 Byte) Byte { - var walk, other Byte - result := NewByte() - if s1.Len() < s2.Len() { - walk = s1 - other = s2 - } else { - walk = s2 - other = s1 - } - for key := range walk { - if other.Has(key) { - result.Insert(key) - } - } - return result -} - -// IsSuperset returns true if and only if s1 is a superset of s2. -func (s1 Byte) IsSuperset(s2 Byte) bool { - for item := range s2 { - if !s1.Has(item) { - return false - } - } - return true -} - -// Equal returns true if and only if s1 is equal (as a set) to s2. -// Two sets are equal if their membership is identical. -// (In practice, this means same elements, order doesn't matter) -func (s1 Byte) Equal(s2 Byte) bool { - return len(s1) == len(s2) && s1.IsSuperset(s2) -} - -type sortableSliceOfByte []byte - -func (s sortableSliceOfByte) Len() int { return len(s) } -func (s sortableSliceOfByte) Less(i, j int) bool { return lessByte(s[i], s[j]) } -func (s sortableSliceOfByte) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// List returns the contents as a sorted byte slice. -func (s Byte) List() []byte { - res := make(sortableSliceOfByte, 0, len(s)) - for key := range s { - res = append(res, key) - } - sort.Sort(res) - return []byte(res) -} - -// UnsortedList returns the slice with contents in random order. -func (s Byte) UnsortedList() []byte { - res := make([]byte, 0, len(s)) - for key := range s { - res = append(res, key) - } - return res -} - -// Returns a single element from the set. -func (s Byte) PopAny() (byte, bool) { - for key := range s { - s.Delete(key) - return key, true - } - var zeroValue byte - return zeroValue, false -} - -// Len returns the size of the set. -func (s Byte) Len() int { - return len(s) -} - -func lessByte(lhs, rhs byte) bool { - return lhs < rhs -} diff --git a/vendor/github.com/appscode/go/sets/doc.go b/vendor/github.com/appscode/go/sets/doc.go deleted file mode 100644 index 28a6a7d5c..000000000 --- a/vendor/github.com/appscode/go/sets/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -// Package sets has auto-generated set types. -package sets diff --git a/vendor/github.com/appscode/go/sets/empty.go b/vendor/github.com/appscode/go/sets/empty.go deleted file mode 100644 index cd22b953a..000000000 --- a/vendor/github.com/appscode/go/sets/empty.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -package sets - -// Empty is public since it is used by some internal API objects for conversions between external -// string arrays and internal sets, and conversion logic requires public types today. -type Empty struct{} diff --git a/vendor/github.com/appscode/go/sets/int.go b/vendor/github.com/appscode/go/sets/int.go deleted file mode 100644 index 0614e9fb0..000000000 --- a/vendor/github.com/appscode/go/sets/int.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -package sets - -import ( - "reflect" - "sort" -) - -// sets.Int is a set of ints, implemented via map[int]struct{} for minimal memory consumption. -type Int map[int]Empty - -// New creates a Int from a list of values. -func NewInt(items ...int) Int { - ss := Int{} - ss.Insert(items...) - return ss -} - -// IntKeySet creates a Int from a keys of a map[int](? extends interface{}). -// If the value passed in is not actually a map, this will panic. -func IntKeySet(theMap interface{}) Int { - v := reflect.ValueOf(theMap) - ret := Int{} - - for _, keyValue := range v.MapKeys() { - ret.Insert(keyValue.Interface().(int)) - } - return ret -} - -// Insert adds items to the set. -func (s Int) Insert(items ...int) { - for _, item := range items { - s[item] = Empty{} - } -} - -// Delete removes all items from the set. -func (s Int) Delete(items ...int) { - for _, item := range items { - delete(s, item) - } -} - -// Has returns true if and only if item is contained in the set. -func (s Int) Has(item int) bool { - _, contained := s[item] - return contained -} - -// HasAll returns true if and only if all items are contained in the set. -func (s Int) HasAll(items ...int) bool { - for _, item := range items { - if !s.Has(item) { - return false - } - } - return true -} - -// HasAny returns true if any items are contained in the set. -func (s Int) HasAny(items ...int) bool { - for _, item := range items { - if s.Has(item) { - return true - } - } - return false -} - -// Difference returns a set of objects that are not in s2 -// For example: -// s1 = {a1, a2, a3} -// s2 = {a1, a2, a4, a5} -// s1.Difference(s2) = {a3} -// s2.Difference(s1) = {a4, a5} -func (s Int) Difference(s2 Int) Int { - result := NewInt() - for key := range s { - if !s2.Has(key) { - result.Insert(key) - } - } - return result -} - -// Union returns a new set which includes items in either s1 or s2. -// For example: -// s1 = {a1, a2} -// s2 = {a3, a4} -// s1.Union(s2) = {a1, a2, a3, a4} -// s2.Union(s1) = {a1, a2, a3, a4} -func (s1 Int) Union(s2 Int) Int { - result := NewInt() - for key := range s1 { - result.Insert(key) - } - for key := range s2 { - result.Insert(key) - } - return result -} - -// Intersection returns a new set which includes the item in BOTH s1 and s2 -// For example: -// s1 = {a1, a2} -// s2 = {a2, a3} -// s1.Intersection(s2) = {a2} -func (s1 Int) Intersection(s2 Int) Int { - var walk, other Int - result := NewInt() - if s1.Len() < s2.Len() { - walk = s1 - other = s2 - } else { - walk = s2 - other = s1 - } - for key := range walk { - if other.Has(key) { - result.Insert(key) - } - } - return result -} - -// IsSuperset returns true if and only if s1 is a superset of s2. -func (s1 Int) IsSuperset(s2 Int) bool { - for item := range s2 { - if !s1.Has(item) { - return false - } - } - return true -} - -// Equal returns true if and only if s1 is equal (as a set) to s2. -// Two sets are equal if their membership is identical. -// (In practice, this means same elements, order doesn't matter) -func (s1 Int) Equal(s2 Int) bool { - return len(s1) == len(s2) && s1.IsSuperset(s2) -} - -type sortableSliceOfInt []int - -func (s sortableSliceOfInt) Len() int { return len(s) } -func (s sortableSliceOfInt) Less(i, j int) bool { return lessInt(s[i], s[j]) } -func (s sortableSliceOfInt) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// List returns the contents as a sorted int slice. -func (s Int) List() []int { - res := make(sortableSliceOfInt, 0, len(s)) - for key := range s { - res = append(res, key) - } - sort.Sort(res) - return []int(res) -} - -// UnsortedList returns the slice with contents in random order. -func (s Int) UnsortedList() []int { - res := make([]int, 0, len(s)) - for key := range s { - res = append(res, key) - } - return res -} - -// Returns a single element from the set. -func (s Int) PopAny() (int, bool) { - for key := range s { - s.Delete(key) - return key, true - } - var zeroValue int - return zeroValue, false -} - -// Len returns the size of the set. -func (s Int) Len() int { - return len(s) -} - -func lessInt(lhs, rhs int) bool { - return lhs < rhs -} diff --git a/vendor/github.com/appscode/go/sets/int64.go b/vendor/github.com/appscode/go/sets/int64.go deleted file mode 100644 index 82e1ba782..000000000 --- a/vendor/github.com/appscode/go/sets/int64.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -package sets - -import ( - "reflect" - "sort" -) - -// sets.Int64 is a set of int64s, implemented via map[int64]struct{} for minimal memory consumption. -type Int64 map[int64]Empty - -// New creates a Int64 from a list of values. -func NewInt64(items ...int64) Int64 { - ss := Int64{} - ss.Insert(items...) - return ss -} - -// Int64KeySet creates a Int64 from a keys of a map[int64](? extends interface{}). -// If the value passed in is not actually a map, this will panic. -func Int64KeySet(theMap interface{}) Int64 { - v := reflect.ValueOf(theMap) - ret := Int64{} - - for _, keyValue := range v.MapKeys() { - ret.Insert(keyValue.Interface().(int64)) - } - return ret -} - -// Insert adds items to the set. -func (s Int64) Insert(items ...int64) { - for _, item := range items { - s[item] = Empty{} - } -} - -// Delete removes all items from the set. -func (s Int64) Delete(items ...int64) { - for _, item := range items { - delete(s, item) - } -} - -// Has returns true if and only if item is contained in the set. -func (s Int64) Has(item int64) bool { - _, contained := s[item] - return contained -} - -// HasAll returns true if and only if all items are contained in the set. -func (s Int64) HasAll(items ...int64) bool { - for _, item := range items { - if !s.Has(item) { - return false - } - } - return true -} - -// HasAny returns true if any items are contained in the set. -func (s Int64) HasAny(items ...int64) bool { - for _, item := range items { - if s.Has(item) { - return true - } - } - return false -} - -// Difference returns a set of objects that are not in s2 -// For example: -// s1 = {a1, a2, a3} -// s2 = {a1, a2, a4, a5} -// s1.Difference(s2) = {a3} -// s2.Difference(s1) = {a4, a5} -func (s Int64) Difference(s2 Int64) Int64 { - result := NewInt64() - for key := range s { - if !s2.Has(key) { - result.Insert(key) - } - } - return result -} - -// Union returns a new set which includes items in either s1 or s2. -// For example: -// s1 = {a1, a2} -// s2 = {a3, a4} -// s1.Union(s2) = {a1, a2, a3, a4} -// s2.Union(s1) = {a1, a2, a3, a4} -func (s1 Int64) Union(s2 Int64) Int64 { - result := NewInt64() - for key := range s1 { - result.Insert(key) - } - for key := range s2 { - result.Insert(key) - } - return result -} - -// Intersection returns a new set which includes the item in BOTH s1 and s2 -// For example: -// s1 = {a1, a2} -// s2 = {a2, a3} -// s1.Intersection(s2) = {a2} -func (s1 Int64) Intersection(s2 Int64) Int64 { - var walk, other Int64 - result := NewInt64() - if s1.Len() < s2.Len() { - walk = s1 - other = s2 - } else { - walk = s2 - other = s1 - } - for key := range walk { - if other.Has(key) { - result.Insert(key) - } - } - return result -} - -// IsSuperset returns true if and only if s1 is a superset of s2. -func (s1 Int64) IsSuperset(s2 Int64) bool { - for item := range s2 { - if !s1.Has(item) { - return false - } - } - return true -} - -// Equal returns true if and only if s1 is equal (as a set) to s2. -// Two sets are equal if their membership is identical. -// (In practice, this means same elements, order doesn't matter) -func (s1 Int64) Equal(s2 Int64) bool { - return len(s1) == len(s2) && s1.IsSuperset(s2) -} - -type sortableSliceOfInt64 []int64 - -func (s sortableSliceOfInt64) Len() int { return len(s) } -func (s sortableSliceOfInt64) Less(i, j int) bool { return lessInt64(s[i], s[j]) } -func (s sortableSliceOfInt64) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// List returns the contents as a sorted int64 slice. -func (s Int64) List() []int64 { - res := make(sortableSliceOfInt64, 0, len(s)) - for key := range s { - res = append(res, key) - } - sort.Sort(res) - return []int64(res) -} - -// UnsortedList returns the slice with contents in random order. -func (s Int64) UnsortedList() []int64 { - res := make([]int64, 0, len(s)) - for key := range s { - res = append(res, key) - } - return res -} - -// Returns a single element from the set. -func (s Int64) PopAny() (int64, bool) { - for key := range s { - s.Delete(key) - return key, true - } - var zeroValue int64 - return zeroValue, false -} - -// Len returns the size of the set. -func (s Int64) Len() int { - return len(s) -} - -func lessInt64(lhs, rhs int64) bool { - return lhs < rhs -} diff --git a/vendor/github.com/appscode/go/sets/string.go b/vendor/github.com/appscode/go/sets/string.go deleted file mode 100644 index baef7a6a2..000000000 --- a/vendor/github.com/appscode/go/sets/string.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -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. -*/ - -// This file was autogenerated by set-gen. Do not edit it manually! - -package sets - -import ( - "reflect" - "sort" -) - -// sets.String is a set of strings, implemented via map[string]struct{} for minimal memory consumption. -type String map[string]Empty - -// New creates a String from a list of values. -func NewString(items ...string) String { - ss := String{} - ss.Insert(items...) - return ss -} - -// StringKeySet creates a String from a keys of a map[string](? extends interface{}). -// If the value passed in is not actually a map, this will panic. -func StringKeySet(theMap interface{}) String { - v := reflect.ValueOf(theMap) - ret := String{} - - for _, keyValue := range v.MapKeys() { - ret.Insert(keyValue.Interface().(string)) - } - return ret -} - -// Insert adds items to the set. -func (s String) Insert(items ...string) { - for _, item := range items { - s[item] = Empty{} - } -} - -// Delete removes all items from the set. -func (s String) Delete(items ...string) { - for _, item := range items { - delete(s, item) - } -} - -// Has returns true if and only if item is contained in the set. -func (s String) Has(item string) bool { - _, contained := s[item] - return contained -} - -// HasAll returns true if and only if all items are contained in the set. -func (s String) HasAll(items ...string) bool { - for _, item := range items { - if !s.Has(item) { - return false - } - } - return true -} - -// HasAny returns true if any items are contained in the set. -func (s String) HasAny(items ...string) bool { - for _, item := range items { - if s.Has(item) { - return true - } - } - return false -} - -// Difference returns a set of objects that are not in s2 -// For example: -// s1 = {a1, a2, a3} -// s2 = {a1, a2, a4, a5} -// s1.Difference(s2) = {a3} -// s2.Difference(s1) = {a4, a5} -func (s String) Difference(s2 String) String { - result := NewString() - for key := range s { - if !s2.Has(key) { - result.Insert(key) - } - } - return result -} - -// Union returns a new set which includes items in either s1 or s2. -// For example: -// s1 = {a1, a2} -// s2 = {a3, a4} -// s1.Union(s2) = {a1, a2, a3, a4} -// s2.Union(s1) = {a1, a2, a3, a4} -func (s1 String) Union(s2 String) String { - result := NewString() - for key := range s1 { - result.Insert(key) - } - for key := range s2 { - result.Insert(key) - } - return result -} - -// Intersection returns a new set which includes the item in BOTH s1 and s2 -// For example: -// s1 = {a1, a2} -// s2 = {a2, a3} -// s1.Intersection(s2) = {a2} -func (s1 String) Intersection(s2 String) String { - var walk, other String - result := NewString() - if s1.Len() < s2.Len() { - walk = s1 - other = s2 - } else { - walk = s2 - other = s1 - } - for key := range walk { - if other.Has(key) { - result.Insert(key) - } - } - return result -} - -// IsSuperset returns true if and only if s1 is a superset of s2. -func (s1 String) IsSuperset(s2 String) bool { - for item := range s2 { - if !s1.Has(item) { - return false - } - } - return true -} - -// Equal returns true if and only if s1 is equal (as a set) to s2. -// Two sets are equal if their membership is identical. -// (In practice, this means same elements, order doesn't matter) -func (s1 String) Equal(s2 String) bool { - return len(s1) == len(s2) && s1.IsSuperset(s2) -} - -type sortableSliceOfString []string - -func (s sortableSliceOfString) Len() int { return len(s) } -func (s sortableSliceOfString) Less(i, j int) bool { return lessString(s[i], s[j]) } -func (s sortableSliceOfString) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// List returns the contents as a sorted string slice. -func (s String) List() []string { - res := make(sortableSliceOfString, 0, len(s)) - for key := range s { - res = append(res, key) - } - sort.Sort(res) - return []string(res) -} - -// UnsortedList returns the slice with contents in random order. -func (s String) UnsortedList() []string { - res := make([]string, 0, len(s)) - for key := range s { - res = append(res, key) - } - return res -} - -// Returns a single element from the set. -func (s String) PopAny() (string, bool) { - for key := range s { - s.Delete(key) - return key, true - } - var zeroValue string - return zeroValue, false -} - -// Len returns the size of the set. -func (s String) Len() int { - return len(s) -} - -func lessString(lhs, rhs string) bool { - return lhs < rhs -} diff --git a/vendor/github.com/appscode/go/types/convert_types.go b/vendor/github.com/appscode/go/types/convert_types.go deleted file mode 100644 index b60ac2300..000000000 --- a/vendor/github.com/appscode/go/types/convert_types.go +++ /dev/null @@ -1,501 +0,0 @@ -package types - -import "time" - -// StringP returns a pointer to the string value passed in. -func StringP(v string) *string { - return &v -} - -// String returns the value of the string pointer passed in or -// "" if the pointer is nil. -func String(v *string) string { - if v != nil { - return *v - } - return "" -} - -// StringPSlice converts a slice of string values into a slice of -// string pointers -func StringPSlice(src []string) []*string { - dst := make([]*string, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// StringSlice converts a slice of string pointers into a slice of -// string values -func StringSlice(src []*string) []string { - dst := make([]string, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// StringPMap converts a string map of string values into a string -// map of string pointers -func StringPMap(src map[string]string) map[string]*string { - dst := make(map[string]*string) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// StringMap converts a string map of string pointers into a string -// map of string values -func StringMap(src map[string]*string) map[string]string { - dst := make(map[string]string) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -var trueP = BoolP(true) - -// FalseP returns a pointer to `true` boolean value. -func TrueP() *bool { - return trueP -} - -var falseP = BoolP(false) - -// FalseP returns a pointer to `false` boolean value. -func FalseP() *bool { - return falseP -} - -// BoolP returns a pointer to the bool value passed in. -func BoolP(v bool) *bool { - return &v -} - -// Bool returns the value of the bool pointer passed in or -// false if the pointer is nil. -func Bool(v *bool) bool { - if v != nil { - return *v - } - return false -} - -// BoolPSlice converts a slice of bool values into a slice of -// bool pointers -func BoolPSlice(src []bool) []*bool { - dst := make([]*bool, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// BoolSlice converts a slice of bool pointers into a slice of -// bool values -func BoolSlice(src []*bool) []bool { - dst := make([]bool, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// BoolPMap converts a string map of bool values into a string -// map of bool pointers -func BoolPMap(src map[string]bool) map[string]*bool { - dst := make(map[string]*bool) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// BoolMap converts a string map of bool pointers into a string -// map of bool values -func BoolMap(src map[string]*bool) map[string]bool { - dst := make(map[string]bool) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// IntP returns a pointer to the int value passed in. -func IntP(v int) *int { - return &v -} - -// Int returns the value of the int pointer passed in or -// 0 if the pointer is nil. -func Int(v *int) int { - if v != nil { - return *v - } - return 0 -} - -// IntPSlice converts a slice of int values into a slice of -// int pointers -func IntPSlice(src []int) []*int { - dst := make([]*int, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// IntSlice converts a slice of int pointers into a slice of -// int values -func IntSlice(src []*int) []int { - dst := make([]int, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// IntPMap converts a string map of int values into a string -// map of int pointers -func IntPMap(src map[string]int) map[string]*int { - dst := make(map[string]*int) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// IntMap converts a string map of int pointers into a string -// map of int values -func IntMap(src map[string]*int) map[string]int { - dst := make(map[string]int) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// UIntP returns a pointer to the uint value passed in. -func UIntP(v uint) *uint { - return &v -} - -// UInt returns the value of the uint pointer passed in or -// 0 if the pointer is nil. -func UInt(v *uint) uint { - if v != nil { - return *v - } - return 0 -} - -// UIntPSlice converts a slice of uint values into a slice of -// uint pointers -func UIntPSlice(src []uint) []*uint { - dst := make([]*uint, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// UIntSlice converts a slice of uint pointers into a slice of -// uint values -func UIntSlice(src []*uint) []uint { - dst := make([]uint, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// UIntPMap converts a string map of uint values into a string -// map of uint pointers -func UIntPMap(src map[string]uint) map[string]*uint { - dst := make(map[string]*uint) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// UIntMap converts a string map of uint pointers into a string -// map of uint values -func UIntMap(src map[string]*uint) map[string]uint { - dst := make(map[string]uint) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Int32P returns a pointer to the int32 value passed in. -func Int32P(v int32) *int32 { - return &v -} - -// Int32 returns the value of the int32 pointer passed in or -// 0 if the pointer is nil. -func Int32(v *int32) int32 { - if v != nil { - return *v - } - return 0 -} - -// Int32PSlice converts a slice of int32 values into a slice of -// int32 pointers -func Int32PSlice(src []int32) []*int32 { - dst := make([]*int32, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// Int32Slice converts a slice of int32 pointers into a slice of -// int32 values -func Int32Slice(src []*int32) []int32 { - dst := make([]int32, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// Int32PMap converts a string map of int32 values into a string -// map of int32 pointers -func Int32PMap(src map[string]int32) map[string]*int32 { - dst := make(map[string]*int32) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// Int32Map converts a string map of int32 pointers into a string -// map of int32 values -func Int32Map(src map[string]*int32) map[string]int32 { - dst := make(map[string]int32) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Int64P returns a pointer to the int64 value passed in. -func Int64P(v int64) *int64 { - return &v -} - -// Int64 returns the value of the int64 pointer passed in or -// 0 if the pointer is nil. -func Int64(v *int64) int64 { - if v != nil { - return *v - } - return 0 -} - -// Int64PSlice converts a slice of int64 values into a slice of -// int64 pointers -func Int64PSlice(src []int64) []*int64 { - dst := make([]*int64, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// Int64Slice converts a slice of int64 pointers into a slice of -// int64 values -func Int64Slice(src []*int64) []int64 { - dst := make([]int64, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// Int64PMap converts a string map of int64 values into a string -// map of int64 pointers -func Int64PMap(src map[string]int64) map[string]*int64 { - dst := make(map[string]*int64) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// Int64Map converts a string map of int64 pointers into a string -// map of int64 values -func Int64Map(src map[string]*int64) map[string]int64 { - dst := make(map[string]int64) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Float64P returns a pointer to the float64 value passed in. -func Float64P(v float64) *float64 { - return &v -} - -// Float64 returns the value of the float64 pointer passed in or -// 0 if the pointer is nil. -func Float64(v *float64) float64 { - if v != nil { - return *v - } - return 0 -} - -// Float64PSlice converts a slice of float64 values into a slice of -// float64 pointers -func Float64PSlice(src []float64) []*float64 { - dst := make([]*float64, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// Float64Slice converts a slice of float64 pointers into a slice of -// float64 values -func Float64Slice(src []*float64) []float64 { - dst := make([]float64, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// Float64PMap converts a string map of float64 values into a string -// map of float64 pointers -func Float64PMap(src map[string]float64) map[string]*float64 { - dst := make(map[string]*float64) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// Float64Map converts a string map of float64 pointers into a string -// map of float64 values -func Float64Map(src map[string]*float64) map[string]float64 { - dst := make(map[string]float64) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// TimeP returns a pointer to the time.Time value passed in. -func TimeP(v time.Time) *time.Time { - return &v -} - -// Time returns the value of the time.Time pointer passed in or -// time.Time{} if the pointer is nil. -func Time(v *time.Time) time.Time { - if v != nil { - return *v - } - return time.Time{} -} - -// TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC". -// The result is undefined if the Unix time cannot be represented by an int64. -// Which includes calling TimeUnixMilli on a zero Time is undefined. -// -// This utility is useful for service API's such as CloudWatch Logs which require -// their unix time values to be in milliseconds. -// -// See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information. -func TimeUnixMilli(t time.Time) int64 { - return t.UnixNano() / int64(time.Millisecond/time.Nanosecond) -} - -// TimePSlice converts a slice of time.Time values into a slice of -// time.Time pointers -func TimePSlice(src []time.Time) []*time.Time { - dst := make([]*time.Time, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// TimeSlice converts a slice of time.Time pointers into a slice of -// time.Time values -func TimeSlice(src []*time.Time) []time.Time { - dst := make([]time.Time, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// TimePMap converts a string map of time.Time values into a string -// map of time.Time pointers -func TimePMap(src map[string]time.Time) map[string]*time.Time { - dst := make(map[string]*time.Time) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// TimeMap converts a string map of time.Time pointers into a string -// map of time.Time values -func TimeMap(src map[string]*time.Time) map[string]time.Time { - dst := make(map[string]time.Time) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} diff --git a/vendor/github.com/appscode/go/types/doc.go b/vendor/github.com/appscode/go/types/doc.go deleted file mode 100644 index 031caf593..000000000 --- a/vendor/github.com/appscode/go/types/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -GOlang value <--> pointer - -##Acknowledgements -This repo was started as a fork of https://github.com/aws/aws-sdk-go/blob/master/aws/convert_types.go -*/ -package types diff --git a/vendor/kmodules.xyz/client-go/meta/hash.go b/vendor/kmodules.xyz/client-go/meta/hash.go index cb119fe89..4981fee35 100644 --- a/vendor/kmodules.xyz/client-go/meta/hash.go +++ b/vendor/kmodules.xyz/client-go/meta/hash.go @@ -23,7 +23,6 @@ import ( "reflect" "strconv" - "github.com/appscode/go/encoding/json/types" "github.com/davecgh/go-spew/spew" "github.com/fatih/structs" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -106,7 +105,7 @@ func MustAlreadyReconciled(o interface{}) bool { } func AlreadyReconciled(o interface{}) (bool, error) { - var generation, observedGeneration *types.IntHash + var generation, observedGeneration int64 var err error switch obj := o.(type) { @@ -120,36 +119,36 @@ func AlreadyReconciled(o interface{}) (bool, error) { if err != nil { return false, err } - return observedGeneration.MatchGeneration(generation), nil + return observedGeneration == generation, nil } -func extractGenerationFromUnstructured(obj *unstructured.Unstructured) (*types.IntHash, *types.IntHash, error) { - generation := types.IntHashForGeneration(obj.GetGeneration()) - +func extractGenerationFromUnstructured(obj *unstructured.Unstructured) (int64, int64, error) { val, found, err := unstructured.NestedFieldNoCopy(obj.Object, "status", "observedGeneration") if err != nil { - return nil, nil, err + return -1, -1, err } else if !found { - return nil, nil, fmt.Errorf("status.observedGeneration is missing") + return obj.GetGeneration(), -1, nil } - observedGeneration, err := types.ParseIntHash(val) - - return generation, observedGeneration, err + observedGeneration, ok := val.(int64) + if !ok { + return -1, -1, fmt.Errorf("%s %s/%s status.observedGeneration %+v is not int64", obj.GroupVersionKind(), obj.GetNamespace(), obj.GetName(), val) + } + return obj.GetGeneration(), observedGeneration, nil } -func extractGenerationFromObject(obj metav1.Object) (*types.IntHash, *types.IntHash, error) { - generation := types.IntHashForGeneration(obj.GetGeneration()) - +func extractGenerationFromObject(obj metav1.Object) (int64, int64, error) { st := structs.New(obj) fieldStatus, found := st.FieldOk("Status") if !found { - return nil, nil, fmt.Errorf("status is missing") + return obj.GetGeneration(), -1, nil } fieldObsGen, found := fieldStatus.FieldOk("ObservedGeneration") if !found { - return nil, nil, fmt.Errorf("status.observedGeneration is missing") + return obj.GetGeneration(), -1, nil } - observedGeneration, err := types.ParseIntHash(fieldObsGen.Value()) - - return generation, observedGeneration, err + observedGeneration, ok := fieldObsGen.Value().(int64) + if !ok { + return -1, -1, fmt.Errorf("%s %s/%s status.observedGeneration %+v is not int64", reflect.TypeOf(obj).String(), obj.GetNamespace(), obj.GetName(), fieldObsGen.Value()) + } + return obj.GetGeneration(), observedGeneration, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 99f139f77..3bc582dfc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,10 +7,7 @@ github.com/PuerkitoBio/purell # github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 github.com/PuerkitoBio/urlesc # github.com/appscode/go v0.0.0-20201006035845-a0302ac8e3d3 -github.com/appscode/go/encoding/json/types github.com/appscode/go/runtime -github.com/appscode/go/sets -github.com/appscode/go/types # github.com/beorn7/perks v1.0.1 github.com/beorn7/perks/quantile # github.com/blang/semver v3.5.1+incompatible @@ -717,7 +714,7 @@ k8s.io/utils/net k8s.io/utils/path k8s.io/utils/pointer k8s.io/utils/trace -# kmodules.xyz/client-go v0.0.0-20201011221802-3180ab67d845 +# kmodules.xyz/client-go v0.0.0-20201013083546-b17c1e15f1a3 kmodules.xyz/client-go kmodules.xyz/client-go/apiextensions kmodules.xyz/client-go/apiextensions/v1