Skip to content

Commit

Permalink
move var at the top.
Browse files Browse the repository at this point in the history
  • Loading branch information
guettli committed Dec 16, 2024
1 parent 3a64a7e commit 3279e78
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions internal/hotreload/hotreload.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ import (
"k8s.io/klog/v2"
)

var (
oldRobotUser string
oldRobotPassword string
RobotReloadCounter uint64
robotMutex sync.Mutex

oldHcloudToken string
HcloudTokenReloadCounter uint64
hcloudMutex sync.Mutex
)

// Watch the mounted secrets. Reload the credentials, when the files get updated. The robotClient can be nil.
func Watch(hetznerSecretDirectory string, hcloudClient *hcloud.Client, robotClient robotclient.Client) error {
watcher, err := fsnotify.NewWatcher()
Expand Down Expand Up @@ -80,13 +91,6 @@ func isValidEvent(event fsnotify.Event) bool {
return false
}

var (
oldRobotUser string
oldRobotPassword string
RobotReloadCounter uint64
robotMutex sync.Mutex
)

func LoadRobotCredentials(hetznerSecretDirectory string, robotClient robotclient.Client) error {
robotMutex.Lock()
defer robotMutex.Unlock()
Expand Down Expand Up @@ -122,12 +126,6 @@ func ReadRobotCredentialsFromDirectory(hetznerSecretDirectory string) (username,
return strings.TrimSpace(string(u)), strings.TrimSpace(string(p)), nil
}

var (
oldHcloudToken string
HcloudTokenReloadCounter uint64
hcloudMutex sync.Mutex
)

func LoadHcloudCredentials(hetznerSecretDirectory string, hcloudClient *hcloud.Client) error {
hcloudMutex.Lock()
defer hcloudMutex.Unlock()
Expand Down

0 comments on commit 3279e78

Please sign in to comment.