@@ -180,6 +180,26 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
180180
181181 serverCreateOpts := metal.CreateDeviceRequest {}
182182
183+ var sshKeyInput []metal.SSHKeyInput
184+ if len (packetMachineSpec .SSHKeys ) > 0 {
185+ for _ , key := range packetMachineSpec .SSHKeys {
186+ sshKeyInput = append (sshKeyInput , metal.SSHKeyInput {
187+ Label : metal .PtrString (fmt .Sprintf ("cluster-api-provider-packet-%s" , req .MachineScope .Name ())),
188+ Key : metal .PtrString (key ),
189+ })
190+ }
191+ }
192+
193+ /*
194+ var sshKeyInput metal.SSHKeyInput
195+ if len(packetMachineSpec.SSHKeys) > 0 {
196+ sshKeyInput = metal.SSHKeyInput{
197+ Label: metal.PtrString("cluster-api-provider-packet"),
198+ Key: metal.PtrString(packetMachineSpec.SSHKeys[0]),
199+ }
200+ }
201+ */
202+
183203 if facility != "" {
184204 serverCreateOpts .DeviceCreateInFacilityInput = & metal.DeviceCreateInFacilityInput {
185205 Hostname : & hostname ,
@@ -188,6 +208,7 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
188208 Plan : req .MachineScope .PacketMachine .Spec .MachineType ,
189209 OperatingSystem : req .MachineScope .PacketMachine .Spec .OS ,
190210 IpxeScriptUrl : & req .MachineScope .PacketMachine .Spec .IPXEUrl ,
211+ SshKeys : sshKeyInput ,
191212 Tags : tags ,
192213 Userdata : & userData ,
193214 }
@@ -199,6 +220,7 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
199220 Plan : req .MachineScope .PacketMachine .Spec .MachineType ,
200221 OperatingSystem : req .MachineScope .PacketMachine .Spec .OS ,
201222 IpxeScriptUrl : & req .MachineScope .PacketMachine .Spec .IPXEUrl ,
223+ SshKeys : sshKeyInput ,
202224 Tags : tags ,
203225 Userdata : & userData ,
204226 }
0 commit comments