Skip to content

Commit

Permalink
fix: create default site if it doesn't exist yet
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Mar 15, 2024
1 parent e1ced6e commit f7771e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
DefaultOSVersion string = "Generic Version"
DefaultManufacturer string = "Generic Manufacturer"
DefaultModel string = "Generic Model"
DefaultSite string = "DefaultSite"
)

// Default mappings of sources to colors (for tags).
Expand Down
4 changes: 2 additions & 2 deletions internal/source/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func MatchVlanToTenant(ctx context.Context, nbi *inventory.NetboxInventory, vlan

// Function that matches Host from hostName to Site using hostSiteRelations.
//
// In case that there is not match or hostSiteRelations is nil, it will return nil.
// In case that there is not match or hostSiteRelations is nil, it will return default site.
func MatchHostToSite(ctx context.Context, nbi *inventory.NetboxInventory, hostName string, hostSiteRelations map[string]string) (*objects.Site, error) {
if hostSiteRelations == nil {
return nil, nil
Expand All @@ -151,7 +151,7 @@ func MatchHostToSite(ctx context.Context, nbi *inventory.NetboxInventory, hostNa
}
return site, nil
}
return nil, nil
return nbi.SitesIndexByName[constants.DefaultSite], nil
}

// Function that matches Host from hostName to Tenant using hostTenantRelations.
Expand Down

0 comments on commit f7771e4

Please sign in to comment.