Skip to content

Commit

Permalink
fix: source tags should not be set in objects that are not scoped to …
Browse files Browse the repository at this point in the history
…source

This must be done to ensure idempotency
  • Loading branch information
bl4ko committed Jan 31, 2025
1 parent 3eb15cd commit 7d31349
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 118 deletions.
8 changes: 7 additions & 1 deletion cmd/netbox-ssot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ func main() {
minutes := int(duration.Minutes())
seconds := int((duration - time.Duration(minutes)*time.Minute).Seconds())
if successfullRun {
ssotLogger.Infof(mainCtx, "%s Syncing took %d min %d sec in total", constants.Rocket, minutes, seconds)
ssotLogger.Infof(
mainCtx,
"%s Syncing took %d min %d sec in total",
constants.Rocket,
minutes,
seconds,
)

Check warning on line 149 in cmd/netbox-ssot/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/netbox-ssot/main.go#L143-L149

Added lines #L143 - L149 were not covered by tests
} else {
for source := range encounteredErrors {
ssotLogger.Infof(mainCtx, "%s syncing of source %s failed", constants.WarningSign, source)
Expand Down
2 changes: 1 addition & 1 deletion internal/netbox/objects/virtualization.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type VMInterfaceMode struct {
var (
VMInterfaceModeAccess = VMInterfaceMode{Choice{Value: "access", Label: "Access"}}
VMInterfaceModeTagged = VMInterfaceMode{Choice{Value: "tagged", Label: "Tagged"}}
VMInterfaceModeTaggedAll = VMInterfaceMode{Choice{Value: "tagged-all", Label: "Tagged All"}}
VMInterfaceModeTaggedAll = VMInterfaceMode{Choice{Value: "tagged-all", Label: "Tagged (All)"}}
)

type VMInterface struct {
Expand Down
7 changes: 6 additions & 1 deletion internal/source/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ type Source interface {
type Config struct {
Logger *logger.Logger
SourceConfig *parser.SourceConfig
SourceTags []*objects.Tag
CustomCertPool *x509.CertPool
SourceNameTag *objects.Tag
SourceTypeTag *objects.Tag
Ctx context.Context //nolint:containedctx
CAFile string // path to the ca file
}

func (c Config) GetSourceTags() []*objects.Tag {
return []*objects.Tag{c.SourceNameTag, c.SourceTypeTag}

Check warning on line 33 in internal/source/common/common.go

View check run for this annotation

Codecov / codecov/patch

internal/source/common/common.go#L32-L33

Added lines #L32 - L33 were not covered by tests
}
22 changes: 11 additions & 11 deletions internal/source/dnac/dnac_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (ds *DnacSource) syncSites(nbi *inventory.NetboxInventory) error {
for _, site := range ds.Sites {
dnacSite := &objects.Site{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.Config.GetSourceTags(),

Check warning on line 22 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L22

Added line #L22 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
},
Expand Down Expand Up @@ -83,7 +83,7 @@ func (ds *DnacSource) syncVlans(nbi *inventory.NetboxInventory) error {
}
newVlan, err := nbi.AddVlan(ds.Ctx, &objects.Vlan{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 86 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L86

Added line #L86 was not covered by tests
Description: vlan.VLANType,
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
Expand All @@ -104,7 +104,7 @@ func (ds *DnacSource) syncVlans(nbi *inventory.NetboxInventory) error {
prefix := fmt.Sprintf("%s/%s", vlan.NetworkAddress, vlan.Prefix)
_, err = nbi.AddPrefix(ds.Ctx, &objects.Prefix{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 107 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L107

Added line #L107 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
},
Expand Down Expand Up @@ -274,7 +274,7 @@ func (ds *DnacSource) syncDevice(

nbDevice, err := nbi.AddDevice(ds.Ctx, &objects.Device{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 277 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L277

Added line #L277 was not covered by tests
Description: description,
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
Expand Down Expand Up @@ -385,7 +385,7 @@ func (ds *DnacSource) syncDeviceInterface(
nbIface, err := nbi.AddInterface(ds.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Description: strings.TrimSpace(ifaceDescription),
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 388 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L387-L388

Added lines #L387 - L388 were not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
},
Expand Down Expand Up @@ -551,7 +551,7 @@ func (ds *DnacSource) addIPAddressToInterface(

nbIPAddress, err := nbi.AddIPAddress(ds.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 554 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L554

Added line #L554 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
constants.CustomFieldArpEntryName: false,
Expand All @@ -575,7 +575,7 @@ func (ds *DnacSource) addIPAddressToInterface(
} else if mask != constants.MaxIPv4MaskBits {
_, err = nbi.AddPrefix(ds.Ctx, &objects.Prefix{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 578 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L578

Added line #L578 was not covered by tests
},
Prefix: prefix,
Tenant: iface.Device.Tenant,
Expand Down Expand Up @@ -604,7 +604,7 @@ func (ds *DnacSource) syncWirelessLANs(nbi *inventory.NetboxInventory) error {
wlanGroupName := ds.SSID2WlanGroupName[wlanName]
wlanGroup, err := nbi.AddWirelessLANGroup(ds.Ctx, &objects.WirelessLANGroup{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 607 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L607

Added line #L607 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
},
Expand Down Expand Up @@ -665,7 +665,7 @@ func (ds *DnacSource) syncWirelessLANs(nbi *inventory.NetboxInventory) error {
vlan, _ := nbi.GetVlan(vlanGroup.ID, wlanVID)
wlanStruct := &objects.WirelessLAN{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 668 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L668

Added line #L668 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
},
Expand Down Expand Up @@ -716,7 +716,7 @@ func (ds *DnacSource) syncMissingDevicePrimaryIPs(nbi *inventory.NetboxInventory
// We create a management interface for a device
managementInterfaceStruct := &objects.Interface{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 719 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L719

Added line #L719 was not covered by tests
Description: "Management interface",
},
Device: nbDevice,
Expand Down Expand Up @@ -747,7 +747,7 @@ func (ds *DnacSource) syncMissingDevicePrimaryIPs(nbi *inventory.NetboxInventory

nbIPAddressStruct := &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: ds.Config.SourceTags,
Tags: ds.GetSourceTags(),

Check warning on line 750 in internal/source/dnac/dnac_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/dnac/dnac_sync.go#L750

Added line #L750 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceName: ds.SourceConfig.Name,
constants.CustomFieldArpEntryName: false,
Expand Down
12 changes: 6 additions & 6 deletions internal/source/fmc/fmc_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (fmcs *FMCSource) syncDevices(nbi *inventory.NetboxInventory) error {
NBDevice, err := nbi.AddDevice(fmcs.Ctx, &objects.Device{
NetboxObject: objects.NetboxObject{
Description: device.Description,
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 97 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L97

Added line #L97 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceIDName: deviceUUID,
constants.CustomFieldDeviceUUIDName: deviceUUID,
Expand Down Expand Up @@ -197,7 +197,7 @@ func (fmcs *FMCSource) syncVlanInterfaces(
}
vlan, err := nbi.AddVlan(fmcs.Ctx, &objects.Vlan{
NetboxObject: objects.NetboxObject{
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 200 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L200

Added line #L200 was not covered by tests
Description: vlanIface.Description,
},
Status: &objects.VlanStatusActive,
Expand All @@ -216,7 +216,7 @@ func (fmcs *FMCSource) syncVlanInterfaces(
NBIface, err := nbi.AddInterface(fmcs.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Description: vlanIface.Description,
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 219 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L219

Added line #L219 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceIDName: vlanIface.ID,
},
Expand All @@ -241,7 +241,7 @@ func (fmcs *FMCSource) syncVlanInterfaces(
dnsName := utils.ReverseLookup(vlanIface.IPv4.Static.Address)
_, err := nbi.AddIPAddress(fmcs.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 244 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L244

Added line #L244 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldArpEntryName: false,
},
Expand Down Expand Up @@ -291,7 +291,7 @@ func (fmcs *FMCSource) syncPhysicalInterfaces(
NBIface, err := nbi.AddInterface(fmcs.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Description: pIface.Description,
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 294 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L294

Added line #L294 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldSourceIDName: pIface.ID,
},
Expand All @@ -315,7 +315,7 @@ func (fmcs *FMCSource) syncPhysicalInterfaces(
dnsName := utils.ReverseLookup(pIface.IPv4.Static.Address)
_, err := nbi.AddIPAddress(fmcs.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: fmcs.SourceTags,
Tags: fmcs.GetSourceTags(),

Check warning on line 318 in internal/source/fmc/fmc_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fmc/fmc_sync.go#L318

Added line #L318 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldArpEntryName: false,
},
Expand Down
14 changes: 7 additions & 7 deletions internal/source/fortigate/fortigate_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (fs *FortigateSource) syncDevice(nbi *inventory.NetboxInventory) error {
}
NBDevice, err := nbi.AddDevice(fs.Ctx, &objects.Device{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 94 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L94

Added line #L94 was not covered by tests
},
Name: deviceName,
Site: deviceSite,
Expand Down Expand Up @@ -149,7 +149,7 @@ func (fs *FortigateSource) syncInterfaces(nbi *inventory.NetboxInventory) error
if iface.Vdom != "" {
vdom, err := nbi.AddVirtualDeviceContext(fs.Ctx, &objects.VirtualDeviceContext{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 152 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L152

Added line #L152 was not covered by tests
},
Name: iface.Vdom,
Device: fs.NBFirewall,
Expand All @@ -162,7 +162,7 @@ func (fs *FortigateSource) syncInterfaces(nbi *inventory.NetboxInventory) error
}
NBIface, err := nbi.AddInterface(fs.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 165 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L165

Added line #L165 was not covered by tests
Description: iface.Description,
},
Device: fs.NBFirewall,
Expand Down Expand Up @@ -229,7 +229,7 @@ func (fs *FortigateSource) syncInterfaces(nbi *inventory.NetboxInventory) error
}
NBVlan, err := nbi.AddVlan(fs.Ctx, &objects.Vlan{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 232 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L232

Added line #L232 was not covered by tests
},
Status: &objects.VlanStatusActive,
Name: vlanName,
Expand Down Expand Up @@ -293,7 +293,7 @@ func syncInterfaceIPs(
}
NBIPAddress, err = nbi.AddIPAddress(fs.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 296 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L296

Added line #L296 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldArpEntryName: false,
},
Expand Down Expand Up @@ -322,7 +322,7 @@ func syncInterfaceIPs(
}
_, err = nbi.AddIPAddress(fs.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 325 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L325

Added line #L325 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldArpEntryName: false,
},
Expand Down Expand Up @@ -354,7 +354,7 @@ func syncInterfaceIPs(
}
_, err = nbi.AddIPAddress(fs.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: fs.SourceTags,
Tags: fs.GetSourceTags(),

Check warning on line 357 in internal/source/fortigate/fortigate_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/fortigate/fortigate_sync.go#L357

Added line #L357 was not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldArpEntryName: false,
},
Expand Down
53 changes: 41 additions & 12 deletions internal/source/ios-xe/iosxe_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ func (is *IOSXESource) syncDevice(nbi *inventory.NetboxInventory) error {
if err != nil {
return fmt.Errorf("add device type: %s", err)
}
deviceTenant, err := common.MatchHostToTenant(is.Ctx, nbi, deviceName, is.SourceConfig.HostTenantRelations)
deviceTenant, err := common.MatchHostToTenant(
is.Ctx,
nbi,
deviceName,
is.SourceConfig.HostTenantRelations,
)

Check warning on line 41 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L36-L41

Added lines #L36 - L41 were not covered by tests
if err != nil {
return fmt.Errorf("match host to tenant: %s", err)
}
Expand All @@ -42,7 +47,12 @@ func (is *IOSXESource) syncDevice(nbi *inventory.NetboxInventory) error {
// not use default switch role.
var deviceRole *objects.DeviceRole
if len(is.SourceConfig.HostRoleRelations) > 0 {
deviceRole, err = common.MatchHostToRole(is.Ctx, nbi, deviceName, is.SourceConfig.HostRoleRelations)
deviceRole, err = common.MatchHostToRole(
is.Ctx,
nbi,
deviceName,
is.SourceConfig.HostRoleRelations,
)

Check warning on line 55 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L50-L55

Added lines #L50 - L55 were not covered by tests
if err != nil {
return fmt.Errorf("match host to role: %s", err)
}
Expand All @@ -54,7 +64,12 @@ func (is *IOSXESource) syncDevice(nbi *inventory.NetboxInventory) error {
}
}

deviceSite, err := common.MatchHostToSite(is.Ctx, nbi, deviceName, is.SourceConfig.HostSiteRelations)
deviceSite, err := common.MatchHostToSite(
is.Ctx,
nbi,
deviceName,
is.SourceConfig.HostSiteRelations,
)

Check warning on line 72 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L67-L72

Added lines #L67 - L72 were not covered by tests
if err != nil {
return fmt.Errorf("match host to site: %s", err)
}
Expand All @@ -70,7 +85,7 @@ func (is *IOSXESource) syncDevice(nbi *inventory.NetboxInventory) error {
}
NBDevice, err := nbi.AddDevice(is.Ctx, &objects.Device{
NetboxObject: objects.NetboxObject{
Tags: is.SourceTags,
Tags: is.GetSourceTags(),

Check warning on line 88 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L88

Added line #L88 was not covered by tests
},
Name: deviceName,
Site: deviceSite,
Expand Down Expand Up @@ -136,7 +151,7 @@ func (is *IOSXESource) syncInterfaces(nbi *inventory.NetboxInventory) error {

nbIface, err := nbi.AddInterface(is.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Tags: is.SourceTags,
Tags: is.GetSourceTags(),

Check warning on line 154 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L154

Added line #L154 was not covered by tests
},
Name: ifaceName,
Type: ifaceType,
Expand All @@ -148,7 +163,12 @@ func (is *IOSXESource) syncInterfaces(nbi *inventory.NetboxInventory) error {
return fmt.Errorf("add interface: %s", err)
}
if ifaceMAC != "" {
nbMACAddress, err := common.CreateMACAddressForObjectType(is.Ctx, nbi, ifaceMAC, nbIface)
nbMACAddress, err := common.CreateMACAddressForObjectType(
is.Ctx,
nbi,
ifaceMAC,
nbIface,
)

Check warning on line 171 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L166-L171

Added lines #L166 - L171 were not covered by tests
if err != nil {
return fmt.Errorf("create mac address for object type: %s", err)
}
Expand Down Expand Up @@ -179,20 +199,29 @@ func (is *IOSXESource) syncArpTable(nbi *inventory.NetboxInventory) error {
}

for _, arpEntry := range is.ArpEntries {
if utils.IsPermittedIPAddress(arpEntry.Address, is.SourceConfig.PermittedSubnets, is.SourceConfig.IgnoredSubnets) {
newTags := is.SourceTags
if utils.IsPermittedIPAddress(
arpEntry.Address,
is.SourceConfig.PermittedSubnets,
is.SourceConfig.IgnoredSubnets,
) {
newTags := is.GetSourceTags()

Check warning on line 207 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L202-L207

Added lines #L202 - L207 were not covered by tests
newTags = append(newTags, arpTag)
currentTime := time.Now()
dnsName := utils.ReverseLookup(arpEntry.Address)
defaultMask := 32
addressWithMask := fmt.Sprintf("%s/%d", arpEntry.Address, defaultMask)
_, err := nbi.AddIPAddress(is.Ctx, &objects.IPAddress{
NetboxObject: objects.NetboxObject{
Tags: newTags,
Description: fmt.Sprintf("IP collected from %s arp table", is.SourceConfig.Name),
Tags: newTags,
Description: fmt.Sprintf(
"IP collected from %s arp table",
is.SourceConfig.Name,
),

Check warning on line 219 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L215-L219

Added lines #L215 - L219 were not covered by tests
CustomFields: map[string]interface{}{
constants.CustomFieldOrphanLastSeenName: currentTime.Format(constants.CustomFieldOrphanLastSeenFormat),
constants.CustomFieldArpEntryName: true,
constants.CustomFieldOrphanLastSeenName: currentTime.Format(
constants.CustomFieldOrphanLastSeenFormat,
),
constants.CustomFieldArpEntryName: true,

Check warning on line 224 in internal/source/ios-xe/iosxe_sync.go

View check run for this annotation

Codecov / codecov/patch

internal/source/ios-xe/iosxe_sync.go#L221-L224

Added lines #L221 - L224 were not covered by tests
},
},
Address: addressWithMask,
Expand Down
Loading

0 comments on commit 7d31349

Please sign in to comment.