Skip to content

Commit

Permalink
Use once
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Dec 1, 2023
1 parent 22ec468 commit 3a50694
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions apis/kubedb/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ import (
)

var (
mutex sync.Mutex
once sync.Once
DefaultClient client.Client
)

func SetDefaultClient(kc client.Client) {
if DefaultClient == nil {
mutex.Lock()
defer mutex.Unlock()
once.Do(func() {
DefaultClient = kc
}
})
}

type InitSpec struct {
Expand Down

0 comments on commit 3a50694

Please sign in to comment.