Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasfrank committed Nov 29, 2024
1 parent f6855f6 commit c7b1640
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 59 deletions.
2 changes: 1 addition & 1 deletion api/compute/v1alpha1/machinereservation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ReservationStatus struct {
type ReservationState string

const (
// ReservationStatePending means the Reservation is beeing reconciled.
// ReservationStatePending means the Reservation is being reconciled.
ReservationStatePending ReservationState = "Pending"
// ReservationStateAccepted means the pool accepted the reservation and reserved the requested resources.
ReservationStateAccepted ReservationState = "Accepted"
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/server/reservation_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package server
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/resource"

"github.com/go-logr/logr"
computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1"
Expand All @@ -18,6 +17,7 @@ import (
metav1alpha1 "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
machinepoolletv1alpha1 "github.com/ironcore-dev/ironcore/poollet/machinepoollet/api/v1alpha1"
"github.com/ironcore-dev/ironcore/utils/maps"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/apis/compute/machinereservation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ReservationStatus struct {
type ReservationState string

const (
// ReservationStatePending means the Reservation is beeing reconciled.
// ReservationStatePending means the Reservation is being reconciled.
ReservationStatePending MachineState = "Pending"
// ReservationStateAccepted means the pool accepted the reservation and reserved the requested resources.
ReservationStateAccepted MachineState = "Accepted"
Expand Down
13 changes: 0 additions & 13 deletions internal/registry/compute/reservation/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,3 @@ func (reservationStatusStrategy) WarningsOnUpdate(cxt context.Context, obj, old
type ResourceGetter interface {
Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
}

func getReservation(ctx context.Context, getter ResourceGetter, name string) (*compute.Reservation, error) {
obj, err := getter.Get(ctx, name, &metav1.GetOptions{})
if err != nil {
return nil, err
}

machine, ok := obj.(*compute.Reservation)
if !ok {
return nil, fmt.Errorf("unexpected object type %T", obj)
}
return machine, nil
}
43 changes: 0 additions & 43 deletions poollet/machinepoollet/controllers/reservation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/go-logr/logr"
"github.com/ironcore-dev/controller-utils/clientutils"
commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1"
computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1"
irimachine "github.com/ironcore-dev/ironcore/iri/apis/machine"
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
Expand Down Expand Up @@ -98,24 +97,6 @@ func (r *ReservationReconciler) listReservationsByReservationKey(ctx context.Con
return res.Reservations, nil
}

func (r *ReservationReconciler) getReservationByID(ctx context.Context, id string) (*iri.Reservation, error) {
res, err := r.MachineRuntime.ListReservations(ctx, &iri.ListReservationsRequest{
Filter: &iri.ReservationFilter{Id: id},
})
if err != nil {
return nil, fmt.Errorf("error listing reservations filtering by id: %w", err)
}

switch len(res.Reservations) {
case 0:
return nil, status.Errorf(codes.NotFound, "reservation %s not found", id)
case 1:
return res.Reservations[0], nil
default:
return nil, fmt.Errorf("multiple reservations found for id %s", id)
}
}

func (r *ReservationReconciler) deleteReservations(ctx context.Context, log logr.Logger, reservations []*iri.Reservation) (bool, error) {
var (
errs []error
Expand Down Expand Up @@ -368,20 +349,6 @@ func (r *ReservationReconciler) create(
return ctrl.Result{}, nil
}

func (r *ReservationReconciler) getReservationGeneration(iriReservation *iri.Reservation) (int64, error) {
return getAndParseFromStringMap(iriReservation.GetMetadata().GetAnnotations(),
v1alpha1.ReservationGenerationAnnotation,
parseInt64,
)
}

func (r *ReservationReconciler) getIRIReservationGeneration(iriReservation *iri.Reservation) (int64, error) {
return getAndParseFromStringMap(iriReservation.GetMetadata().GetAnnotations(),
v1alpha1.IRIReservationGenerationAnnotation,
parseInt64,
)
}

func (r *ReservationReconciler) updateStatus(
ctx context.Context,
log logr.Logger,
Expand Down Expand Up @@ -512,16 +479,6 @@ func ReservationAssignedToMachinePoolPredicate(machinePoolName string) predicate
})
}

func (r *ReservationReconciler) matchingWatchLabel() client.ListOption {
var labels map[string]string
if r.WatchFilterValue != "" {
labels = map[string]string{
commonv1alpha1.WatchLabel: r.WatchFilterValue,
}
}
return client.MatchingLabels(labels)
}

func (r *ReservationReconciler) SetupWithManager(mgr ctrl.Manager) error {
log := ctrl.Log.WithName("reservationpoollet")

Expand Down

0 comments on commit c7b1640

Please sign in to comment.