Skip to content

Commit b375950

Browse files
committed
inlined creation of ProviderID, to reduce complexity.
1 parent dec7bfe commit b375950

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

pkg/services/baremetal/baremetal/baremetal.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import (
5555
// TODO: Implement logic for removal of unpaid servers.
5656

5757
const (
58-
providerIDPrefix = "hrobot://"
59-
6058
// requeueAfter gives the duration of time until the next reconciliation should be performed.
6159
requeueAfter = time.Second * 30
6260

@@ -684,7 +682,7 @@ func (s *Service) setProviderID(ctx context.Context) error {
684682
}
685683

686684
// set providerID
687-
providerID := providerIDFromServerID(host.Spec.ServerID)
685+
providerID := fmt.Sprintf("hrobot://%d", host.Spec.ServerID)
688686
s.scope.BareMetalMachine.Spec.ProviderID = &providerID
689687
s.scope.BareMetalMachine.Status.Phase = clusterv1.MachinePhaseRunning
690688

@@ -899,12 +897,6 @@ func checkForRequeueError(err error, errMessage string) (res reconcile.Result, r
899897
return reconcile.Result{}, fmt.Errorf("%s: %w", errMessage, err)
900898
}
901899

902-
// providerIDFromServerID returns the ProviderID. See HetznerBareMetalMachineSpec.ProviderID for
903-
// docs.
904-
func providerIDFromServerID(serverID int) string {
905-
return fmt.Sprintf("%s%d", providerIDPrefix, serverID)
906-
}
907-
908900
func analyzePatchError(err error, ignoreNotFound bool) error {
909901
if apierrors.IsConflict(err) {
910902
return &scope.RequeueAfterError{}

pkg/services/baremetal/baremetal/baremetal_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,6 @@ var _ = Describe("Test ensureClusterLabel", func() {
702702
)
703703
})
704704

705-
var _ = Describe("Test providerIDFromServerID", func() {
706-
Expect(providerIDFromServerID(42)).To(Equal("hrobot://42"))
707-
})
708-
709705
var _ = Describe("Test hostKey", func() {
710706
host := &infrav1.HetznerBareMetalHost{}
711707
host.Namespace = "namespace"

0 commit comments

Comments
 (0)