mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-24 16:41:30 +02:00
Fix lint issues
This commit is contained in:
@@ -56,11 +56,8 @@ type Table struct {
|
||||
// finite, non-negative USD amount; a violation is returned as an error so
|
||||
// a corrupt config fails the chain build loudly instead of mispricing.
|
||||
// Management validates the same constraints at its API boundary, so this
|
||||
// is defense-in-depth. Nil input yields nil output.
|
||||
// is defense-in-depth. Nil input yields an empty (never-matching) map.
|
||||
func NewEntries(raw map[string]map[string]EntryJSON) (map[string]map[string]Entry, error) {
|
||||
if raw == nil {
|
||||
return nil, nil
|
||||
}
|
||||
out := make(map[string]map[string]Entry, len(raw))
|
||||
for outer, models := range raw {
|
||||
inner := make(map[string]Entry, len(models))
|
||||
@@ -76,13 +73,9 @@ func NewEntries(raw map[string]map[string]EntryJSON) (map[string]map[string]Entr
|
||||
return nil, fmt.Errorf("pricing %s/%s: %s must be a finite, non-negative rate, got %v", outer, model, field, v)
|
||||
}
|
||||
}
|
||||
inner[model] = Entry{
|
||||
InputPer1K: e.InputPer1K,
|
||||
OutputPer1K: e.OutputPer1K,
|
||||
CachedInputPer1K: e.CachedInputPer1K,
|
||||
CacheReadPer1K: e.CacheReadPer1K,
|
||||
CacheCreationPer1K: e.CacheCreationPer1K,
|
||||
}
|
||||
// EntryJSON and Entry are field-identical (tags aside), so a
|
||||
// direct conversion carries all five rates.
|
||||
inner[model] = Entry(e)
|
||||
}
|
||||
out[outer] = inner
|
||||
}
|
||||
@@ -96,9 +89,6 @@ func NewTable(raw map[string]map[string]EntryJSON) (*Table, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if entries == nil {
|
||||
entries = map[string]map[string]Entry{}
|
||||
}
|
||||
return &Table{entries: entries}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -173,5 +173,5 @@ func TestNewTable_NilAndEmpty(t *testing.T) {
|
||||
|
||||
entries, err := NewEntries(nil)
|
||||
require.NoError(t, err)
|
||||
assert.Nil(t, entries, "nil in, nil out for the per-record map")
|
||||
assert.Empty(t, entries, "nil in, empty (never-matching) map out for the per-record map")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user