This repository was archived by the owner on Aug 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Ssh key #788
Closed
Closed
Ssh key #788
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,6 +180,26 @@ | |
|
|
||
| serverCreateOpts := metal.CreateDeviceRequest{} | ||
|
|
||
| var sshKeyInput []metal.SSHKeyInput | ||
| if len(packetMachineSpec.SSHKeys) > 0 { | ||
| for _, key := range packetMachineSpec.SSHKeys { | ||
| sshKeyInput = append(sshKeyInput, metal.SSHKeyInput{ | ||
| Label: metal.PtrString(fmt.Sprintf("cluster-api-provider-packet-%s", req.MachineScope.Name())), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All SSHKeys will have the same label per machine. Should we use a tag for the repeated values and a unique value per label? I'm pretty sure labels are optional. If we can't find a meaningful unique label, we could omit them. The tag would tell us what we need to know about the SSHKey. If Label is required, perhaps it could suffix the label you've provided with some tail bytes of the SSH Key? (not the comment section of the key). |
||
| Key: metal.PtrString(key), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| /* | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the unused code |
||
| var sshKeyInput metal.SSHKeyInput | ||
| if len(packetMachineSpec.SSHKeys) > 0 { | ||
| sshKeyInput = metal.SSHKeyInput{ | ||
| Label: metal.PtrString("cluster-api-provider-packet"), | ||
| Key: metal.PtrString(packetMachineSpec.SSHKeys[0]), | ||
| } | ||
| } | ||
| */ | ||
|
|
||
| if facility != "" { | ||
| serverCreateOpts.DeviceCreateInFacilityInput = &metal.DeviceCreateInFacilityInput{ | ||
| Hostname: &hostname, | ||
|
|
@@ -188,6 +208,7 @@ | |
| Plan: req.MachineScope.PacketMachine.Spec.MachineType, | ||
| OperatingSystem: req.MachineScope.PacketMachine.Spec.OS, | ||
| IpxeScriptUrl: &req.MachineScope.PacketMachine.Spec.IPXEUrl, | ||
| SshKeys: sshKeyInput, | ||
| Tags: tags, | ||
| Userdata: &userData, | ||
| } | ||
|
|
@@ -199,6 +220,7 @@ | |
| Plan: req.MachineScope.PacketMachine.Spec.MachineType, | ||
| OperatingSystem: req.MachineScope.PacketMachine.Spec.OS, | ||
| IpxeScriptUrl: &req.MachineScope.PacketMachine.Spec.IPXEUrl, | ||
| SshKeys: sshKeyInput, | ||
| Tags: tags, | ||
| Userdata: &userData, | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave out the
ifconditional. The for loop will only append sshKeyInput if SSHKeys exist (and are >0).Likewise, if the SSHKeys are nil or 0, sshKeyInput will be nil when sent to the Request object.