Skip to content

Commit

Permalink
style(v2alpha2): format rebalance controller
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Jul 21, 2023
1 parent f6b4efa commit e7d0858
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 363 deletions.
26 changes: 19 additions & 7 deletions controllers/apps/v1beta4/emqx_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,29 @@ func (r *EmqxReconciler) processResult(subResult subResult, instance appsv1beta4
return subResult.result, subResult.err
}

func NewRequesterByPod(client client.Client, instance appsv1beta4.Emqx, pod *corev1.Pod) (innerReq.RequesterInterface, error) {
username, password, err := getBootstrapUser(context.Background(), client, instance)
func NewRequesterByPod(k8sClient client.Client, instance appsv1beta4.Emqx) (innerReq.RequesterInterface, error) {
username, password, err := getBootstrapUser(context.Background(), k8sClient, instance)
if err != nil {
return nil, err
}

Check warning on line 140 in controllers/apps/v1beta4/emqx_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v1beta4/emqx_controller.go#L136-L140

Added lines #L136 - L140 were not covered by tests

return &innerReq.Requester{
Host: fmt.Sprintf("%s:8081", pod.Status.PodIP),
Username: username,
Password: password,
}, nil
podList := &corev1.PodList{}
_ = k8sClient.List(context.Background(), podList,
client.InNamespace(instance.GetNamespace()),
client.MatchingLabels(instance.GetSpec().GetTemplate().Labels),
)
for _, pod := range podList.Items {
for _, c := range pod.Status.Conditions {
if c.Type == corev1.PodReady && c.Status == corev1.ConditionTrue {
return &innerReq.Requester{
Host: fmt.Sprintf("%s:8081", pod.Status.PodIP),
Username: username,
Password: password,
}, nil
}

Check warning on line 155 in controllers/apps/v1beta4/emqx_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v1beta4/emqx_controller.go#L142-L155

Added lines #L142 - L155 were not covered by tests
}
}
return nil, emperror.New("failed to get ready pod")

Check warning on line 158 in controllers/apps/v1beta4/emqx_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/apps/v1beta4/emqx_controller.go#L158

Added line #L158 was not covered by tests
}

func newRequesterBySvc(client client.Client, instance appsv1beta4.Emqx) (innerReq.RequesterInterface, error) {
Expand Down
Loading

0 comments on commit e7d0858

Please sign in to comment.