@@ -142,30 +142,17 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*packn
142
142
143
143
// If Metro or Facility are specified at the Machine level, we ignore the
144
144
// values set at the Cluster level
145
- var metro , facility string
145
+ facility := packetClusterSpec .Facility
146
+ metro := packetClusterSpec .Metro
146
147
147
148
if packetMachineSpec .Facility != "" || packetMachineSpec .Metro != "" {
148
149
metro = packetMachineSpec .Metro
149
150
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
- }
163
151
}
164
152
165
153
serverCreateOpts := & packngo.DeviceCreateRequest {
166
154
Hostname : req .MachineScope .Name (),
167
155
ProjectID : packetClusterSpec .ProjectID ,
168
- Facility : []string {facility },
169
156
Metro : metro ,
170
157
BillingCycle : packetMachineSpec .BillingCycle ,
171
158
Plan : packetMachineSpec .MachineType ,
@@ -175,6 +162,10 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*packn
175
162
UserData : userData ,
176
163
}
177
164
165
+ if facility != "" {
166
+ serverCreateOpts .Facility = []string {facility }
167
+ }
168
+
178
169
reservationIDs := strings .Split (packetMachineSpec .HardwareReservationID , "," )
179
170
180
171
// If there are no reservationIDs to process, go ahead and return early
0 commit comments