Skip to content

Commit

Permalink
fix: fixing custom fields descriptions and organizing with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Feb 27, 2024
1 parent d20c244 commit e246255
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
24 changes: 24 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,27 @@ const (
const (
HTTPSDefaultPort = 443
)

// Names used for netbox objects custom fields attribute.
const (
// Custom Field for matching object with a source. This custom field is important
// for priority diff.
CustomFieldSourceName = "source"
CustomFieldSourceLabel = "Source"
CustomFieldSourceDescription = "Name of the source from which the object was collected"

// Custom field for adding source ID for each object.
CustomFieldSourceIDName = "source_id"
CustomFieldSourceIDLabel = "Source ID"
CustomFieldSourceIDDescription = "ID of the object on the source API"

// Custom field dcim.device, so we can add number of cpu cores for each server.
CustomFieldHostCPUCoresName = "host_cpu_cores"
CustomFieldHostCPUCoresLabel = "Host CPU cores"
CustomFieldHostCPUCoresDescription = "Number of CPU cores on the host"

// Custom field for dcim.device, so we can add number of ram for each server.
CustomFieldHostMemoryName = "host_memory"
CustomFieldHostMemoryLabel = "Host memory"
CustomFieldHostMemoryDescription = "Amount of memory on the host"
)
15 changes: 0 additions & 15 deletions internal/constants/symbols.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,3 @@ const (
CheckMark = "\u2713"
Rocket = "\U0001F680"
)

// Names used for netbox objects custom fields attribute.
const (
CustomFieldSourceName = "source"
CustomFieldSourceLabel = "Source"

CustomFieldSourceIDName = "source_id"
CustomFieldSourceIDLabel = "Source ID"

CustomFieldHostCPUCoresName = "host_cpu_cores"
CustomFieldHostCPUCoresLabel = "Host CPU cores"

CustomFieldHostMemoryName = "host_memory"
CustomFieldHostMemoryLabel = "Host memory"
)
10 changes: 5 additions & 5 deletions internal/netbox/inventory/init_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (nbi *NetboxInventory) InitSsotCustomFields() error {
CustomFieldUIVisible: &objects.CustomFieldUIVisibleAlways,
CustomFieldUIEditable: &objects.CustomFieldUIEditableYes,
DisplayWeight: objects.DisplayWeightDefault,
Description: "Source origin of the object",
Description: constants.CustomFieldSourceDescription,
SearchWeight: objects.SearchWeightDefault,
ContentTypes: []string{"dcim.device", "dcim.devicerole", "dcim.devicetype", "dcim.interface", "dcim.location", "dcim.manufacturer", "dcim.platform", "dcim.region", "dcim.site", "ipam.ipaddress", "ipam.vlangroup", "ipam.vlan", "ipam.prefix", "tenancy.tenantgroup", "tenancy.tenant", "tenancy.contact", "tenancy.contactassignment", "tenancy.contactgroup", "tenancy.contactrole", "virtualization.cluster", "virtualization.clustergroup", "virtualization.clustertype", "virtualization.virtualmachine", "virtualization.vminterface"},
})
Expand All @@ -317,13 +317,13 @@ func (nbi *NetboxInventory) InitSsotCustomFields() error {
}
err = nbi.AddCustomField(&objects.CustomField{
Name: constants.CustomFieldSourceIDName,
Label: constants.CustomFieldSourceLabel,
Label: constants.CustomFieldSourceIDLabel,
Type: objects.CustomFieldTypeText,
FilterLogic: objects.FilterLogicLoose,
CustomFieldUIVisible: &objects.CustomFieldUIVisibleAlways,
CustomFieldUIEditable: &objects.CustomFieldUIEditableYes,
DisplayWeight: objects.DisplayWeightDefault,
Description: "Source ID of the object",
Description: constants.CustomFieldSourceIDDescription,
SearchWeight: objects.SearchWeightDefault,
ContentTypes: []string{"dcim.device", "dcim.devicerole", "dcim.devicetype", "dcim.interface", "dcim.location", "dcim.manufacturer", "dcim.platform", "dcim.region", "dcim.site", "ipam.ipaddress", "ipam.vlangroup", "ipam.vlan", "ipam.prefix", "tenancy.tenantgroup", "tenancy.tenant", "tenancy.contact", "tenancy.contactassignment", "tenancy.contactgroup", "tenancy.contactrole", "virtualization.cluster", "virtualization.clustergroup", "virtualization.clustertype", "virtualization.virtualmachine", "virtualization.vminterface"},
})
Expand All @@ -338,7 +338,7 @@ func (nbi *NetboxInventory) InitSsotCustomFields() error {
CustomFieldUIVisible: &objects.CustomFieldUIVisibleAlways,
CustomFieldUIEditable: &objects.CustomFieldUIEditableYes,
DisplayWeight: objects.DisplayWeightDefault,
Description: "Number of CPU cores on the host",
Description: constants.CustomFieldHostCPUCoresDescription,
SearchWeight: objects.SearchWeightDefault,
ContentTypes: []string{"dcim.device"},
})
Expand All @@ -353,7 +353,7 @@ func (nbi *NetboxInventory) InitSsotCustomFields() error {
CustomFieldUIVisible: &objects.CustomFieldUIVisibleAlways,
CustomFieldUIEditable: &objects.CustomFieldUIEditableYes,
DisplayWeight: objects.DisplayWeightDefault,
Description: "Amount of memory on the host",
Description: constants.CustomFieldHostMemoryDescription,
SearchWeight: objects.SearchWeightDefault,
ContentTypes: []string{"dcim.device"},
})
Expand Down

0 comments on commit e246255

Please sign in to comment.