Skip to content

Commit

Permalink
Reference "k8s.io/api/core/v1" as corev1, not apiv1
Browse files Browse the repository at this point in the history
  • Loading branch information
frobware committed Feb 4, 2020
1 parent 5c697b2 commit be68af5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package clusterapi
import (
"fmt"

apiv1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
kubeinformers "k8s.io/client-go/informers"
Expand Down Expand Up @@ -53,7 +53,7 @@ type machineController struct {
type machineSetFilterFunc func(machineSet *v1alpha1.MachineSet) error

func indexNodeByNodeProviderID(obj interface{}) ([]string, error) {
if node, ok := obj.(*apiv1.Node); ok {
if node, ok := obj.(*corev1.Node); ok {
return []string{node.Spec.ProviderID}, nil
}
return []string{}, nil
Expand Down Expand Up @@ -147,7 +147,7 @@ func (c *machineController) run(stopCh <-chan struct{}) error {
// node.Spec.ProviderID as the key. Returns nil if either the Node by
// node.Spec.ProviderID cannot be found or if the node has no machine
// annotation. A DeepCopy() of the object is returned on success.
func (c *machineController) findMachineByNodeProviderID(node *apiv1.Node) (*v1alpha1.Machine, error) {
func (c *machineController) findMachineByNodeProviderID(node *corev1.Node) (*v1alpha1.Machine, error) {
objs, err := c.nodeInformer.GetIndexer().ByIndex(nodeProviderIDIndex, node.Spec.ProviderID)
if err != nil {
return nil, err
Expand All @@ -160,7 +160,7 @@ func (c *machineController) findMachineByNodeProviderID(node *apiv1.Node) (*v1al
return nil, fmt.Errorf("internal error; expected len==1, got %v", n)
}

node, ok := objs[0].(*apiv1.Node)
node, ok := objs[0].(*corev1.Node)
if !ok {
return nil, fmt.Errorf("internal error; unexpected type %T", node)
}
Expand All @@ -175,7 +175,7 @@ func (c *machineController) findMachineByNodeProviderID(node *apiv1.Node) (*v1al
// findNodeByNodeName find the Node object keyed by node.Name. Returns
// nil if it cannot be found. A DeepCopy() of the object is returned
// on success.
func (c *machineController) findNodeByNodeName(name string) (*apiv1.Node, error) {
func (c *machineController) findNodeByNodeName(name string) (*corev1.Node, error) {
item, exists, err := c.nodeInformer.GetIndexer().GetByKey(name)
if err != nil {
return nil, err
Expand All @@ -185,7 +185,7 @@ func (c *machineController) findNodeByNodeName(name string) (*apiv1.Node, error)
return nil, nil
}

node, ok := item.(*apiv1.Node)
node, ok := item.(*corev1.Node)
if !ok {
return nil, fmt.Errorf("internal error; unexpected type %T", node)
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func (c *machineController) machineSetNodeGroups() ([]*nodegroup, error) {
}

func (c *machineController) machineDeploymentNodeGroups() ([]*nodegroup, error) {
machineDeployments, err := c.machineDeploymentInformer.Lister().MachineDeployments(apiv1.NamespaceAll).List(labels.Everything())
machineDeployments, err := c.machineDeploymentInformer.Lister().MachineDeployments(corev1.NamespaceAll).List(labels.Everything())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -361,7 +361,7 @@ func (c *machineController) nodeGroups() ([]*nodegroup, error) {
return append(machineSets, machineDeployments...), nil
}

func (c *machineController) nodeGroupForNode(node *apiv1.Node) (*nodegroup, error) {
func (c *machineController) nodeGroupForNode(node *corev1.Node) (*nodegroup, error) {
machine, err := c.findMachineByNodeProviderID(node)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"time"

apiv1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
Expand Down Expand Up @@ -89,7 +89,7 @@ func (ng *nodegroup) IncreaseSize(delta int) error {
// either on failure or if the given node doesn't belong to this node
// group. This function should wait until node group size is updated.
// Implementation required.
func (ng *nodegroup) DeleteNodes(nodes []*apiv1.Node) error {
func (ng *nodegroup) DeleteNodes(nodes []*corev1.Node) error {
for _, node := range nodes {
actualNodeGroup, err := ng.machineController.nodeGroupForNode(node)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package clusterapi
import (
"reflect"

apiv1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
"k8s.io/autoscaler/cluster-autoscaler/config"
Expand Down Expand Up @@ -77,7 +77,7 @@ func (p *provider) NodeGroups() []cloudprovider.NodeGroup {
return result
}

func (p *provider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error) {
func (p *provider) NodeGroupForNode(node *corev1.Node) (cloudprovider.NodeGroup, error) {
ng, err := p.controller.nodeGroupForNode(node)
if err != nil {
return nil, err
Expand All @@ -100,7 +100,7 @@ func (*provider) NewNodeGroup(
machineType string,
labels map[string]string,
systemLabels map[string]string,
taints []apiv1.Taint,
taints []corev1.Taint,
extraResources map[string]resource.Quantity,
) (cloudprovider.NodeGroup, error) {
return nil, cloudprovider.ErrNotImplemented
Expand All @@ -115,7 +115,7 @@ func (p *provider) Refresh() error {
}

// GetInstanceID gets the instance ID for the specified node.
func (p *provider) GetInstanceID(node *apiv1.Node) string {
func (p *provider) GetInstanceID(node *corev1.Node) string {
return node.Spec.ProviderID
}

Expand Down

0 comments on commit be68af5

Please sign in to comment.