Skip to content

Commit

Permalink
Extract making medusa address to a functin
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek committed Jan 13, 2025
1 parent 1dd6f15 commit fbf67f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions controllers/medusa/medusatask_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func doPurge(ctx context.Context, task *medusav1alpha1.MedusaTask, pod *corev1.P
if found {
medusaPort = explicitPort
}
addr := net.JoinHostPort(pod.Status.PodIP, fmt.Sprint(medusaPort))
addr := makeMedusaAddress(pod, medusaPort)
if medusaClient, err := clientFactory.NewClient(ctx, addr); err != nil {
return nil, err
} else {
Expand All @@ -434,7 +434,7 @@ func prepareRestore(ctx context.Context, task *medusav1alpha1.MedusaTask, pod *c
if found {
medusaPort = explicitPort
}
addr := net.JoinHostPort(pod.Status.PodIP, fmt.Sprint(medusaPort))
addr := makeMedusaAddress(pod, medusaPort)
if medusaClient, err := clientFactory.NewClient(ctx, addr); err != nil {
return nil, err
} else {
Expand All @@ -450,7 +450,7 @@ func GetBackups(ctx context.Context, pod *corev1.Pod, clientFactory medusa.Clien
if found {
medusaPort = explicitPort
}
addr := net.JoinHostPort(pod.Status.PodIP, fmt.Sprint(medusaPort))
addr := makeMedusaAddress(pod, medusaPort)
if medusaClient, err := clientFactory.NewClient(ctx, addr); err != nil {
return nil, err
} else {
Expand Down Expand Up @@ -478,3 +478,7 @@ func (r *MedusaTaskReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&medusav1alpha1.MedusaTask{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Complete(r)
}

func makeMedusaAddress(medusaPod *corev1.Pod, medusaPort int) string {
return net.JoinHostPort(medusaPod.Status.PodIP, fmt.Sprint(medusaPort))
}

0 comments on commit fbf67f8

Please sign in to comment.