Skip to content

Commit

Permalink
🐛 Ensure secret contains non-empty creds
Browse files Browse the repository at this point in the history
Ensure that target secret contains only robot credentials if they are
not empty.
  • Loading branch information
janiskemper committed Oct 24, 2023
1 parent b0c2271 commit 938b5d9
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 938b5d9

Please sign in to comment.