Skip to content

Commit

Permalink
fix: Remove the pkg/k8sutil/client.go and replace it with HAMi/pkg/ut…
Browse files Browse the repository at this point in the history
…il/client in pkg/scheduler/scheduler.go

Signed-off-by: Shouren Yang <[email protected]>
  • Loading branch information
Shouren committed Dec 5, 2024
1 parent 24fd039 commit ae54f90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 51 deletions.
43 changes: 0 additions & 43 deletions pkg/k8sutil/client.go

This file was deleted.

3 changes: 2 additions & 1 deletion pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/Project-HAMi/HAMi/pkg/scheduler/config"
"github.com/Project-HAMi/HAMi/pkg/scheduler/policy"
"github.com/Project-HAMi/HAMi/pkg/util"
"github.com/Project-HAMi/HAMi/pkg/util/client"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (s *Scheduler) onDelPod(obj interface{}) {
}

func (s *Scheduler) Start() {
kubeClient, err := k8sutil.NewClient()
kubeClient, err := client.NewClient()

Check warning on line 129 in pkg/scheduler/scheduler.go

View check run for this annotation

Codecov / codecov/patch

pkg/scheduler/scheduler.go#L129

Added line #L129 was not covered by tests
check(err)
s.kubeClient = kubeClient
informerFactory := informers.NewSharedInformerFactoryWithOptions(s.kubeClient, time.Hour*1)
Expand Down
13 changes: 6 additions & 7 deletions pkg/util/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ var (
KubeClient kubernetes.Interface
)

func init() {
func GetClient() kubernetes.Interface {
var err error
KubeClient, err = NewClient()
if err != nil {
panic(err)
if KubeClient == nil {
KubeClient, err = NewClient()
if err != nil {
panic(err)

Check warning on line 38 in pkg/util/client/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/util/client/client.go#L36-L38

Added lines #L36 - L38 were not covered by tests
}
}
}

func GetClient() kubernetes.Interface {
return KubeClient
}

Expand Down

0 comments on commit ae54f90

Please sign in to comment.