diff --git a/controllers/hetznercluster_controller.go b/controllers/hetznercluster_controller.go index e12178fa3..a49e97b76 100644 --- a/controllers/hetznercluster_controller.go +++ b/controllers/hetznercluster_controller.go @@ -497,11 +497,13 @@ func reconcileTargetSecret(ctx context.Context, clusterScope *scope.ClusterScope data := make(map[string][]byte) data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken] = hetznerToken - // Save robot credentials if available (even it empty) - robotUserName := tokenSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser] - data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser] = robotUserName - robotPassword := tokenSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotPassword] - data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotPassword] = robotPassword + // Save robot credentials if available + if clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser != "" { + robotUserName := tokenSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser] + data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser] = robotUserName + robotPassword := tokenSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotPassword] + data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotPassword] = robotPassword + } // Save network ID in secret if clusterScope.HetznerCluster.Spec.HCloudNetwork.Enabled {