Skip to content

Commit

Permalink
Merge branch 'add-test-cloud-service-loadbalancer' into add-test-clou…
Browse files Browse the repository at this point in the history
…d-service-obj
  • Loading branch information
komer3 committed Mar 21, 2024
2 parents 4fce676 + f3362b0 commit 0d39ba0
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 217 deletions.
4 changes: 2 additions & 2 deletions cloud/scope/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// LinodeClient is an interface that defines the methods that a Linode client must have to interact with Linode.
// It defines all the functions that are required to create, delete, and get resources
// from Linode such as object storage buckets, node balancers, linodes, and VPCs.
type MachineScopeLinodeClient interface {
type MachineLinodeClient interface {
LinodeNodeBalancerClient
LinodeInstanceClient
LinodeVPCClient
Expand Down Expand Up @@ -53,7 +53,7 @@ type LinodeObjectStorageClient interface {
DeleteObjectStorageKey(ctx context.Context, keyID int) error
}

type LinodeObjectStorageBucketBuilder func(apiKey string) (LinodeObjectStorageClient, error)
type LinodeObjectStorageClientBuilder func(apiKey string) (LinodeObjectStorageClient, error)

func CreateLinodeObjectStorageBucketClient(apiKey string) (LinodeObjectStorageClient, error) {
return CreateLinodeClient(apiKey)
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type MachineScope struct {
PatchHelper *patch.Helper
Cluster *clusterv1.Cluster
Machine *clusterv1.Machine
LinodeClient MachineScopeLinodeClient
LinodeClient MachineLinodeClient
LinodeCluster *infrav1alpha1.LinodeCluster
LinodeMachine *infrav1alpha1.LinodeMachine
}
Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/object_storage_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

type ObjectStorageBucketScopeParams struct {
Client k8sClient
LinodeClientBuilder LinodeObjectStorageBucketBuilder
LinodeClientBuilder LinodeObjectStorageClientBuilder
Bucket *infrav1alpha1.LinodeObjectStorageBucket
Logger *logr.Logger
}
Expand Down
15 changes: 0 additions & 15 deletions cloud/services/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ func AddNodeToNB(
return nil
}

if machineScope.LinodeMachine.Spec.InstanceID == nil {
return errors.New("no InstanceID set for LinodeMachine.Spec")
}

// Get the private IP that was assigned
addresses, err := machineScope.LinodeClient.GetInstanceIPAddresses(ctx, *machineScope.LinodeMachine.Spec.InstanceID)
if err != nil {
Expand All @@ -145,13 +141,6 @@ func AddNodeToNB(
return err
}

if machineScope.LinodeCluster.Spec.Network.NodeBalancerID == nil {
err := errors.New("nil NodeBalancer ID")
logger.Error(err, "NodeBalancer ID is nil")

return err
}

_, err = machineScope.LinodeClient.CreateNodeBalancerNode(
ctx,
*machineScope.LinodeCluster.Spec.Network.NodeBalancerID,
Expand Down Expand Up @@ -182,10 +171,6 @@ func DeleteNodeFromNB(
return nil
}

if machineScope.LinodeMachine.Spec.InstanceID == nil {
return errors.New("no InstanceID set for LinodeMachine.Spec")
}

if machineScope.LinodeCluster.Spec.ControlPlaneEndpoint.Host == "" {
logger.Info("NodeBalancer already deleted, no NodeBalancer backend Node to remove")

Expand Down
Loading

0 comments on commit 0d39ba0

Please sign in to comment.