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

Commit 5cf41bd

Browse files
committed
Clean up logic
Signed-off-by: Chris Privitere <[email protected]>
1 parent 0fb5663 commit 5cf41bd

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

pkg/cloud/packet/client.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,30 +142,17 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*packn
142142

143143
// If Metro or Facility are specified at the Machine level, we ignore the
144144
// values set at the Cluster level
145-
var metro, facility string
145+
facility := packetClusterSpec.Facility
146+
metro := packetClusterSpec.Metro
146147

147148
if packetMachineSpec.Facility != "" || packetMachineSpec.Metro != "" {
148149
metro = packetMachineSpec.Metro
149150
facility = packetMachineSpec.Facility
150-
// If both specified, metro takes precedence over facility
151-
if metro != "" {
152-
facility = ""
153-
}
154-
} else {
155-
// Machine level is empty so set facility and metro to cluster level values
156-
facility = packetClusterSpec.Facility
157-
metro = packetClusterSpec.Metro
158-
159-
// If both specified, metro takes precedence over facility
160-
if metro != "" {
161-
facility = ""
162-
}
163151
}
164152

165153
serverCreateOpts := &packngo.DeviceCreateRequest{
166154
Hostname: req.MachineScope.Name(),
167155
ProjectID: packetClusterSpec.ProjectID,
168-
Facility: []string{facility},
169156
Metro: metro,
170157
BillingCycle: packetMachineSpec.BillingCycle,
171158
Plan: packetMachineSpec.MachineType,
@@ -175,6 +162,10 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*packn
175162
UserData: userData,
176163
}
177164

165+
if facility != "" {
166+
serverCreateOpts.Facility = []string{facility}
167+
}
168+
178169
reservationIDs := strings.Split(packetMachineSpec.HardwareReservationID, ",")
179170

180171
// If there are no reservationIDs to process, go ahead and return early

0 commit comments

Comments
 (0)