mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-28 02:37:11 +00:00
Merge pull request #43 from ConnorDoyle/use-client-go
Automatic merge from submit-queue [WIP] Use out-of-tree k8s go client. Fixes #38. Builds and tests pass, but still needs manual testing (since we don't have e2e set up yet.) This also speeds up the build quite a bit.
This commit is contained in:
commit
acdf1f8c3a
5 changed files with 77 additions and 390 deletions
368
glide.lock
generated
368
glide.lock
generated
|
@ -1,366 +1,48 @@
|
|||
hash: 06660a6f6a53a4d29b7870e5a452ab194c2c99d69107db164f4af5945cc746bc
|
||||
updated: 2016-09-02T11:18:55.975551365-07:00
|
||||
hash: f43fa3ac02ea7f1a8669981c2244722bf001e9237002d659d0c0a508d9a067c9
|
||||
updated: 2016-11-11T10:29:40.757214999-08:00
|
||||
imports:
|
||||
- name: github.com/beorn7/perks
|
||||
version: 3ac7bf7a47d159a033b107610db8a1b6575507a4
|
||||
subpackages:
|
||||
- quantile
|
||||
- name: github.com/blang/semver
|
||||
version: 31b736133b98f26d5e078ec9eb591666edfd091f
|
||||
- name: github.com/coreos/go-oidc
|
||||
version: 5cf2aa52da8c574d3aa4458f471ad6ae2240fe6b
|
||||
subpackages:
|
||||
- http
|
||||
- jose
|
||||
- key
|
||||
- oauth2
|
||||
- oidc
|
||||
- name: github.com/coreos/go-systemd
|
||||
version: 4484981625c1a6a2ecb40a390fcb6a9bcfee76e3
|
||||
subpackages:
|
||||
- activation
|
||||
- daemon
|
||||
- dbus
|
||||
- journal
|
||||
- unit
|
||||
- util
|
||||
- name: github.com/coreos/pkg
|
||||
version: 7f080b6c11ac2d2347c3cd7521e810207ea1a041
|
||||
subpackages:
|
||||
- capnslog
|
||||
- dlopen
|
||||
- health
|
||||
- httputil
|
||||
- timeutil
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 2df174808ee097f90d259e432cc04442cf60be21
|
||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/docker/distribution
|
||||
version: cd27f179f2c10c5d300e6d09025b538c475b0d51
|
||||
subpackages:
|
||||
- digest
|
||||
- reference
|
||||
- name: github.com/docker/docker
|
||||
version: 0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d
|
||||
subpackages:
|
||||
- pkg/jsonmessage
|
||||
- pkg/mount
|
||||
- pkg/stdcopy
|
||||
- pkg/symlink
|
||||
- pkg/term
|
||||
- pkg/term/winconsole
|
||||
- pkg/timeutils
|
||||
- pkg/units
|
||||
- name: github.com/docker/go-units
|
||||
version: 0bbddae09c5a5419a8c6dcdd7ff90da3d450393b
|
||||
- name: github.com/docopt/docopt-go
|
||||
version: 784ddc588536785e7299f7272f39101f7faccc3f
|
||||
- name: github.com/docopt/docopt.go
|
||||
version: 784ddc588536785e7299f7272f39101f7faccc3f
|
||||
- name: github.com/emicklei/go-restful
|
||||
version: 7c47e2558a0bbbaba9ecab06bc6681e73028a28a
|
||||
subpackages:
|
||||
- log
|
||||
- swagger
|
||||
- name: github.com/ghodss/yaml
|
||||
version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee
|
||||
- name: github.com/gogo/protobuf
|
||||
version: 82d16f734d6d871204a3feb1a73cb220cc92574c
|
||||
subpackages:
|
||||
- gogoproto
|
||||
- plugin/defaultcheck
|
||||
- plugin/description
|
||||
- plugin/embedcheck
|
||||
- plugin/enumstringer
|
||||
- plugin/equal
|
||||
- plugin/face
|
||||
- plugin/gostring
|
||||
- plugin/grpc
|
||||
- plugin/marshalto
|
||||
- plugin/oneofcheck
|
||||
- plugin/populate
|
||||
- plugin/size
|
||||
- plugin/stringer
|
||||
- plugin/testgen
|
||||
- plugin/union
|
||||
- plugin/unmarshal
|
||||
- proto
|
||||
- protoc-gen-gogo/descriptor
|
||||
- protoc-gen-gogo/generator
|
||||
- protoc-gen-gogo/plugin
|
||||
- sortkeys
|
||||
- vanity
|
||||
- vanity/command
|
||||
- name: github.com/golang/glog
|
||||
version: 44145f04b68cf362d9c4df2182967c2275eaefed
|
||||
- name: github.com/golang/protobuf
|
||||
version: b982704f8bb716bb608144408cff30e15fbde841
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/google/cadvisor
|
||||
version: 4dbefc9b671b81257973a33211fb12370c1a526e
|
||||
subpackages:
|
||||
- api
|
||||
- cache/memory
|
||||
- collector
|
||||
- container
|
||||
- container/common
|
||||
- container/docker
|
||||
- container/libcontainer
|
||||
- container/raw
|
||||
- container/rkt
|
||||
- container/systemd
|
||||
- devicemapper
|
||||
- events
|
||||
- fs
|
||||
- healthz
|
||||
- http
|
||||
- http/mux
|
||||
- info/v1
|
||||
- info/v1/test
|
||||
- info/v2
|
||||
- machine
|
||||
- manager
|
||||
- manager/watcher
|
||||
- manager/watcher/raw
|
||||
- manager/watcher/rkt
|
||||
- metrics
|
||||
- pages
|
||||
- pages/static
|
||||
- storage
|
||||
- summary
|
||||
- utils
|
||||
- utils/cloudinfo
|
||||
- utils/cpuload
|
||||
- utils/cpuload/netlink
|
||||
- utils/docker
|
||||
- utils/oomparser
|
||||
- utils/sysfs
|
||||
- utils/sysinfo
|
||||
- utils/tail
|
||||
- validate
|
||||
- version
|
||||
- name: github.com/google/gofuzz
|
||||
version: bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
|
||||
- name: github.com/jonboulle/clockwork
|
||||
version: 3f831b65b61282ba6bece21b91beea2edc4c887a
|
||||
- name: github.com/juju/ratelimit
|
||||
version: 77ed1c8a01217656d2080ad51981f6e99adaa177
|
||||
- name: github.com/klauspost/cpuid
|
||||
version: 09cded8978dc9e80714c4d85b0322337b0a1e5e0
|
||||
- name: github.com/matttproud/golang_protobuf_extensions
|
||||
version: fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a
|
||||
subpackages:
|
||||
- pbutil
|
||||
- name: github.com/opencontainers/runc
|
||||
version: 7ca2aa4873aea7cb4265b1726acb24b90d8726c6
|
||||
subpackages:
|
||||
- libcontainer
|
||||
- libcontainer/apparmor
|
||||
- libcontainer/cgroups
|
||||
- libcontainer/cgroups/fs
|
||||
- libcontainer/cgroups/systemd
|
||||
- libcontainer/configs
|
||||
- libcontainer/configs/validate
|
||||
- libcontainer/criurpc
|
||||
- libcontainer/label
|
||||
- libcontainer/seccomp
|
||||
- libcontainer/selinux
|
||||
- libcontainer/stacktrace
|
||||
- libcontainer/system
|
||||
- libcontainer/user
|
||||
- libcontainer/utils
|
||||
- name: github.com/pborman/uuid
|
||||
version: ca53cad383cad2479bbba7f7a1a05797ec1386e4
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/prometheus/client_golang
|
||||
version: 3b78d7a77f51ccbc364d4bc170920153022cfd08
|
||||
- name: github.com/stretchr/objx
|
||||
version: cbeaeb16a013161a98496fad62933b1d21786672
|
||||
- name: github.com/stretchr/testify
|
||||
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
|
||||
subpackages:
|
||||
- prometheus
|
||||
- name: github.com/prometheus/client_model
|
||||
version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6
|
||||
- mock
|
||||
- assert
|
||||
- name: k8s.io/client-go
|
||||
version: b22087a53becae45931ed72d5e0f12e0031d771a
|
||||
subpackages:
|
||||
- go
|
||||
- name: github.com/prometheus/common
|
||||
version: a6ab08426bb262e2d190097751f5cfd1cfdfd17d
|
||||
- 1.4/kubernetes
|
||||
- 1.4/pkg/api
|
||||
- 1.4/rest
|
||||
testImports:
|
||||
- name: github.com/gopherjs/gopherjs
|
||||
version: e34a5cd6a1bc7c4fde759f2d3039852fc68b5fcc
|
||||
subpackages:
|
||||
- expfmt
|
||||
- internal/bitbucket.org/ww/goautoneg
|
||||
- model
|
||||
- name: github.com/prometheus/procfs
|
||||
version: 490cc6eb5fa45bf8a8b7b73c8bc82a8160e8531d
|
||||
- js
|
||||
- name: github.com/jtolds/gls
|
||||
version: 8ddce2a84170772b95dd5d576c48d517b22cac63
|
||||
- name: github.com/smartystreets/assertions
|
||||
version: e60cfa771e3f4d18723a4119f1833898c9c62066
|
||||
subpackages:
|
||||
- internal/go-render/render
|
||||
- internal/oglematchers
|
||||
- name: github.com/smartystreets/goconvey
|
||||
version: d4c757aa9afd1e2fc1832aaab209b5794eb336e1
|
||||
subpackages:
|
||||
- convey
|
||||
- convey/reporting
|
||||
- convey/gotest
|
||||
- name: github.com/spf13/pflag
|
||||
version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5
|
||||
- name: github.com/stretchr/objx
|
||||
version: cbeaeb16a013161a98496fad62933b1d21786672
|
||||
- name: github.com/stretchr/testify
|
||||
version: f390dcf405f7b83c997eac1b06768bb9f44dec18
|
||||
subpackages:
|
||||
- mock
|
||||
- assert
|
||||
- name: github.com/ugorji/go
|
||||
version: f4485b318aadd133842532f841dc205a8e339d74
|
||||
subpackages:
|
||||
- codec
|
||||
- codec/codecgen
|
||||
- name: github.com/vektra/errors
|
||||
version: c64d83aba85aa4392895aadeefabbd24e89f3580
|
||||
- name: golang.org/x/net
|
||||
version: 62685c2d7ca23c807425dca88b11a3e2323dab41
|
||||
subpackages:
|
||||
- context
|
||||
- context/ctxhttp
|
||||
- html
|
||||
- html/atom
|
||||
- http2
|
||||
- http2/hpack
|
||||
- internal/timeseries
|
||||
- proxy
|
||||
- trace
|
||||
- websocket
|
||||
- name: golang.org/x/oauth2
|
||||
version: b5adcc2dcdf009d0391547edc6ecbaff889f5bb9
|
||||
subpackages:
|
||||
- google
|
||||
- internal
|
||||
- jws
|
||||
- jwt
|
||||
- name: google.golang.org/appengine
|
||||
version: 12d5545dc1cfa6047a286d5e853841b6471f4c19
|
||||
subpackages:
|
||||
- urlfetch
|
||||
- internal
|
||||
- internal/urlfetch
|
||||
- internal/app_identity
|
||||
- internal/modules
|
||||
- internal/base
|
||||
- internal/datastore
|
||||
- internal/log
|
||||
- internal/remote_api
|
||||
- name: google.golang.org/cloud
|
||||
version: eb47ba841d53d93506cfbfbc03927daf9cc48f88
|
||||
subpackages:
|
||||
- compute/metadata
|
||||
- internal
|
||||
- name: gopkg.in/inf.v0
|
||||
version: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4
|
||||
- name: gopkg.in/yaml.v2
|
||||
version: a83829b6f1293c91addabc89d0571c246397bbf4
|
||||
- name: k8s.io/kubernetes
|
||||
version: 283137936a498aed572ee22af6774b6fb6e9fd94
|
||||
subpackages:
|
||||
- pkg/api
|
||||
- pkg/client/unversioned
|
||||
- pkg/api/meta
|
||||
- pkg/api/meta/metatypes
|
||||
- pkg/api/resource
|
||||
- pkg/api/unversioned
|
||||
- pkg/auth/user
|
||||
- pkg/conversion
|
||||
- pkg/fields
|
||||
- pkg/labels
|
||||
- pkg/runtime
|
||||
- pkg/runtime/serializer
|
||||
- pkg/types
|
||||
- pkg/util
|
||||
- pkg/util/intstr
|
||||
- pkg/util/rand
|
||||
- pkg/util/sets
|
||||
- pkg/api/errors
|
||||
- pkg/api/install
|
||||
- pkg/apimachinery/registered
|
||||
- pkg/apis/apps
|
||||
- pkg/apis/apps/install
|
||||
- pkg/apis/authentication.k8s.io/install
|
||||
- pkg/apis/authorization/install
|
||||
- pkg/apis/autoscaling
|
||||
- pkg/apis/autoscaling/install
|
||||
- pkg/apis/batch
|
||||
- pkg/apis/batch/install
|
||||
- pkg/apis/batch/v2alpha1
|
||||
- pkg/apis/componentconfig/install
|
||||
- pkg/apis/extensions
|
||||
- pkg/apis/extensions/install
|
||||
- pkg/apis/policy
|
||||
- pkg/apis/policy/install
|
||||
- pkg/apis/rbac
|
||||
- pkg/apis/rbac/install
|
||||
- pkg/client/restclient
|
||||
- pkg/client/typed/discovery
|
||||
- pkg/util/net
|
||||
- pkg/util/wait
|
||||
- pkg/version
|
||||
- pkg/watch
|
||||
- plugin/pkg/client/auth
|
||||
- pkg/util/errors
|
||||
- third_party/forked/reflect
|
||||
- pkg/util/validation
|
||||
- pkg/conversion/queryparams
|
||||
- pkg/util/json
|
||||
- pkg/runtime/serializer/json
|
||||
- pkg/runtime/serializer/protobuf
|
||||
- pkg/runtime/serializer/recognizer
|
||||
- pkg/runtime/serializer/versioning
|
||||
- pkg/util/validation/field
|
||||
- pkg/api/v1
|
||||
- pkg/apimachinery
|
||||
- pkg/watch/versioned
|
||||
- pkg/apis/apps/v1alpha1
|
||||
- pkg/apis/authentication.k8s.io
|
||||
- pkg/apis/authentication.k8s.io/v1beta1
|
||||
- pkg/apis/authorization
|
||||
- pkg/apis/authorization/v1beta1
|
||||
- pkg/apis/autoscaling/v1
|
||||
- pkg/apis/batch/v1
|
||||
- pkg/apis/componentconfig
|
||||
- pkg/apis/componentconfig/v1alpha1
|
||||
- pkg/apis/extensions/v1beta1
|
||||
- pkg/apis/policy/v1alpha1
|
||||
- pkg/apis/rbac/v1alpha1
|
||||
- pkg/api/validation
|
||||
- pkg/client/metrics
|
||||
- pkg/client/transport
|
||||
- pkg/client/unversioned/clientcmd/api
|
||||
- pkg/runtime/serializer/streaming
|
||||
- pkg/util/crypto
|
||||
- pkg/util/flowcontrol
|
||||
- pkg/util/runtime
|
||||
- plugin/pkg/client/auth/gcp
|
||||
- plugin/pkg/client/auth/oidc
|
||||
- pkg/util/framer
|
||||
- pkg/util/yaml
|
||||
- pkg/util/parsers
|
||||
- pkg/kubelet/qos
|
||||
- pkg/master/ports
|
||||
- pkg/api/endpoints
|
||||
- pkg/api/pod
|
||||
- pkg/api/service
|
||||
- pkg/api/unversioned/validation
|
||||
- pkg/api/util
|
||||
- pkg/capabilities
|
||||
- pkg/util/integer
|
||||
- pkg/kubelet/qos/util
|
||||
- pkg/util/hash
|
||||
- pkg/util/net/sets
|
||||
testImports:
|
||||
- name: github.com/gopherjs/gopherjs
|
||||
version: 45518c130e5bd1525f20110830a4986365a153de
|
||||
subpackages:
|
||||
- js
|
||||
- name: github.com/jtolds/gls
|
||||
version: 8ddce2a84170772b95dd5d576c48d517b22cac63
|
||||
- name: github.com/smartystreets/assertions
|
||||
version: 2063fd1cc7c975db70502811a34b06ad034ccdf2
|
||||
subpackages:
|
||||
- internal/go-render/render
|
||||
- internal/oglematchers
|
||||
|
|
28
glide.yaml
28
glide.yaml
|
@ -1,20 +1,22 @@
|
|||
package: github.com/kubernetes-incubator/node-feature-discovery
|
||||
import:
|
||||
- package: github.com/klauspost/cpuid
|
||||
version: v1.0
|
||||
- package: github.com/docopt/docopt.go
|
||||
- package: github.com/docopt/docopt-go
|
||||
version: ^0.6.2
|
||||
- package: k8s.io/kubernetes
|
||||
version: v1.3.0
|
||||
subpackages:
|
||||
- pkg/api
|
||||
- pkg/client/unversioned
|
||||
- package: github.com/smartystreets/goconvey
|
||||
version: 1.6.2
|
||||
subpackages:
|
||||
- convey
|
||||
- package: github.com/klauspost/cpuid
|
||||
version: ^1.0.0
|
||||
- package: github.com/stretchr/testify
|
||||
version: v1.1.3
|
||||
version: ^1.1.4
|
||||
subpackages:
|
||||
- mock
|
||||
- package: k8s.io/client-go
|
||||
version: ^2.0.0-alpha.0
|
||||
subpackages:
|
||||
- 1.4/kubernetes
|
||||
- 1.4/pkg/api
|
||||
- 1.4/rest
|
||||
testImport:
|
||||
- package: github.com/smartystreets/goconvey
|
||||
version: ^1.6.2
|
||||
subpackages:
|
||||
- convey
|
||||
- package: github.com/vektra/errors
|
||||
|
|
35
main.go
35
main.go
|
@ -8,8 +8,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/docopt/docopt-go"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
k8sclient "k8s.io/client-go/kubernetes"
|
||||
api "k8s.io/client-go/pkg/api/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -44,10 +45,10 @@ type Labels map[string]string
|
|||
// APIHelpers represents a set of API helpers for Kubernetes
|
||||
type APIHelpers interface {
|
||||
// GetClient returns a client
|
||||
GetClient() (*client.Client, error)
|
||||
GetClient() (*k8sclient.Clientset, error)
|
||||
|
||||
// GetNode returns the Kubernetes node on which this container is running.
|
||||
GetNode(*client.Client) (*api.Node, error)
|
||||
GetNode(*k8sclient.Clientset) (*api.Node, error)
|
||||
|
||||
// RemoveLabels removes labels from the supplied node that contain the
|
||||
// search string provided. In order to publish the changes, the node must
|
||||
|
@ -60,7 +61,7 @@ type APIHelpers interface {
|
|||
AddLabels(*api.Node, Labels)
|
||||
|
||||
// UpdateNode updates the node via the API server using a client.
|
||||
UpdateNode(*client.Client, *api.Node) error
|
||||
UpdateNode(*k8sclient.Clientset, *api.Node) error
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -179,7 +180,6 @@ func getFeatureLabels(source FeatureSource) (Labels, error) {
|
|||
// advertiseFeatureLabels advertises the feature labels to a Kubernetes node
|
||||
// via the API server.
|
||||
func advertiseFeatureLabels(helper APIHelpers, labels Labels) error {
|
||||
// Set up K8S client.
|
||||
cli, err := helper.GetClient()
|
||||
if err != nil {
|
||||
stderrLogger.Printf("can't get kubernetes client: %s", err.Error())
|
||||
|
@ -211,17 +211,20 @@ func advertiseFeatureLabels(helper APIHelpers, labels Labels) error {
|
|||
// Implements main.APIHelpers
|
||||
type k8sHelpers struct{}
|
||||
|
||||
func (h k8sHelpers) GetClient() (*client.Client, error) {
|
||||
// Set up K8S client.
|
||||
cli, err := client.NewInCluster()
|
||||
func (h k8sHelpers) GetClient() (*k8sclient.Clientset, error) {
|
||||
// Set up an in-cluster K8S client.
|
||||
config, err := restclient.InClusterConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cli, nil
|
||||
clientset, err := k8sclient.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clientset, nil
|
||||
}
|
||||
|
||||
func (h k8sHelpers) GetNode(cli *client.Client) (*api.Node, error) {
|
||||
func (h k8sHelpers) GetNode(cli *k8sclient.Clientset) (*api.Node, error) {
|
||||
// Get the pod name and pod namespace from the env variables
|
||||
podName := os.Getenv(PodNameEnv)
|
||||
podns := os.Getenv(PodNamespaceEnv)
|
||||
|
@ -229,14 +232,14 @@ func (h k8sHelpers) GetNode(cli *client.Client) (*api.Node, error) {
|
|||
stdoutLogger.Printf("%s: %s", PodNamespaceEnv, podns)
|
||||
|
||||
// Get the pod object using the pod name and pod namespace
|
||||
pod, err := cli.Pods(podns).Get(podName)
|
||||
pod, err := cli.Core().Pods(podns).Get(podName)
|
||||
if err != nil {
|
||||
stderrLogger.Printf("can't get pods: %s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the node object using the pod name and pod namespace
|
||||
node, err := cli.Nodes().Get(pod.Spec.NodeName)
|
||||
node, err := cli.Core().Nodes().Get(pod.Spec.NodeName)
|
||||
if err != nil {
|
||||
stderrLogger.Printf("can't get node: %s", err.Error())
|
||||
return nil, err
|
||||
|
@ -261,9 +264,9 @@ func (h k8sHelpers) AddLabels(n *api.Node, labels Labels) {
|
|||
}
|
||||
}
|
||||
|
||||
func (h k8sHelpers) UpdateNode(c *client.Client, n *api.Node) error {
|
||||
func (h k8sHelpers) UpdateNode(c *k8sclient.Clientset, n *api.Node) error {
|
||||
// Send the updated node to the apiserver.
|
||||
_, err := c.Nodes().Update(n)
|
||||
_, err := c.Core().Nodes().Update(n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/vektra/errors"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
k8sclient "k8s.io/client-go/kubernetes"
|
||||
api "k8s.io/client-go/pkg/api/v1"
|
||||
)
|
||||
|
||||
func TestDiscoveryWithMockSources(t *testing.T) {
|
||||
|
@ -49,7 +49,7 @@ func TestDiscoveryWithMockSources(t *testing.T) {
|
|||
|
||||
mockAPIHelper := new(MockAPIHelpers)
|
||||
testHelper := APIHelpers(mockAPIHelper)
|
||||
var mockClient *client.Client
|
||||
var mockClient *k8sclient.Clientset
|
||||
var mockNode *api.Node
|
||||
|
||||
Convey("When I successfully advertise feature labels to a node", func() {
|
||||
|
|
|
@ -2,8 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
k8sclient "k8s.io/client-go/kubernetes"
|
||||
api "k8s.io/client-go/pkg/api/v1"
|
||||
)
|
||||
|
||||
type MockAPIHelpers struct {
|
||||
|
@ -11,16 +11,16 @@ type MockAPIHelpers struct {
|
|||
}
|
||||
|
||||
// GetClient provides a mock function with no input arguments and
|
||||
// *client.Client and error as return value
|
||||
func (_m *MockAPIHelpers) GetClient() (*client.Client, error) {
|
||||
// *k8sclient.Clientset and error as return value
|
||||
func (_m *MockAPIHelpers) GetClient() (*k8sclient.Clientset, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *client.Client
|
||||
if rf, ok := ret.Get(0).(func() *client.Client); ok {
|
||||
var r0 *k8sclient.Clientset
|
||||
if rf, ok := ret.Get(0).(func() *k8sclient.Clientset); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*client.Client)
|
||||
r0 = ret.Get(0).(*k8sclient.Clientset)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,13 @@ func (_m *MockAPIHelpers) GetClient() (*client.Client, error) {
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// GetNode provides a mock function with *client.Client as input argument and
|
||||
// *api.Node and error as return values
|
||||
func (_m *MockAPIHelpers) GetNode(_a0 *client.Client) (*api.Node, error) {
|
||||
// GetNode provides a mock function with *k8sclient.Clientset as input
|
||||
// argument and *api.Node and error as return values
|
||||
func (_m *MockAPIHelpers) GetNode(_a0 *k8sclient.Clientset) (*api.Node, error) {
|
||||
ret := _m.Called(_a0)
|
||||
|
||||
var r0 *api.Node
|
||||
if rf, ok := ret.Get(0).(func(*client.Client) *api.Node); ok {
|
||||
if rf, ok := ret.Get(0).(func(*k8sclient.Clientset) *api.Node); ok {
|
||||
r0 = rf(_a0)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
|
@ -49,7 +49,7 @@ func (_m *MockAPIHelpers) GetNode(_a0 *client.Client) (*api.Node, error) {
|
|||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*client.Client) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(*k8sclient.Clientset) error); ok {
|
||||
r1 = rf(_a0)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
|
@ -70,13 +70,13 @@ func (_m *MockAPIHelpers) AddLabels(_a0 *api.Node, _a1 Labels) {
|
|||
_m.Called(_a0, _a1)
|
||||
}
|
||||
|
||||
// UpdateNode provides a mock function with *client.Client and *api.Node as the input arguments and
|
||||
// UpdateNode provides a mock function with *k8sclient.Clientset and *api.Node as the input arguments and
|
||||
// error as the return value
|
||||
func (_m *MockAPIHelpers) UpdateNode(_a0 *client.Client, _a1 *api.Node) error {
|
||||
func (_m *MockAPIHelpers) UpdateNode(_a0 *k8sclient.Clientset, _a1 *api.Node) error {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(*client.Client, *api.Node) error); ok {
|
||||
if rf, ok := ret.Get(0).(func(*k8sclient.Clientset, *api.Node) error); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
|
|
Loading…
Add table
Reference in a new issue