Refactor: use Kubernetes.Interface instead of *Clientset
So we can call with a mock for testing
This commit is contained in:
1 parent
7dcd4bdf47
commit
c3ce052cc5
4 files changed
+6
-6
No files matched your search
@@ -26,11 +26,11 @@ type configMapAnnotations struct {
|
|||||||
cm *v1.ConfigMap
|
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{
|
return &configMapAnnotations{
|
||||||
Namespace: ns,
|
Namespace: ns,
|
||||||
ConfigMapName: configMapName,
|
ConfigMapName: configMapName,
|
||||||
Client: clientset.CoreV1(),
|
Client: c.CoreV1(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type nodeInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return the IP addresses of all nodes in the cluster
|
// 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{})
|
nodeList, err := c.CoreV1().Nodes().List(api.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// based on k8s.io/kubernetes/pkg/controller/nodeipam/ipam/adapter.go
|
// 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{
|
condition := v1.NodeCondition{
|
||||||
Type: v1.NodeNetworkUnavailable,
|
Type: v1.NodeNetworkUnavailable,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (cml *configMapAnnotations) UpdatePeerList(list peerList) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the list of all peers that have gone through this code path
|
// 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
|
var list *peerList
|
||||||
err := cml.LoopUpdate(func() error {
|
err := cml.LoopUpdate(func() error {
|
||||||
var err error
|
var err error
|
||||||
@@ -91,7 +91,7 @@ func addMyselfToPeerList(cml *configMapAnnotations, c *kubernetes.Clientset, pee
|
|||||||
return list, err
|
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 {
|
if err := cml.Init(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user