@@ -93,7 +93,11 @@ func handleEvent(credentialsDir, baseName string, hcloudClient *hcloud.Client, r
9393
9494 case "hcloud" :
9595 // This case is executed, when the process is running on a local machine.
96- return loadHcloudCredentials (credentialsDir , hcloudClient )
96+ err := loadHcloudCredentials (credentialsDir , hcloudClient )
97+ if err != nil {
98+ return fmt .Errorf ("handleEvent hcloud: %w" , err )
99+ }
100+ return nil
97101
98102 case "..data" :
99103 // This case is executed, when the secrets are mounted in a Kubernetes pod.
@@ -102,14 +106,19 @@ func handleEvent(credentialsDir, baseName string, hcloudClient *hcloud.Client, r
102106 // This means the files/symlinks don't change. When the secrets get changed, then
103107 // a new ..data directory gets created. This is done by Kubernetes to make the
104108 // update of all files atomic.
105- err = loadHcloudCredentials (credentialsDir , hcloudClient )
106- if err != nil {
107- return err
109+ if hcloudClient != nil {
110+ err = loadHcloudCredentials (credentialsDir , hcloudClient )
111+ if err != nil {
112+ return fmt .Errorf ("handleEvent ..data loadHcloudCredentials: %w" , err )
113+ }
108114 }
109- if robotClient == nil {
110- return nil
115+ if robotClient != nil {
116+ err := loadRobotCredentials (credentialsDir , robotClient )
117+ if err != nil {
118+ return fmt .Errorf ("handleEvent ..data loadRobotCredentials: %w" , err )
119+ }
111120 }
112- return loadRobotCredentials ( credentialsDir , robotClient )
121+ return nil
113122
114123 default :
115124 klog .Infof ("Ignoring fsnotify event for file %q: %s" , baseName , event .String ())
@@ -192,7 +201,7 @@ func loadHcloudCredentials(credentialsDir string, hcloudClient *hcloud.Client) e
192201
193202 token , err := readHcloudCredentials (credentialsDir )
194203 if err != nil {
195- return err
204+ return fmt . Errorf ( "loadHcloudCredentials: %w" , err )
196205 }
197206
198207 if len (token ) != 64 {
@@ -218,7 +227,7 @@ func loadHcloudCredentials(credentialsDir string, hcloudClient *hcloud.Client) e
218227func GetInitialHcloudCredentialsFromDirectory (credentialsDir string ) (string , error ) {
219228 token , err := readHcloudCredentials (credentialsDir )
220229 if err != nil {
221- return "" , fmt .Errorf ("readHcloudCredentials: %w" , err )
230+ return "" , fmt .Errorf ("Getting initial credentials: readHcloudCredentials: %w" , err )
222231 }
223232
224233 // Update global variable
0 commit comments