Skip to content

Commit

Permalink
Merge pull request #1024 from syself/target-secret-robot
Browse files Browse the repository at this point in the history
🐛 Ensure secret contains non-empty creds
  • Loading branch information
janiskemper authored Oct 30, 2023
2 parents 5fa9b05 + 938b5d9 commit d2ce008
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions controllers/hetznercluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d2ce008

Please sign in to comment.