Skip to content

Commit

Permalink
🌱Add check to disallow hcloud servers without ssh key (#1413)
Browse files Browse the repository at this point in the history
* 🌱Add check to disallow hcloud servers without ssh key

* 🌱Minor change

* 🌱Minor change
  • Loading branch information
yrs147 authored Aug 10, 2024
1 parent 705c1bd commit 9a170a2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/services/hcloud/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,17 @@ func (s *Service) createServer(ctx context.Context) (*hcloud.Server, error) {
}
}

if len(sshKeySpecs) == 0 {
conditions.MarkFalse(
s.scope.HCloudMachine,
infrav1.ServerCreateSucceededCondition,
infrav1.SSHKeyNotFoundReason,
clusterv1.ConditionSeverityError,
"No SSH key configured for the server. Please add an SSH key",
)
return nil, errServerCreateNotPossible
}

// get all ssh keys that are stored in HCloud API
sshKeysAPI, err := s.scope.HCloudClient.ListSSHKeys(ctx, hcloud.SSHKeyListOpts{})
if err != nil {
Expand Down

0 comments on commit 9a170a2

Please sign in to comment.