Fix backend linter errors

This commit is contained in:
Alexander Zobnin
2023-08-30 12:48:38 +02:00
parent a536e6d8db
commit c06683cd37
12 changed files with 81 additions and 72 deletions

View File

@@ -115,6 +115,9 @@ func (ds *Zabbix) GetItems(
itemTagFilter = strings.Join(tagStrs, ",")
}
allItems, err = ds.GetAllItems(ctx, hostids, nil, itemType, showDisabled, itemTagFilter)
if err != nil {
return nil, err
}
return filterItemsByQuery(allItems, itemFilter)
}
@@ -153,6 +156,9 @@ func (ds *Zabbix) GetItemsBefore54(
} else if appFilter == "" && len(hostids) > 0 {
allItems, err = ds.GetAllItems(ctx, hostids, nil, itemType, showDisabled, "")
}
if err != nil {
return nil, err
}
return filterItemsByQuery(allItems, itemFilter)
}
@@ -239,7 +245,11 @@ func (ds *Zabbix) GetItemTags(ctx context.Context, groupFilter string, hostFilte
var allItems []*Item
itemType := "num"
showDisabled := false
allItems, err = ds.GetAllItems(ctx, hostids, nil, itemType, showDisabled, "")
if err != nil {
return nil, err
}
var allTags []ItemTag
tagsMap := make(map[string]ItemTag)
@@ -397,7 +407,7 @@ func (ds *Zabbix) GetAllItems(ctx context.Context, hostids []string, appids []st
}
}
if showDisabled == false {
if !showDisabled {
params["monitored"] = true
}
@@ -521,12 +531,3 @@ func (ds *Zabbix) GetVersion(ctx context.Context) (int, error) {
versionNum, err := strconv.Atoi(version)
return versionNum, err
}
func isAppMethodNotFoundError(err error) bool {
if err == nil {
return false
}
message := err.Error()
return message == `Method not found. Incorrect API "application".`
}

View File

@@ -12,7 +12,7 @@ func (item *Item) ExpandItemName() string {
name := item.Name
key := item.Key
if strings.Index(key, "[") == -1 {
if !strings.Contains(key, "[") {
return name
}
@@ -34,14 +34,13 @@ func expandItems(items []*Item) []*Item {
}
func splitKeyParams(paramStr string) []string {
paramRunes := []rune(paramStr)
params := []string{}
quoted := false
inArray := false
splitSymbol := ","
param := ""
for _, r := range paramRunes {
for _, r := range paramStr {
symbol := string(r)
if symbol == `"` && inArray {
param += symbol