-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ssh key #788
base: main
Are you sure you want to change the base?
Ssh key #788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
} | ||
|
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
if
conditional. 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.