Refactor: use Kubernetes.Interface instead of *Clientset

So we can call with a mock for testing
This commit is contained in:
Bryan Boreham committed 2018-09-12 12:35:34 +00:00
1 parent 7dcd4bdf47
commit c3ce052cc5
4 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -26,11 +26,11 @@ type configMapAnnotations struct {
cm *v1.ConfigMap
}
func newConfigMapAnnotations(ns string, configMapName string, clientset *kubernetes.Clientset) *configMapAnnotations {
func newConfigMapAnnotations(ns string, configMapName string, c kubernetes.Interface) *configMapAnnotations {
return &configMapAnnotations{
Namespace: ns,
ConfigMapName: configMapName,
Client: clientset.CoreV1(),
Client: c.CoreV1(),
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ type nodeInfo struct {
}
// return the IP addresses of all nodes in the cluster
func getKubePeers(c *kubernetes.Clientset, includeWithNoIPAddr bool) ([]nodeInfo, error) {
func getKubePeers(c kubernetes.Interface, includeWithNoIPAddr bool) ([]nodeInfo, error) {
nodeList, err := c.CoreV1().Nodes().List(api.ListOptions{})
if err != nil {
return nil, err
+1 -1
View File
@@ -10,7 +10,7 @@ import (
)
// based on k8s.io/kubernetes/pkg/controller/nodeipam/ipam/adapter.go
func setNodeNetworkUnavailableFalse(c *kubernetes.Clientset, nodeName string) error {
func setNodeNetworkUnavailableFalse(c kubernetes.Interface, nodeName string) error {
condition := v1.NodeCondition{
Type: v1.NodeNetworkUnavailable,
Status: v1.ConditionFalse,
+2 -2
View File
@@ -71,7 +71,7 @@ func (cml *configMapAnnotations) UpdatePeerList(list peerList) error {
}
// update the list of all peers that have gone through this code path
func addMyselfToPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, peerName, name string) (*peerList, error) {
func addMyselfToPeerList(cml *configMapAnnotations, c kubernetes.Interface, peerName, name string) (*peerList, error) {
var list *peerList
err := cml.LoopUpdate(func() error {
var err error
@@ -91,7 +91,7 @@ func addMyselfToPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, pee
return list, err
}
func checkIamInPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, peerName string) (bool, error) {
func checkIamInPeerList(cml *configMapAnnotations, c kubernetes.Interface, peerName string) (bool, error) {
if err := cml.Init(); err != nil {
return false, err
}