mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package supportbundlesimpl
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/grafana/grafana/pkg/services/supportbundles"
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
)
|
|
|
|
func userCollector(users user.Service) supportbundles.Collector {
|
|
collectorFn := func(ctx context.Context) (*supportbundles.SupportItem, error) {
|
|
query := &user.SearchUsersQuery{
|
|
SignedInUser: &user.SignedInUser{},
|
|
OrgID: 0,
|
|
Query: "",
|
|
Page: 0,
|
|
Limit: 0,
|
|
AuthModule: "",
|
|
Filters: []user.Filter{},
|
|
IsDisabled: new(bool),
|
|
}
|
|
res, err := users.Search(ctx, query)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
userBytes, err := json.Marshal(res.Users)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &supportbundles.SupportItem{
|
|
Filename: "users.json",
|
|
FileBytes: userBytes,
|
|
}, nil
|
|
}
|
|
|
|
return supportbundles.Collector{
|
|
UID: "users",
|
|
DisplayName: "User information",
|
|
Description: "List users belonging to the Grafana instance",
|
|
IncludedByDefault: false,
|
|
Default: false,
|
|
Fn: collectorFn,
|
|
}
|
|
}
|