Skip to content

Commit

Permalink
Use types.MakeString() instead of manual initialization (refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Mar 25, 2024
1 parent d36ade1 commit 10afc56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
25 changes: 5 additions & 20 deletions cmd/icingadb-migrate/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,9 @@ func convertCommentRows(
},
AckHistoryUpserter: history.AckHistoryUpserter{ClearTime: clearTime},
SetTime: setTime,
Author: icingadbTypes.String{
NullString: sql.NullString{
String: row.AuthorName,
Valid: true,
},
},
Comment: icingadbTypes.String{
NullString: sql.NullString{
String: row.CommentData,
Valid: true,
},
},
ExpireTime: convertTime(row.ExpirationTime, 0),
Author: icingadbTypes.MakeString(row.AuthorName),
Comment: icingadbTypes.MakeString(row.CommentData),
ExpireTime: convertTime(row.ExpirationTime, 0),
IsPersistent: icingadbTypes.Bool{
Bool: row.IsPersistent != 0,
Valid: true,
Expand Down Expand Up @@ -656,13 +646,8 @@ func convertNotificationRows(
SendTime: ts,
State: row.State,
PreviousHardState: previousHardState,
Text: icingadbTypes.String{
NullString: sql.NullString{
String: text,
Valid: true,
},
},
UsersNotified: row.ContactsNotified,
Text: icingadbTypes.MakeString(text),
UsersNotified: row.ContactsNotified,
})

allHistory = append(allHistory, &history.HistoryNotification{
Expand Down
3 changes: 1 addition & 2 deletions pkg/flatten/flatten.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package flatten

import (
"database/sql"
"fmt"
"github.com/icinga/icingadb/pkg/types"
"strconv"
Expand Down Expand Up @@ -37,7 +36,7 @@ func Flatten(value interface{}, prefix string) map[string]types.String {
if value != nil {
val = fmt.Sprintf("%v", value)
}
flattened[key] = types.String{NullString: sql.NullString{String: val, Valid: true}}
flattened[key] = types.MakeString(val)
}
}

Expand Down
7 changes: 1 addition & 6 deletions pkg/icingadb/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,7 @@ func (h *HA) controller() {
EntityWithoutChecksum: v1.EntityWithoutChecksum{IdMeta: v1.IdMeta{
Id: envId,
}},
Name: types.String{
NullString: sql.NullString{
String: envId.String(),
Valid: true,
},
},
Name: types.MakeString(envId.String()),
}
h.environmentMu.Unlock()
}
Expand Down

0 comments on commit 10afc56

Please sign in to comment.