Skip to content

Commit

Permalink
feat: add sshkeys handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dirien committed Sep 12, 2024
1 parent 988c62d commit 61ea7f8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/cloud/packet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal

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())),
Key: metal.PtrString(key),
})
}
}

/*

Check failure on line 193 in pkg/cloud/packet/client.go

View workflow job for this annotation

GitHub Actions / Validate lint

commentedOutCode: may want to remove commented-out code (gocritic)
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,
Expand All @@ -188,6 +208,7 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
Plan: req.MachineScope.PacketMachine.Spec.MachineType,
OperatingSystem: req.MachineScope.PacketMachine.Spec.OS,
IpxeScriptUrl: &req.MachineScope.PacketMachine.Spec.IPXEUrl,
SshKeys: sshKeyInput,
Tags: tags,
Userdata: &userData,
}
Expand All @@ -199,6 +220,7 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
Plan: req.MachineScope.PacketMachine.Spec.MachineType,
OperatingSystem: req.MachineScope.PacketMachine.Spec.OS,
IpxeScriptUrl: &req.MachineScope.PacketMachine.Spec.IPXEUrl,
SshKeys: sshKeyInput,
Tags: tags,
Userdata: &userData,
}
Expand Down

0 comments on commit 61ea7f8

Please sign in to comment.