Skip to content

Commit 0dec8dd

Browse files
committed
delint
1 parent 63b8677 commit 0dec8dd

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

api/v1alpha2/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
)
2828

2929
var (
30-
// GroupVersion is group version used to register these objects
30+
// GroupVersion is group version used to register these objects.
3131
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha2"}
3232

33-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
33+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3434
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3535

3636
// AddToScheme adds the types in this group-version to the given scheme.

api/v1alpha2/proxmoxmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ type ProxmoxMachineStatus struct {
490490
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
491491
}
492492

493-
// TODO: Unfuck machine status
494493
// IPAddresses stores the IP addresses of a network interface. Used for status
494+
// TODO: Unfuck machine status
495495
type IPAddresses struct {
496496
// IPV4 is the IPv4 address.
497497
// +optional

internal/controller/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/proxmox/proxmoxtest"
3232
"github.com/ionos-cloud/cluster-api-provider-proxmox/test/helpers"
33+
3334
// +kubebuilder:scaffold:imports
3435

3536
ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"

internal/service/vmservice/ip.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ func reconcileIPAddresses(ctx context.Context, machineScope *scope.MachineScope)
6767

6868
// update the status.IpAddr.
6969

70-
// TODO: Unfuck
71-
statusAddresses := make(map[string]*infrav1alpha2.IPAddresses)
72-
70+
statusAddresses := make(map[string]*infrav1alpha2.IPAddresses, len(addresses))
7371
for k, v := range addresses {
7472
if _, e := statusAddresses[k]; !e {
7573
statusAddresses[k] = new(infrav1alpha2.IPAddresses)
7674
}
77-
if strings.Contains("::", v) {
78-
statusAddresses[k].IPV6 = append(statusAddresses[k].IPV6, v)
79-
} else {
75+
if isIPV4(v) {
8076
statusAddresses[k].IPV4 = append(statusAddresses[k].IPV4, v)
77+
} else {
78+
statusAddresses[k].IPV6 = append(statusAddresses[k].IPV6, v)
8179
}
8280
}
8381
machineScope.Logger.V(4).Info("updating ProxmoxMachine.status.ipAddresses.")
@@ -94,7 +92,7 @@ func findIPAddress(ctx context.Context, machineScope *scope.MachineScope, device
9492
return machineScope.IPAMHelper.GetIPAddress(ctx, key)
9593
}
9694

97-
// findIPAddressesByPool attempts to return all ip addresses belonging to a device
95+
// findIPAddressesByPool attempts to return all ip addresses belonging to a device.
9896
func findIPAddressesByPool(ctx context.Context, machineScope *scope.MachineScope, device string, poolRef corev1.TypedLocalObjectReference) ([]ipamv1.IPAddress, error) {
9997
addresses, err := machineScope.IPAMHelper.GetIPAddressByPool(ctx, poolRef)
10098
if err != nil {

pkg/kubernetes/ipam/ipam.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ import (
3939
infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2"
4040
)
4141

42+
const (
43+
globalInClusterIPPool = "GlobalInClusterIPPool"
44+
inClusterIPPool = "InClusterIPPool"
45+
)
46+
4247
// Helper provides handling of ipam objects such as, InClusterPool, IPAddressClaim.
4348
type Helper struct {
4449
ctrlClient client.Client
@@ -200,13 +205,13 @@ func (h *Helper) GetIPPoolAnnotations(ctx context.Context, ipAddress *ipamv1.IPA
200205
Name: poolRef.Name,
201206
}
202207

203-
if poolRef.Kind == "InClusterIPPool" {
208+
if poolRef.Kind == inClusterIPPool {
204209
ipPool, err := h.GetInClusterIPPool(ctx, key)
205210
annotations = ipPool.ObjectMeta.Annotations
206211
if err != nil {
207212
return nil, err
208213
}
209-
} else if poolRef.Kind == "GlobalInClusterIPPool" {
214+
} else if poolRef.Kind == globalInClusterIPPool {
210215
ipPool, err := h.GetGlobalInClusterIPPool(ctx, key)
211216
annotations = ipPool.ObjectMeta.Annotations
212217
if err != nil {
@@ -240,7 +245,7 @@ func (h *Helper) CreateIPAddressClaim(ctx context.Context, owner client.Object,
240245
if err != nil {
241246
return err
242247
}
243-
case ref.Kind == "InClusterIPPool":
248+
case ref.Kind == inClusterIPPool:
244249
pool, err := h.GetInClusterIPPool(ctx, ref)
245250
if err != nil {
246251
return errors.Wrapf(err, "unable to find inclusterpool for cluster %s", h.cluster.Name)
@@ -250,7 +255,7 @@ func (h *Helper) CreateIPAddressClaim(ctx context.Context, owner client.Object,
250255
if err != nil {
251256
return err
252257
}
253-
case ref.Kind == "GlobalInClusterIPPool":
258+
case ref.Kind == globalInClusterIPPool:
254259
pool, err := h.GetGlobalInClusterIPPool(ctx, ref)
255260
if err != nil {
256261
return errors.Wrapf(err, "unable to find global inclusterpool for cluster %s", h.cluster.Name)
@@ -302,7 +307,7 @@ func (h *Helper) CreateIPAddressClaimV2(ctx context.Context, owner client.Object
302307
suffix := infrav1.DefaultSuffix
303308

304309
switch {
305-
case ref.Kind == "InClusterIPPool":
310+
case ref.Kind == inClusterIPPool:
306311
pool, err := h.GetInClusterIPPool(ctx, ref)
307312
if err != nil {
308313
return errors.Wrapf(err, "unable to find inclusterpool for cluster %s", h.cluster.Name)
@@ -312,7 +317,7 @@ func (h *Helper) CreateIPAddressClaimV2(ctx context.Context, owner client.Object
312317
if err != nil {
313318
return err
314319
}
315-
case ref.Kind == "GlobalInClusterIPPool":
320+
case ref.Kind == globalInClusterIPPool:
316321
pool, err := h.GetGlobalInClusterIPPool(ctx, ref)
317322
if err != nil {
318323
return errors.Wrapf(err, "unable to find global inclusterpool for cluster %s", h.cluster.Name)
@@ -368,9 +373,8 @@ func (h *Helper) GetIPAddress(ctx context.Context, key client.ObjectKey) (*ipamv
368373
// GetIPAddressByPool attempts to retrieve all IPAddresses belonging to a pool
369374
func (h *Helper) GetIPAddressByPool(ctx context.Context, poolRef corev1.TypedLocalObjectReference) ([]ipamv1.IPAddress, error) {
370375
addresses := &ipamv1.IPAddressList{}
371-
var out []ipamv1.IPAddress
372376

373-
//fieldSelector, err := fields.ParseSelector("spec.poolRef.name=" + poolRef.Name + ",spec.poolRef.kind=" + poolRef.Kind)
377+
// fieldSelector, err := fields.ParseSelector("spec.poolRef.name=" + poolRef.Name + ",spec.poolRef.kind=" + poolRef.Kind)
374378
fieldSelector, err := fields.ParseSelector("spec.poolRef.name=" + poolRef.Name)
375379
if err != nil {
376380
return nil, err
@@ -383,6 +387,7 @@ func (h *Helper) GetIPAddressByPool(ctx context.Context, poolRef corev1.TypedLoc
383387
return nil, err
384388
}
385389

390+
out := make([]ipamv1.IPAddress, 0, len(addresses.Items))
386391
for _, addr := range addresses.Items {
387392
groupVersion, _ := schema.ParseGroupVersion(addr.APIVersion)
388393
if groupVersion.Group != "ipam.cluster.x-k8s.io" {

0 commit comments

Comments
 (0)