From 245f66ff1e0b78249609c78be8efd5cd1db82bef Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 26 Sep 2019 12:58:16 +0200 Subject: [PATCH] Utils: Improve function names --- .../objecttypes/actionurl/actionurl.go | 4 +-- .../objecttypes/checkcommand/checkcommand.go | 10 +++---- .../checkcommandargument.go | 8 ++--- .../checkcommandcustomvar.go | 8 ++--- .../checkcommandenvvar/checkcommandenvvar.go | 8 ++--- .../objecttypes/customvar/customvar.go | 6 ++-- .../customvar/customvarflat/customvarflat.go | 12 ++++---- configobject/objecttypes/endpoint/endpoint.go | 10 +++---- .../objecttypes/eventcommand/eventcommand.go | 10 +++---- .../eventcommandargument.go | 8 ++--- .../eventcommandcustomvar.go | 8 ++--- .../eventcommandenvvar/eventcommandenvvar.go | 8 ++--- configobject/objecttypes/host/host.go | 28 ++++++++--------- .../host/hostcomment/hostcomment.go | 12 ++++---- .../host/hostcustomvar/hostcustomvar.go | 8 ++--- .../host/hostdowntime/hostdowntime.go | 12 ++++---- .../objecttypes/host/hoststate/hoststate.go | 6 ++-- .../objecttypes/hostgroup/hostgroup.go | 12 ++++---- .../hostgroupcustomvar/hostgroupcustomvar.go | 8 ++--- .../hostgroupmember/hostgroupmember.go | 8 ++--- .../objecttypes/iconimage/iconimage.go | 4 +-- configobject/objecttypes/notesurl/notesurl.go | 4 +-- .../objecttypes/notification/notification.go | 24 +++++++-------- .../notificationcustomvar.go | 8 ++--- .../notificationuser/notificationuser.go | 8 ++--- .../notificationusergroup.go | 8 ++--- .../notificationcommand.go | 10 +++---- .../notificationcommandargument.go | 8 ++--- .../notificationcommandcustomvar.go | 8 ++--- .../notificationcommandenvvar.go | 8 ++--- configobject/objecttypes/service/service.go | 30 +++++++++---------- .../service/servicecomment/servicecomment.go | 12 ++++---- .../servicecustomvar/servicecustomvar.go | 8 ++--- .../servicedowntime/servicedowntime.go | 12 ++++---- .../service/servicestate/servicestate.go | 6 ++-- .../objecttypes/servicegroup/servicegroup.go | 12 ++++---- .../servicegroupcustomvar.go | 8 ++--- .../servicegroupmember/servicegroupmember.go | 8 ++--- .../objecttypes/timeperiod/timeperiod.go | 10 +++---- .../timeperiodcustomvar.go | 8 ++--- .../timeperiodoverrideexclude.go | 8 ++--- .../timeperiodoverrideinclude.go | 8 ++--- .../timeperiodrange/timeperiodrange.go | 6 ++-- configobject/objecttypes/user/user.go | 16 +++++----- .../user/usercustomvar/usercustomvar.go | 8 ++--- .../objecttypes/usergroup/usergroup.go | 12 ++++---- .../usergroupcustomvar/usergroupcustomvar.go | 8 ++--- .../usergroupmember/usergroupmember.go | 8 ++--- configobject/objecttypes/zone/zone.go | 12 ++++---- connection/mysql.go | 2 +- utils/convert.go | 8 ++--- utils/convert_test.go | 12 ++++---- 52 files changed, 253 insertions(+), 253 deletions(-) diff --git a/configobject/objecttypes/actionurl/actionurl.go b/configobject/objecttypes/actionurl/actionurl.go index e869afe5..d6c91f43 100644 --- a/configobject/objecttypes/actionurl/actionurl.go +++ b/configobject/objecttypes/actionurl/actionurl.go @@ -30,7 +30,7 @@ func NewActionUrl() connection.Row { func (a *ActionUrl) InsertValues() []interface{} { v := a.UpdateValues() - return append([]interface{}{utils.Checksum(a.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(a.Id)}, v...) } func (a *ActionUrl) UpdateValues() []interface{} { @@ -38,7 +38,7 @@ func (a *ActionUrl) UpdateValues() []interface{} { v = append( v, - utils.Checksum(a.EnvId), + utils.EncodeChecksum(a.EnvId), a.ActionUrl, ) diff --git a/configobject/objecttypes/checkcommand/checkcommand.go b/configobject/objecttypes/checkcommand/checkcommand.go index be21772b..4c32d11a 100644 --- a/configobject/objecttypes/checkcommand/checkcommand.go +++ b/configobject/objecttypes/checkcommand/checkcommand.go @@ -43,7 +43,7 @@ func NewCheckCommand() connection.Row { func (c *CheckCommand) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *CheckCommand) UpdateValues() []interface{} { @@ -51,12 +51,12 @@ func (c *CheckCommand) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EnvId), - utils.Checksum(c.NameChecksum), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.NameChecksum), + utils.EncodeChecksum(c.PropertiesChecksum), c.Name, c.NameCi, - utils.Checksum(c.ZoneId), + utils.EncodeChecksum(c.ZoneId), c.Command, c.Timeout, ) diff --git a/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go b/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go index 12d27cc3..8a2c5b40 100644 --- a/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go +++ b/configobject/objecttypes/checkcommand/checkcommandargument/checkcommandargument.go @@ -49,7 +49,7 @@ func NewCheckCommandArgument() connection.Row { func (c *CheckCommandArgument) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *CheckCommandArgument) UpdateValues() []interface{} { @@ -57,10 +57,10 @@ func (c *CheckCommandArgument) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.ArgumentKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.ArgumentValue, c.ArgumentOrder, c.Description, diff --git a/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go b/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go index 141eb2d1..9b13a6f1 100644 --- a/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go +++ b/configobject/objecttypes/checkcommand/checkcommandcustomvar/checkcommandcustomvar.go @@ -31,7 +31,7 @@ func NewCheckCommandCustomvar() connection.Row { func (c *CheckCommandCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *CheckCommandCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *CheckCommandCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CheckCommandId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.CheckCommandId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go b/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go index 79f9a92e..55390b62 100644 --- a/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go +++ b/configobject/objecttypes/checkcommand/checkcommandenvvar/checkcommandenvvar.go @@ -35,7 +35,7 @@ func NewCheckCommandEnvvar() connection.Row { func (c *CheckCommandEnvvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *CheckCommandEnvvar) UpdateValues() []interface{} { @@ -43,10 +43,10 @@ func (c *CheckCommandEnvvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.EnvvarKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.EnvvarValue, ) diff --git a/configobject/objecttypes/customvar/customvar.go b/configobject/objecttypes/customvar/customvar.go index 3015b2e6..33b7f538 100644 --- a/configobject/objecttypes/customvar/customvar.go +++ b/configobject/objecttypes/customvar/customvar.go @@ -34,7 +34,7 @@ func NewCustomvar() connection.Row { func (c *Customvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *Customvar) UpdateValues() []interface{} { @@ -42,8 +42,8 @@ func (c *Customvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EnvId), - utils.Checksum(c.NameChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.NameChecksum), c.Name, c.Value, ) diff --git a/configobject/objecttypes/customvar/customvarflat/customvarflat.go b/configobject/objecttypes/customvar/customvarflat/customvarflat.go index dd879a57..adf74208 100644 --- a/configobject/objecttypes/customvar/customvarflat/customvarflat.go +++ b/configobject/objecttypes/customvar/customvarflat/customvarflat.go @@ -81,10 +81,10 @@ func CollectScalarVars(c *CustomvarFlat, value interface{}, name string, path [] flatValue := fmt.Sprintf("%v", v) return []connection.Row{ &CustomvarFlatFinal{ - Id: utils.StringToSha1String(c.EnvId + flatName + flatValue), + Id: utils.Checksum(c.EnvId + flatName + flatValue), EnvId: c.EnvId, CustomvarId: c.Id, - FlatNameChecksum: utils.StringToSha1String(flatName), + FlatNameChecksum: utils.Checksum(flatName), FlatName: flatName, FlatValue: flatValue, }, @@ -104,7 +104,7 @@ type CustomvarFlatFinal struct { func (c *CustomvarFlatFinal) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *CustomvarFlatFinal) UpdateValues() []interface{} { @@ -112,9 +112,9 @@ func (c *CustomvarFlatFinal) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EnvId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.FlatNameChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.FlatNameChecksum), c.FlatName, c.FlatValue, ) diff --git a/configobject/objecttypes/endpoint/endpoint.go b/configobject/objecttypes/endpoint/endpoint.go index 5e10662c..97740cbe 100644 --- a/configobject/objecttypes/endpoint/endpoint.go +++ b/configobject/objecttypes/endpoint/endpoint.go @@ -39,7 +39,7 @@ func NewEndpoint() connection.Row { func (e *Endpoint) InsertValues() []interface{} { v := e.UpdateValues() - return append([]interface{}{utils.Checksum(e.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(e.Id)}, v...) } func (e *Endpoint) UpdateValues() []interface{} { @@ -47,12 +47,12 @@ func (e *Endpoint) UpdateValues() []interface{} { v = append( v, - utils.Checksum(e.EnvId), - utils.Checksum(e.NameChecksum), - utils.Checksum(e.PropertiesChecksum), + utils.EncodeChecksum(e.EnvId), + utils.EncodeChecksum(e.NameChecksum), + utils.EncodeChecksum(e.PropertiesChecksum), e.Name, e.NameCi, - utils.Checksum(e.ZoneId), + utils.EncodeChecksum(e.ZoneId), ) return v diff --git a/configobject/objecttypes/eventcommand/eventcommand.go b/configobject/objecttypes/eventcommand/eventcommand.go index 9d60a490..d1679bac 100644 --- a/configobject/objecttypes/eventcommand/eventcommand.go +++ b/configobject/objecttypes/eventcommand/eventcommand.go @@ -43,7 +43,7 @@ func NewEventCommand() connection.Row { func (c *EventCommand) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *EventCommand) UpdateValues() []interface{} { @@ -51,12 +51,12 @@ func (c *EventCommand) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EnvId), - utils.Checksum(c.NameChecksum), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.NameChecksum), + utils.EncodeChecksum(c.PropertiesChecksum), c.Name, c.NameCi, - utils.Checksum(c.ZoneId), + utils.EncodeChecksum(c.ZoneId), c.Command, c.Timeout, ) diff --git a/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go b/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go index 575eb97b..d5d766ac 100644 --- a/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go +++ b/configobject/objecttypes/eventcommand/eventcommandargument/eventcommandargument.go @@ -49,7 +49,7 @@ func NewEventCommandArgument() connection.Row { func (c *EventCommandArgument) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *EventCommandArgument) UpdateValues() []interface{} { @@ -57,10 +57,10 @@ func (c *EventCommandArgument) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.ArgumentKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.ArgumentValue, c.ArgumentOrder, c.Description, diff --git a/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go b/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go index e753b0ae..f8b9bc3a 100644 --- a/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go +++ b/configobject/objecttypes/eventcommand/eventcommandcustomvar/eventcommandcustomvar.go @@ -31,7 +31,7 @@ func NewEventCommandCustomvar() connection.Row { func (c *EventCommandCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *EventCommandCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *EventCommandCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EventCommandId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.EventCommandId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go b/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go index 01c9e08a..0a63e1f4 100644 --- a/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go +++ b/configobject/objecttypes/eventcommand/eventcommandenvvar/eventcommandenvvar.go @@ -35,7 +35,7 @@ func NewEventCommandEnvvar() connection.Row { func (c *EventCommandEnvvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *EventCommandEnvvar) UpdateValues() []interface{} { @@ -43,10 +43,10 @@ func (c *EventCommandEnvvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.EnvvarKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.EnvvarValue, ) diff --git a/configobject/objecttypes/host/host.go b/configobject/objecttypes/host/host.go index e6995c85..c68fbc20 100644 --- a/configobject/objecttypes/host/host.go +++ b/configobject/objecttypes/host/host.go @@ -107,7 +107,7 @@ func NewHost() connection.Row { func (h *Host) InsertValues() []interface{} { v := h.UpdateValues() - return append([]interface{}{utils.Checksum(h.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(h.Id)}, v...) } func (h *Host) UpdateValues() []interface{} { @@ -115,11 +115,11 @@ func (h *Host) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.EnvId), - utils.Checksum(h.NameChecksum), - utils.Checksum(h.PropertiesChecksum), - utils.Checksum(h.CustomvarsChecksum), - utils.Checksum(h.GroupsChecksum), + utils.EncodeChecksum(h.EnvId), + utils.EncodeChecksum(h.NameChecksum), + utils.EncodeChecksum(h.PropertiesChecksum), + utils.EncodeChecksum(h.CustomvarsChecksum), + utils.EncodeChecksum(h.GroupsChecksum), h.Name, h.NameCi, h.DisplayName, @@ -128,10 +128,10 @@ func (h *Host) UpdateValues() []interface{} { h.AddressBin, h.Address6Bin, h.Checkcommand, - utils.Checksum(h.CheckcommandId), + utils.EncodeChecksum(h.CheckcommandId), h.MaxCheckAttempts, h.CheckPeriod, - utils.Checksum(h.CheckPeriodId), + utils.EncodeChecksum(h.CheckPeriodId), h.CheckTimeout, h.CheckInterval, h.CheckRetryInterval, @@ -144,17 +144,17 @@ func (h *Host) UpdateValues() []interface{} { h.FlappingThresholdHigh, utils.Bool[h.PerfdataEnabled], h.Eventcommand, - utils.Checksum(h.EventcommandId), + utils.EncodeChecksum(h.EventcommandId), utils.Bool[h.IsVolatile], - utils.Checksum(h.ActionUrlId), - utils.Checksum(h.NotesUrlId), + utils.EncodeChecksum(h.ActionUrlId), + utils.EncodeChecksum(h.NotesUrlId), h.Notes, - utils.Checksum(h.IconImageId), + utils.EncodeChecksum(h.IconImageId), h.IconImageAlt, h.Zone, - utils.Checksum(h.ZoneId), + utils.EncodeChecksum(h.ZoneId), h.CommandEndpoint, - utils.Checksum(h.CommandEndpointId), + utils.EncodeChecksum(h.CommandEndpointId), ) return v diff --git a/configobject/objecttypes/host/hostcomment/hostcomment.go b/configobject/objecttypes/host/hostcomment/hostcomment.go index 3d16fe9a..5096312a 100644 --- a/configobject/objecttypes/host/hostcomment/hostcomment.go +++ b/configobject/objecttypes/host/hostcomment/hostcomment.go @@ -50,7 +50,7 @@ func NewHostComment() connection.Row { func (h *HostComment) InsertValues() []interface{} { v := h.UpdateValues() - return append([]interface{}{utils.Checksum(h.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(h.Id)}, v...) } func (h *HostComment) UpdateValues() []interface{} { @@ -58,10 +58,10 @@ func (h *HostComment) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.EnvId), - utils.Checksum(h.HostId), - utils.Checksum(h.NameChecksum), - utils.Checksum(h.PropertiesChecksum), + utils.EncodeChecksum(h.EnvId), + utils.EncodeChecksum(h.HostId), + utils.EncodeChecksum(h.NameChecksum), + utils.EncodeChecksum(h.PropertiesChecksum), h.Name, h.Author, h.Text, @@ -69,7 +69,7 @@ func (h *HostComment) UpdateValues() []interface{} { h.EntryTime, utils.Bool[h.IsPersistent], h.ExpireTime, - utils.Checksum(h.ZoneId), + utils.EncodeChecksum(h.ZoneId), ) return v diff --git a/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go b/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go index c625b0da..af39ec85 100644 --- a/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go +++ b/configobject/objecttypes/host/hostcustomvar/hostcustomvar.go @@ -31,7 +31,7 @@ func NewHostCustomvar() connection.Row { func (c *HostCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *HostCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *HostCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.HostId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.HostId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/host/hostdowntime/hostdowntime.go b/configobject/objecttypes/host/hostdowntime/hostdowntime.go index 97839c77..528eb61f 100644 --- a/configobject/objecttypes/host/hostdowntime/hostdowntime.go +++ b/configobject/objecttypes/host/hostdowntime/hostdowntime.go @@ -58,7 +58,7 @@ func NewHostDowntime() connection.Row { func (h *HostDowntime) InsertValues() []interface{} { v := h.UpdateValues() - return append([]interface{}{utils.Checksum(h.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(h.Id)}, v...) } func (h *HostDowntime) UpdateValues() []interface{} { @@ -66,10 +66,10 @@ func (h *HostDowntime) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.EnvId), - utils.Checksum(h.HostId), - utils.Checksum(h.NameChecksum), - utils.Checksum(h.PropertiesChecksum), + utils.EncodeChecksum(h.EnvId), + utils.EncodeChecksum(h.HostId), + utils.EncodeChecksum(h.NameChecksum), + utils.EncodeChecksum(h.PropertiesChecksum), h.Name, h.Author, h.Comment, @@ -81,7 +81,7 @@ func (h *HostDowntime) UpdateValues() []interface{} { utils.Bool[h.IsInEffect], h.ActualStartTime, h.ActualEndTime, - utils.Checksum(h.ZoneId), + utils.EncodeChecksum(h.ZoneId), ) return v diff --git a/configobject/objecttypes/host/hoststate/hoststate.go b/configobject/objecttypes/host/hoststate/hoststate.go index df1ad9d7..1db7029a 100644 --- a/configobject/objecttypes/host/hoststate/hoststate.go +++ b/configobject/objecttypes/host/hoststate/hoststate.go @@ -76,7 +76,7 @@ func NewHostState() connection.Row { func (h *HostState) InsertValues() []interface{} { v := h.UpdateValues() - return append([]interface{}{utils.Checksum(h.HostId)}, v...) + return append([]interface{}{utils.EncodeChecksum(h.HostId)}, v...) } func (h *HostState) UpdateValues() []interface{} { @@ -84,7 +84,7 @@ func (h *HostState) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.EnvId), + utils.EncodeChecksum(h.EnvId), utils.IcingaStateTypeToString(h.StateType), h.SoftState, h.HardState, @@ -99,7 +99,7 @@ func (h *HostState) UpdateValues() []interface{} { utils.Bool[h.IsReachable], utils.Bool[h.IsFlapping], utils.Bool[h.IsAcknowledged], - utils.Checksum(h.AcknowledgementCommentId), + utils.EncodeChecksum(h.AcknowledgementCommentId), utils.Bool[h.InDowntime], h.ExecutionTime, h.Latency, diff --git a/configobject/objecttypes/hostgroup/hostgroup.go b/configobject/objecttypes/hostgroup/hostgroup.go index c09d9ea0..0e4dcfae 100644 --- a/configobject/objecttypes/hostgroup/hostgroup.go +++ b/configobject/objecttypes/hostgroup/hostgroup.go @@ -43,7 +43,7 @@ func NewHostgroup() connection.Row { func (h *Hostgroup) InsertValues() []interface{} { v := h.UpdateValues() - return append([]interface{}{utils.Checksum(h.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(h.Id)}, v...) } func (h *Hostgroup) UpdateValues() []interface{} { @@ -51,14 +51,14 @@ func (h *Hostgroup) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.EnvId), - utils.Checksum(h.NameChecksum), - utils.Checksum(h.PropertiesChecksum), - utils.Checksum(h.CustomvarsChecksum), + utils.EncodeChecksum(h.EnvId), + utils.EncodeChecksum(h.NameChecksum), + utils.EncodeChecksum(h.PropertiesChecksum), + utils.EncodeChecksum(h.CustomvarsChecksum), h.Name, h.NameCi, h.DisplayName, - utils.Checksum(h.ZoneId), + utils.EncodeChecksum(h.ZoneId), ) return v diff --git a/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go b/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go index adfd6f8b..a0aaa558 100644 --- a/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go +++ b/configobject/objecttypes/hostgroup/hostgroupcustomvar/hostgroupcustomvar.go @@ -31,7 +31,7 @@ func NewHostgroupCustomvar() connection.Row { func (c *HostgroupCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *HostgroupCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *HostgroupCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.HostgroupId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.HostgroupId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go b/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go index 880a48a3..ed30af15 100644 --- a/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go +++ b/configobject/objecttypes/hostgroup/hostgroupmember/hostgroupmember.go @@ -31,7 +31,7 @@ func NewHostgroupMember() connection.Row { func (c *HostgroupMember) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (h *HostgroupMember) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (h *HostgroupMember) UpdateValues() []interface{} { v = append( v, - utils.Checksum(h.HostgroupId), - utils.Checksum(h.HostId), - utils.Checksum(h.EnvId), + utils.EncodeChecksum(h.HostgroupId), + utils.EncodeChecksum(h.HostId), + utils.EncodeChecksum(h.EnvId), ) return v diff --git a/configobject/objecttypes/iconimage/iconimage.go b/configobject/objecttypes/iconimage/iconimage.go index a1d1e939..a1a2a61c 100644 --- a/configobject/objecttypes/iconimage/iconimage.go +++ b/configobject/objecttypes/iconimage/iconimage.go @@ -30,7 +30,7 @@ func NewIconImage() connection.Row { func (a *IconImage) InsertValues() []interface{} { v := a.UpdateValues() - return append([]interface{}{utils.Checksum(a.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(a.Id)}, v...) } func (a *IconImage) UpdateValues() []interface{} { @@ -38,7 +38,7 @@ func (a *IconImage) UpdateValues() []interface{} { v = append( v, - utils.Checksum(a.EnvId), + utils.EncodeChecksum(a.EnvId), a.IconImage, ) diff --git a/configobject/objecttypes/notesurl/notesurl.go b/configobject/objecttypes/notesurl/notesurl.go index 8f5f8b7d..04ccdd65 100644 --- a/configobject/objecttypes/notesurl/notesurl.go +++ b/configobject/objecttypes/notesurl/notesurl.go @@ -30,7 +30,7 @@ func NewNotesUrl() connection.Row { func (a *NotesUrl) InsertValues() []interface{} { v := a.UpdateValues() - return append([]interface{}{utils.Checksum(a.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(a.Id)}, v...) } func (a *NotesUrl) UpdateValues() []interface{} { @@ -38,7 +38,7 @@ func (a *NotesUrl) UpdateValues() []interface{} { v = append( v, - utils.Checksum(a.EnvId), + utils.EncodeChecksum(a.EnvId), a.NotesUrl, ) diff --git a/configobject/objecttypes/notification/notification.go b/configobject/objecttypes/notification/notification.go index 0169a7f8..11d50adb 100644 --- a/configobject/objecttypes/notification/notification.go +++ b/configobject/objecttypes/notification/notification.go @@ -63,7 +63,7 @@ func NewNotification() connection.Row { func (n *Notification) InsertValues() []interface{} { v := n.UpdateValues() - return append([]interface{}{utils.Checksum(n.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(n.Id)}, v...) } func (n *Notification) UpdateValues() []interface{} { @@ -71,24 +71,24 @@ func (n *Notification) UpdateValues() []interface{} { v = append( v, - utils.Checksum(n.EnvId), - utils.Checksum(n.NameChecksum), - utils.Checksum(n.PropertiesChecksum), - utils.Checksum(n.CustomvarsChecksum), - utils.Checksum(n.UsersChecksum), - utils.Checksum(n.UsergroupsChecksum), + utils.EncodeChecksum(n.EnvId), + utils.EncodeChecksum(n.NameChecksum), + utils.EncodeChecksum(n.PropertiesChecksum), + utils.EncodeChecksum(n.CustomvarsChecksum), + utils.EncodeChecksum(n.UsersChecksum), + utils.EncodeChecksum(n.UsergroupsChecksum), n.Name, n.NameCi, - utils.Checksum(n.HostId), - utils.Checksum(n.ServiceId), - utils.Checksum(n.CommandId), + utils.EncodeChecksum(n.HostId), + utils.EncodeChecksum(n.ServiceId), + utils.EncodeChecksum(n.CommandId), n.TimesBegin, n.TimesEnd, n.NotificationInterval, - utils.Checksum(n.PeriodId), + utils.EncodeChecksum(n.PeriodId), utils.NotificationStatesToBitMask(n.States), utils.NotificationTypesToBitMask(n.Types), - utils.Checksum(n.ZoneId), + utils.EncodeChecksum(n.ZoneId), ) return v diff --git a/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go b/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go index 1d5575e8..fe501cf7 100644 --- a/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go +++ b/configobject/objecttypes/notification/notificationcustomvar/notificationcustomvar.go @@ -31,7 +31,7 @@ func NewNotificationCustomvar() connection.Row { func (c *NotificationCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *NotificationCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *NotificationCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.NotificationId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.NotificationId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/notification/notificationuser/notificationuser.go b/configobject/objecttypes/notification/notificationuser/notificationuser.go index 91e075ef..e4d2a7ac 100644 --- a/configobject/objecttypes/notification/notificationuser/notificationuser.go +++ b/configobject/objecttypes/notification/notificationuser/notificationuser.go @@ -31,7 +31,7 @@ func NewNotificationUser() connection.Row { func (n *NotificationUser) InsertValues() []interface{} { v := n.UpdateValues() - return append([]interface{}{utils.Checksum(n.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(n.Id)}, v...) } func (n *NotificationUser) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (n *NotificationUser) UpdateValues() []interface{} { v = append( v, - utils.Checksum(n.NotificationId), - utils.Checksum(n.UserId), - utils.Checksum(n.EnvId), + utils.EncodeChecksum(n.NotificationId), + utils.EncodeChecksum(n.UserId), + utils.EncodeChecksum(n.EnvId), ) return v diff --git a/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go b/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go index cc5aea51..24eb9314 100644 --- a/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go +++ b/configobject/objecttypes/notification/notificationusergroup/notificationusergroup.go @@ -31,7 +31,7 @@ func NewNotificationUsergroup() connection.Row { func (n *NotificationUsergroup) InsertValues() []interface{} { v := n.UpdateValues() - return append([]interface{}{utils.Checksum(n.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(n.Id)}, v...) } func (n *NotificationUsergroup) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (n *NotificationUsergroup) UpdateValues() []interface{} { v = append( v, - utils.Checksum(n.NotificationId), - utils.Checksum(n.UsergroupId), - utils.Checksum(n.EnvId), + utils.EncodeChecksum(n.NotificationId), + utils.EncodeChecksum(n.UsergroupId), + utils.EncodeChecksum(n.EnvId), ) return v diff --git a/configobject/objecttypes/notificationcommand/notificationcommand.go b/configobject/objecttypes/notificationcommand/notificationcommand.go index 4c32598c..310e6fd6 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommand.go +++ b/configobject/objecttypes/notificationcommand/notificationcommand.go @@ -43,7 +43,7 @@ func NewNotificationCommand() connection.Row { func (c *NotificationCommand) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *NotificationCommand) UpdateValues() []interface{} { @@ -51,12 +51,12 @@ func (c *NotificationCommand) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.EnvId), - utils.Checksum(c.NameChecksum), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.NameChecksum), + utils.EncodeChecksum(c.PropertiesChecksum), c.Name, c.NameCi, - utils.Checksum(c.ZoneId), + utils.EncodeChecksum(c.ZoneId), c.Command, c.Timeout, ) diff --git a/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go b/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go index 568068c2..55687916 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandargument/notificationcommandargument.go @@ -49,7 +49,7 @@ func NewNotificationCommandArgument() connection.Row { func (c *NotificationCommandArgument) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *NotificationCommandArgument) UpdateValues() []interface{} { @@ -57,10 +57,10 @@ func (c *NotificationCommandArgument) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.ArgumentKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.ArgumentValue, c.ArgumentOrder, c.Description, diff --git a/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go b/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go index 3758e82c..da200b0d 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandcustomvar/notificationcommandcustomvar.go @@ -31,7 +31,7 @@ func NewNotificationCommandCustomvar() connection.Row { func (c *NotificationCommandCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *NotificationCommandCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *NotificationCommandCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.NotificationCommandId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.NotificationCommandId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go b/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go index 0e238d8c..7cb4a3eb 100644 --- a/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go +++ b/configobject/objecttypes/notificationcommand/notificationcommandenvvar/notificationcommandenvvar.go @@ -35,7 +35,7 @@ func NewNotificationCommandEnvvar() connection.Row { func (c *NotificationCommandEnvvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *NotificationCommandEnvvar) UpdateValues() []interface{} { @@ -43,10 +43,10 @@ func (c *NotificationCommandEnvvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.CommandId), + utils.EncodeChecksum(c.CommandId), c.EnvvarKey, - utils.Checksum(c.EnvId), - utils.Checksum(c.PropertiesChecksum), + utils.EncodeChecksum(c.EnvId), + utils.EncodeChecksum(c.PropertiesChecksum), c.EnvvarValue, ) diff --git a/configobject/objecttypes/service/service.go b/configobject/objecttypes/service/service.go index 53d071ce..cfd12ded 100644 --- a/configobject/objecttypes/service/service.go +++ b/configobject/objecttypes/service/service.go @@ -101,7 +101,7 @@ func NewService() connection.Row { func (s *Service) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.Id)}, v...) } func (s *Service) UpdateValues() []interface{} { @@ -109,20 +109,20 @@ func (s *Service) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.EnvId), - utils.Checksum(s.NameChecksum), - utils.Checksum(s.PropertiesChecksum), - utils.Checksum(s.CustomvarsChecksum), - utils.Checksum(s.GroupsChecksum), - utils.Checksum(s.HostId), + utils.EncodeChecksum(s.EnvId), + utils.EncodeChecksum(s.NameChecksum), + utils.EncodeChecksum(s.PropertiesChecksum), + utils.EncodeChecksum(s.CustomvarsChecksum), + utils.EncodeChecksum(s.GroupsChecksum), + utils.EncodeChecksum(s.HostId), s.Name, s.NameCi, s.DisplayName, s.Checkcommand, - utils.Checksum(s.CheckcommandId), + utils.EncodeChecksum(s.CheckcommandId), s.MaxCheckAttempts, s.CheckPeriod, - utils.Checksum(s.CheckPeriodId), + utils.EncodeChecksum(s.CheckPeriodId), s.CheckTimeout, s.CheckInterval, s.CheckRetryInterval, @@ -135,17 +135,17 @@ func (s *Service) UpdateValues() []interface{} { s.FlappingThresholdHigh, utils.Bool[s.PerfdataEnabled], s.Eventcommand, - utils.Checksum(s.EventcommandId), + utils.EncodeChecksum(s.EventcommandId), utils.Bool[s.IsVolatile], - utils.Checksum(s.ActionUrlId), - utils.Checksum(s.NotesUrlId), + utils.EncodeChecksum(s.ActionUrlId), + utils.EncodeChecksum(s.NotesUrlId), s.Notes, - utils.Checksum(s.IconImageId), + utils.EncodeChecksum(s.IconImageId), s.IconImageAlt, s.Zone, - utils.Checksum(s.ZoneId), + utils.EncodeChecksum(s.ZoneId), s.CommandEndpoint, - utils.Checksum(s.CommandEndpointId), + utils.EncodeChecksum(s.CommandEndpointId), ) return v diff --git a/configobject/objecttypes/service/servicecomment/servicecomment.go b/configobject/objecttypes/service/servicecomment/servicecomment.go index 1b3ad713..09c798e6 100644 --- a/configobject/objecttypes/service/servicecomment/servicecomment.go +++ b/configobject/objecttypes/service/servicecomment/servicecomment.go @@ -50,7 +50,7 @@ func NewServiceComment() connection.Row { func (s *ServiceComment) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.Id)}, v...) } func (s *ServiceComment) UpdateValues() []interface{} { @@ -58,10 +58,10 @@ func (s *ServiceComment) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.EnvId), - utils.Checksum(s.ServiceId), - utils.Checksum(s.NameChecksum), - utils.Checksum(s.PropertiesChecksum), + utils.EncodeChecksum(s.EnvId), + utils.EncodeChecksum(s.ServiceId), + utils.EncodeChecksum(s.NameChecksum), + utils.EncodeChecksum(s.PropertiesChecksum), s.Name, s.Author, s.Text, @@ -69,7 +69,7 @@ func (s *ServiceComment) UpdateValues() []interface{} { s.EntryTime, utils.Bool[s.IsPersistent], s.ExpireTime, - utils.Checksum(s.ZoneId), + utils.EncodeChecksum(s.ZoneId), ) return v diff --git a/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go b/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go index aa15126f..e6c0f6ba 100644 --- a/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go +++ b/configobject/objecttypes/service/servicecustomvar/servicecustomvar.go @@ -31,7 +31,7 @@ func NewServiceCustomvar() connection.Row { func (c *ServiceCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *ServiceCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *ServiceCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.ServiceId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.ServiceId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/service/servicedowntime/servicedowntime.go b/configobject/objecttypes/service/servicedowntime/servicedowntime.go index a3b164aa..bf712a57 100644 --- a/configobject/objecttypes/service/servicedowntime/servicedowntime.go +++ b/configobject/objecttypes/service/servicedowntime/servicedowntime.go @@ -58,7 +58,7 @@ func NewServiceDowntime() connection.Row { func (s *ServiceDowntime) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.Id)}, v...) } func (s *ServiceDowntime) UpdateValues() []interface{} { @@ -66,10 +66,10 @@ func (s *ServiceDowntime) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.EnvId), - utils.Checksum(s.ServiceId), - utils.Checksum(s.NameChecksum), - utils.Checksum(s.PropertiesChecksum), + utils.EncodeChecksum(s.EnvId), + utils.EncodeChecksum(s.ServiceId), + utils.EncodeChecksum(s.NameChecksum), + utils.EncodeChecksum(s.PropertiesChecksum), s.Name, s.Author, s.Comment, @@ -81,7 +81,7 @@ func (s *ServiceDowntime) UpdateValues() []interface{} { utils.Bool[s.IsInEffect], s.ActualStartTime, s.ActualEndTime, - utils.Checksum(s.ZoneId), + utils.EncodeChecksum(s.ZoneId), ) return v diff --git a/configobject/objecttypes/service/servicestate/servicestate.go b/configobject/objecttypes/service/servicestate/servicestate.go index 059996b7..f8643701 100644 --- a/configobject/objecttypes/service/servicestate/servicestate.go +++ b/configobject/objecttypes/service/servicestate/servicestate.go @@ -76,7 +76,7 @@ func NewServiceState() connection.Row { func (s *ServiceState) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.ServiceId)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.ServiceId)}, v...) } func (s *ServiceState) UpdateValues() []interface{} { @@ -84,7 +84,7 @@ func (s *ServiceState) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.EnvId), + utils.EncodeChecksum(s.EnvId), utils.IcingaStateTypeToString(s.StateType), s.SoftState, s.HardState, @@ -99,7 +99,7 @@ func (s *ServiceState) UpdateValues() []interface{} { utils.Bool[s.IsReachable], utils.Bool[s.IsFlapping], utils.Bool[s.IsAcknowledged], - utils.Checksum(s.AcknowledgementCommentId), + utils.EncodeChecksum(s.AcknowledgementCommentId), utils.Bool[s.InDowntime], s.ExecutionTime, s.Latency, diff --git a/configobject/objecttypes/servicegroup/servicegroup.go b/configobject/objecttypes/servicegroup/servicegroup.go index b68b67aa..1773aec4 100644 --- a/configobject/objecttypes/servicegroup/servicegroup.go +++ b/configobject/objecttypes/servicegroup/servicegroup.go @@ -43,7 +43,7 @@ func NewServicegroup() connection.Row { func (s *Servicegroup) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.Id)}, v...) } func (s *Servicegroup) UpdateValues() []interface{} { @@ -51,14 +51,14 @@ func (s *Servicegroup) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.EnvId), - utils.Checksum(s.NameChecksum), - utils.Checksum(s.PropertiesChecksum), - utils.Checksum(s.CustomvarsChecksum), + utils.EncodeChecksum(s.EnvId), + utils.EncodeChecksum(s.NameChecksum), + utils.EncodeChecksum(s.PropertiesChecksum), + utils.EncodeChecksum(s.CustomvarsChecksum), s.Name, s.NameCi, s.DisplayName, - utils.Checksum(s.ZoneId), + utils.EncodeChecksum(s.ZoneId), ) return v diff --git a/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go b/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go index d73dd4c7..4fc6cc60 100644 --- a/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go +++ b/configobject/objecttypes/servicegroup/servicegroupcustomvar/servicegroupcustomvar.go @@ -31,7 +31,7 @@ func NewServicegroupCustomvar() connection.Row { func (c *ServicegroupCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *ServicegroupCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *ServicegroupCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.ServicegroupId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.ServicegroupId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go b/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go index 13f27681..fc51fe10 100644 --- a/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go +++ b/configobject/objecttypes/servicegroup/servicegroupmember/servicegroupmember.go @@ -31,7 +31,7 @@ func NewServicegroupMember() connection.Row { func (s *ServicegroupMember) InsertValues() []interface{} { v := s.UpdateValues() - return append([]interface{}{utils.Checksum(s.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(s.Id)}, v...) } func (s *ServicegroupMember) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (s *ServicegroupMember) UpdateValues() []interface{} { v = append( v, - utils.Checksum(s.ServicegroupId), - utils.Checksum(s.ServiceId), - utils.Checksum(s.EnvId), + utils.EncodeChecksum(s.ServicegroupId), + utils.EncodeChecksum(s.ServiceId), + utils.EncodeChecksum(s.EnvId), ) return v diff --git a/configobject/objecttypes/timeperiod/timeperiod.go b/configobject/objecttypes/timeperiod/timeperiod.go index 6022bda6..8f90ee34 100644 --- a/configobject/objecttypes/timeperiod/timeperiod.go +++ b/configobject/objecttypes/timeperiod/timeperiod.go @@ -43,7 +43,7 @@ func NewTimeperiod() connection.Row { func (t *Timeperiod) InsertValues() []interface{} { v := t.UpdateValues() - return append([]interface{}{utils.Checksum(t.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(t.Id)}, v...) } func (t *Timeperiod) UpdateValues() []interface{} { @@ -51,14 +51,14 @@ func (t *Timeperiod) UpdateValues() []interface{} { v = append( v, - utils.Checksum(t.EnvId), - utils.Checksum(t.NameChecksum), - utils.Checksum(t.PropertiesChecksum), + utils.EncodeChecksum(t.EnvId), + utils.EncodeChecksum(t.NameChecksum), + utils.EncodeChecksum(t.PropertiesChecksum), t.Name, t.NameCi, t.DisplayName, utils.Bool[t.PreferIncludes], - utils.Checksum(t.ZoneId), + utils.EncodeChecksum(t.ZoneId), ) return v diff --git a/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go b/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go index ab8df0b5..88d9a19e 100644 --- a/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go +++ b/configobject/objecttypes/timeperiod/timeperiodcustomvar/timeperiodcustomvar.go @@ -31,7 +31,7 @@ func NewTimeperiodCustomvar() connection.Row { func (c *TimeperiodCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *TimeperiodCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *TimeperiodCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.TimeperiodId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.TimeperiodId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go b/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go index 02a85dbf..f5d21ad1 100644 --- a/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go +++ b/configobject/objecttypes/timeperiod/timeperiodoverrideexclude/timeperiodoverrideexclude.go @@ -31,7 +31,7 @@ func NewTimeperiodOverrideExclude() connection.Row { func (t *TimeperiodOverrideExclude) InsertValues() []interface{} { v := t.UpdateValues() - return append([]interface{}{utils.Checksum(t.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(t.Id)}, v...) } func (t *TimeperiodOverrideExclude) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (t *TimeperiodOverrideExclude) UpdateValues() []interface{} { v = append( v, - utils.Checksum(t.TimeperiodId), - utils.Checksum(t.OverrideId), - utils.Checksum(t.EnvId), + utils.EncodeChecksum(t.TimeperiodId), + utils.EncodeChecksum(t.OverrideId), + utils.EncodeChecksum(t.EnvId), ) return v diff --git a/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go b/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go index 3f95a676..d96f5201 100644 --- a/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go +++ b/configobject/objecttypes/timeperiod/timeperiodoverrideinclude/timeperiodoverrideinclude.go @@ -31,7 +31,7 @@ func NewTimeperiodOverrideInclude() connection.Row { func (t *TimeperiodOverrideInclude) InsertValues() []interface{} { v := t.UpdateValues() - return append([]interface{}{utils.Checksum(t.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(t.Id)}, v...) } func (t *TimeperiodOverrideInclude) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (t *TimeperiodOverrideInclude) UpdateValues() []interface{} { v = append( v, - utils.Checksum(t.TimeperiodId), - utils.Checksum(t.OverrideId), - utils.Checksum(t.EnvId), + utils.EncodeChecksum(t.TimeperiodId), + utils.EncodeChecksum(t.OverrideId), + utils.EncodeChecksum(t.EnvId), ) return v diff --git a/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go b/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go index 6aea6906..264c4875 100644 --- a/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go +++ b/configobject/objecttypes/timeperiod/timeperiodrange/timeperiodrange.go @@ -33,7 +33,7 @@ func NewTimeperiodRange() connection.Row { func (t *TimeperiodRange) InsertValues() []interface{} { v := t.UpdateValues() - return append([]interface{}{utils.Checksum(t.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(t.Id)}, v...) } func (t *TimeperiodRange) UpdateValues() []interface{} { @@ -41,10 +41,10 @@ func (t *TimeperiodRange) UpdateValues() []interface{} { v = append( v, - utils.Checksum(t.TimeperiodId), + utils.EncodeChecksum(t.TimeperiodId), t.RangeKey, t.RangeValue, - utils.Checksum(t.EnvId), + utils.EncodeChecksum(t.EnvId), ) return v diff --git a/configobject/objecttypes/user/user.go b/configobject/objecttypes/user/user.go index 382e63af..c4b28c90 100644 --- a/configobject/objecttypes/user/user.go +++ b/configobject/objecttypes/user/user.go @@ -57,7 +57,7 @@ func NewUser() connection.Row { func (u *User) InsertValues() []interface{} { v := u.UpdateValues() - return append([]interface{}{utils.Checksum(u.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(u.Id)}, v...) } func (u *User) UpdateValues() []interface{} { @@ -65,21 +65,21 @@ func (u *User) UpdateValues() []interface{} { v = append( v, - utils.Checksum(u.EnvId), - utils.Checksum(u.NameChecksum), - utils.Checksum(u.PropertiesChecksum), - utils.Checksum(u.CustomvarsChecksum), - utils.Checksum(u.GroupsChecksum), + utils.EncodeChecksum(u.EnvId), + utils.EncodeChecksum(u.NameChecksum), + utils.EncodeChecksum(u.PropertiesChecksum), + utils.EncodeChecksum(u.CustomvarsChecksum), + utils.EncodeChecksum(u.GroupsChecksum), u.Name, u.NameCi, u.DisplayName, u.EMail, u.Pager, u.NotificationsEnabled, - utils.Checksum(u.PeriodId), + utils.EncodeChecksum(u.PeriodId), utils.NotificationStatesToBitMask(u.States), utils.NotificationTypesToBitMask(u.Types), - utils.Checksum(u.ZoneId), + utils.EncodeChecksum(u.ZoneId), ) return v diff --git a/configobject/objecttypes/user/usercustomvar/usercustomvar.go b/configobject/objecttypes/user/usercustomvar/usercustomvar.go index c6327285..12126be0 100644 --- a/configobject/objecttypes/user/usercustomvar/usercustomvar.go +++ b/configobject/objecttypes/user/usercustomvar/usercustomvar.go @@ -31,7 +31,7 @@ func NewUserCustomvar() connection.Row { func (c *UserCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *UserCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *UserCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.UserId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.UserId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/usergroup/usergroup.go b/configobject/objecttypes/usergroup/usergroup.go index b6faba67..7a7993c1 100644 --- a/configobject/objecttypes/usergroup/usergroup.go +++ b/configobject/objecttypes/usergroup/usergroup.go @@ -43,7 +43,7 @@ func NewUsergroup() connection.Row { func (u *Usergroup) InsertValues() []interface{} { v := u.UpdateValues() - return append([]interface{}{utils.Checksum(u.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(u.Id)}, v...) } func (u *Usergroup) UpdateValues() []interface{} { @@ -51,14 +51,14 @@ func (u *Usergroup) UpdateValues() []interface{} { v = append( v, - utils.Checksum(u.EnvId), - utils.Checksum(u.NameChecksum), - utils.Checksum(u.PropertiesChecksum), - utils.Checksum(u.CustomvarsChecksum), + utils.EncodeChecksum(u.EnvId), + utils.EncodeChecksum(u.NameChecksum), + utils.EncodeChecksum(u.PropertiesChecksum), + utils.EncodeChecksum(u.CustomvarsChecksum), u.Name, u.NameCi, u.DisplayName, - utils.Checksum(u.ZoneId), + utils.EncodeChecksum(u.ZoneId), ) return v diff --git a/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go b/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go index bc11dbd0..97ecb89c 100644 --- a/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go +++ b/configobject/objecttypes/usergroup/usergroupcustomvar/usergroupcustomvar.go @@ -31,7 +31,7 @@ func NewUsergroupCustomvar() connection.Row { func (c *UsergroupCustomvar) InsertValues() []interface{} { v := c.UpdateValues() - return append([]interface{}{utils.Checksum(c.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(c.Id)}, v...) } func (c *UsergroupCustomvar) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (c *UsergroupCustomvar) UpdateValues() []interface{} { v = append( v, - utils.Checksum(c.UsergroupId), - utils.Checksum(c.CustomvarId), - utils.Checksum(c.EnvId), + utils.EncodeChecksum(c.UsergroupId), + utils.EncodeChecksum(c.CustomvarId), + utils.EncodeChecksum(c.EnvId), ) return v diff --git a/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go b/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go index 374f6eb3..43efe08e 100644 --- a/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go +++ b/configobject/objecttypes/usergroup/usergroupmember/usergroupmember.go @@ -31,7 +31,7 @@ func NewUsergroupMember() connection.Row { func (u *UsergroupMember) InsertValues() []interface{} { v := u.UpdateValues() - return append([]interface{}{utils.Checksum(u.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(u.Id)}, v...) } func (u *UsergroupMember) UpdateValues() []interface{} { @@ -39,9 +39,9 @@ func (u *UsergroupMember) UpdateValues() []interface{} { v = append( v, - utils.Checksum(u.UsergroupId), - utils.Checksum(u.UserId), - utils.Checksum(u.EnvId), + utils.EncodeChecksum(u.UsergroupId), + utils.EncodeChecksum(u.UserId), + utils.EncodeChecksum(u.EnvId), ) return v diff --git a/configobject/objecttypes/zone/zone.go b/configobject/objecttypes/zone/zone.go index 5fb9f81f..5910eb3e 100644 --- a/configobject/objecttypes/zone/zone.go +++ b/configobject/objecttypes/zone/zone.go @@ -45,7 +45,7 @@ func NewZone() connection.Row { func (z *Zone) InsertValues() []interface{} { v := z.UpdateValues() - return append([]interface{}{utils.Checksum(z.Id)}, v...) + return append([]interface{}{utils.EncodeChecksum(z.Id)}, v...) } func (z *Zone) UpdateValues() []interface{} { @@ -53,14 +53,14 @@ func (z *Zone) UpdateValues() []interface{} { v = append( v, - utils.Checksum(z.EnvId), - utils.Checksum(z.NameChecksum), - utils.Checksum(z.PropertiesChecksum), - utils.Checksum(z.ParentsChecksum), + utils.EncodeChecksum(z.EnvId), + utils.EncodeChecksum(z.NameChecksum), + utils.EncodeChecksum(z.PropertiesChecksum), + utils.EncodeChecksum(z.ParentsChecksum), z.Name, z.NameCi, utils.Bool[z.IsGlobal], - utils.Checksum(z.ParentId), + utils.EncodeChecksum(z.ParentId), z.Depth, ) diff --git a/connection/mysql.go b/connection/mysql.go index 442bf329..5b82eb0b 100644 --- a/connection/mysql.go +++ b/connection/mysql.go @@ -698,7 +698,7 @@ func (dbw *DBWrapper) SqlBulkDelete(keys []string, stmt *BulkDeleteStmt) error { values := make([]interface{}, len(bulk)) for i, key := range bulk { - values[i] = utils.Checksum(key) + values[i] = utils.EncodeChecksum(key) } query := fmt.Sprintf(stmt.Format, placeholders) diff --git a/utils/convert.go b/utils/convert.go index c9424c51..e42fa71b 100644 --- a/utils/convert.go +++ b/utils/convert.go @@ -32,15 +32,15 @@ var ( } ) -// StringToSha1String converts the given string into a SHA1 string -func StringToSha1String(s string) string { +// Checksum converts the given string into a SHA1 checksum string +func Checksum(s string) string { hash := sha1.New() hash.Write([]byte(s)) return fmt.Sprintf("%x", hash.Sum(nil)) } -// Checksum converts a hex string to a byte array -func Checksum(s string) []byte { +// EncodeChecksum converts a hex string to a byte array +func EncodeChecksum(s string) []byte { c, err := hex.DecodeString(s) if err != nil { panic(err) diff --git a/utils/convert_test.go b/utils/convert_test.go index f64a94ed..b99274b7 100644 --- a/utils/convert_test.go +++ b/utils/convert_test.go @@ -5,13 +5,13 @@ import ( "testing" ) -func TestChecksum(t *testing.T) { +func TestEncodeChecksum(t *testing.T) { assert.Equal(t, []byte{ 218, 57, 163, 238, 94, 107, 75, 13, 50, 85, 191, 239, 149, 96, 24, 144, 175, 216, 7, 9, - }, Checksum("da39a3ee5e6b4b0d3255bfef95601890afd80709")) + }, EncodeChecksum("da39a3ee5e6b4b0d3255bfef95601890afd80709")) assert.Panics(t, func() { - Checksum("x") + EncodeChecksum("x") }) } @@ -21,9 +21,9 @@ func TestDecodeChecksum(t *testing.T) { })) } -func TestStringToSha1String(t *testing.T) { - assert.Equal(t, "661295c9cbf9d6b2f6428414504a8deed3020641", StringToSha1String("test string")) - assert.Equal(t, "e6c8d9df653f15466261cc7c318743a7534f9462", StringToSha1String("herp da derp")) +func TestChecksum(t *testing.T) { + assert.Equal(t, "661295c9cbf9d6b2f6428414504a8deed3020641", Checksum("test string")) + assert.Equal(t, "e6c8d9df653f15466261cc7c318743a7534f9462", Checksum("herp da derp")) } func TestNotificationTypesToBitMask(t *testing.T) {