feat: make store use ClientManager

This commit is contained in:
James Houlahan
2020-04-07 09:55:28 +02:00
parent f269be4291
commit 042c340881
43 changed files with 414 additions and 264 deletions

View File

@ -36,11 +36,7 @@ var systemLabelNameToID = map[string]string{ //nolint[gochecknoglobals]
}
func (cntrl *Controller) AddUserLabel(username string, label *pmapi.Label) error {
client, ok := cntrl.pmapiByUsername[username]
if !ok {
return fmt.Errorf("user %s does not exist", username)
}
client := cntrl.clientManager.GetClient(username)
label.Exclusive = getLabelExclusive(label.Name)
label.Name = getLabelNameWithoutPrefix(label.Name)
label.Color = pmapi.LabelColors[0]
@ -67,11 +63,7 @@ func (cntrl *Controller) getLabelID(username, labelName string) (string, error)
return labelID, nil
}
client, ok := cntrl.pmapiByUsername[username]
if !ok {
return "", fmt.Errorf("user %s does not exist", username)
}
client := cntrl.clientManager.GetClient(username)
labels, err := client.ListLabels()
if err != nil {
return "", errors.Wrap(err, "failed to list labels")