Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 406a869

Browse files
committed
allow overriding facility
1 parent 75079d4 commit 406a869

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

api/v1alpha3/packetmachine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ type PacketMachineSpec struct {
3838
MachineType string `json:"machineType"`
3939
SshKeys []string `json:"sshKeys,omitempty"`
4040

41+
// Facility represents the Packet facility for this cluster.
42+
// Override from the PacketCluster spec.
43+
Facility string `json:"facility,omitempty"`
44+
4145
// IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider.
4246
// Note that OS should also be set to "custom_ipxe" if using this value.
4347
// +optional

pkg/cloud/packet/client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,16 @@ func (p *PacketClient) NewDevice(req CreateDeviceRequest) (*packngo.Device, erro
112112

113113
userData = stringWriter.String()
114114

115+
// Allow to override the facility for each PacketMachineTemplate
116+
var facility = req.MachineScope.PacketCluster.Spec.Facility
117+
if req.MachineScope.PacketMachine.Spec.Facility != "" {
118+
facility = req.MachineScope.PacketMachine.Spec.Facility
119+
}
120+
115121
serverCreateOpts := &packngo.DeviceCreateRequest{
116122
Hostname: req.MachineScope.Name(),
117123
ProjectID: req.MachineScope.PacketCluster.Spec.ProjectID,
118-
Facility: []string{req.MachineScope.PacketCluster.Spec.Facility},
124+
Facility: []string{facility},
119125
BillingCycle: req.MachineScope.PacketMachine.Spec.BillingCycle,
120126
HardwareReservationID: req.MachineScope.PacketMachine.Spec.HardwareReservationID,
121127
Plan: req.MachineScope.PacketMachine.Spec.MachineType,

0 commit comments

Comments
 (0)