Add missing parenthesis in mmctl webhook list (#28778)
* Add missing parenthesis in mmctl webhook list * Use generics in StoreResult
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f8f998bfcb
Коммит
2c139a293b
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type StoreResult struct {
|
||||
Data interface{}
|
||||
type StoreResult[T any] struct {
|
||||
Data T
|
||||
Err error
|
||||
}
|
||||
|
||||
@@ -108,35 +108,33 @@ func listWebhookCmdF(c client.Client, command *cobra.Command, args []string) err
|
||||
continue
|
||||
}
|
||||
|
||||
incomingResult := make(chan StoreResult, 1)
|
||||
incomingResult := make(chan StoreResult[[]*model.IncomingWebhook], 1)
|
||||
go func() {
|
||||
incomingHooks, err := getPages(func(page, numPerPage int, etag string) ([]*model.IncomingWebhook, *model.Response, error) {
|
||||
return c.GetIncomingWebhooksForTeam(context.TODO(), team.Id, page, numPerPage, etag)
|
||||
}, DefaultPageSize)
|
||||
incomingResult <- StoreResult{Data: incomingHooks, Err: err}
|
||||
incomingResult <- StoreResult[[]*model.IncomingWebhook]{Data: incomingHooks, Err: err}
|
||||
close(incomingResult)
|
||||
}()
|
||||
outgoingResult := make(chan StoreResult, 1)
|
||||
outgoingResult := make(chan StoreResult[[]*model.OutgoingWebhook], 1)
|
||||
go func() {
|
||||
outgoingHooks, err := getPages(func(page, numPerPage int, etag string) ([]*model.OutgoingWebhook, *model.Response, error) {
|
||||
return c.GetOutgoingWebhooksForTeam(context.TODO(), team.Id, page, numPerPage, etag)
|
||||
}, DefaultPageSize)
|
||||
outgoingResult <- StoreResult{Data: outgoingHooks, Err: err}
|
||||
outgoingResult <- StoreResult[[]*model.OutgoingWebhook]{Data: outgoingHooks, Err: err}
|
||||
close(outgoingResult)
|
||||
}()
|
||||
|
||||
if result := <-incomingResult; result.Err == nil {
|
||||
hooks := result.Data.([]*model.IncomingWebhook)
|
||||
for _, hook := range hooks {
|
||||
printer.PrintT("Incoming:\t{{.DisplayName}} ({{.Id}}", hook)
|
||||
for _, hook := range result.Data {
|
||||
printer.PrintT("Incoming:\t{{.DisplayName}} ({{.Id}})", hook)
|
||||
}
|
||||
} else {
|
||||
printer.PrintError("Unable to list incoming webhooks for '" + team.Id + "': " + result.Err.Error())
|
||||
}
|
||||
|
||||
if result := <-outgoingResult; result.Err == nil {
|
||||
hooks := result.Data.([]*model.OutgoingWebhook)
|
||||
for _, hook := range hooks {
|
||||
for _, hook := range result.Data {
|
||||
printer.PrintT("Outgoing:\t {{.DisplayName}} ({{.Id}})", hook)
|
||||
}
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user