@@ -198,6 +198,9 @@ func (r *NautobotReconciler) syncDeviceTypes(ctx context.Context,
198198) error {
199199 log := logf .FromContext (ctx )
200200 log .Info ("syncing device types" , "count" , len (deviceTypeMap ))
201+ if len (deviceTypeMap ) == 0 {
202+ return nil
203+ }
201204 syncSvc := sync .NewDeviceTypeSync (nautobotClient )
202205 if err := syncSvc .SyncAll (ctx , deviceTypeMap ); err != nil {
203206 return fmt .Errorf ("failed to sync device types: %w" , err )
@@ -207,12 +210,15 @@ func (r *NautobotReconciler) syncDeviceTypes(ctx context.Context,
207210
208211func (r * NautobotReconciler ) syncRackGroup (ctx context.Context ,
209212 nautobotClient * nbClient.NautobotClient ,
210- locationType map [string ]string ,
213+ rackGroup map [string ]string ,
211214) error {
212215 log := logf .FromContext (ctx )
213- log .Info ("syncing rack group" , "count" , len (locationType ))
216+ log .Info ("syncing rack group" , "count" , len (rackGroup ))
217+ if len (rackGroup ) == 0 {
218+ return nil
219+ }
214220 syncSvc := sync .NewRackGroupSync (nautobotClient )
215- if err := syncSvc .SyncAll (ctx , locationType ); err != nil {
221+ if err := syncSvc .SyncAll (ctx , rackGroup ); err != nil {
216222 return fmt .Errorf ("failed to sync rack group: %w" , err )
217223 }
218224 return nil
@@ -224,6 +230,9 @@ func (r *NautobotReconciler) syncRack(ctx context.Context,
224230) error {
225231 log := logf .FromContext (ctx )
226232 log .Info ("syncing racks" , "count" , len (rackData ))
233+ if len (rackData ) == 0 {
234+ return nil
235+ }
227236 syncSvc := sync .NewRackSync (nautobotClient )
228237 if err := syncSvc .SyncAll (ctx , rackData ); err != nil {
229238 return fmt .Errorf ("failed to sync racks: %w" , err )
@@ -237,6 +246,9 @@ func (r *NautobotReconciler) syncLocation(ctx context.Context,
237246) error {
238247 log := logf .FromContext (ctx )
239248 log .Info ("syncing location types" , "count" , len (locationType ))
249+ if len (locationType ) == 0 {
250+ return nil
251+ }
240252 syncSvc := sync .NewLocationSync (nautobotClient )
241253 if err := syncSvc .SyncAll (ctx , locationType ); err != nil {
242254 return fmt .Errorf ("failed to sync location types: %w" , err )
@@ -250,6 +262,9 @@ func (r *NautobotReconciler) syncLocationTypes(ctx context.Context,
250262) error {
251263 log := logf .FromContext (ctx )
252264 log .Info ("syncing location types" , "count" , len (locationType ))
265+ if len (locationType ) == 0 {
266+ return nil
267+ }
253268 syncSvc := sync .NewLocationTypeSync (nautobotClient )
254269 if err := syncSvc .SyncAll (ctx , locationType ); err != nil {
255270 return fmt .Errorf ("failed to sync location types: %w" , err )
0 commit comments