MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetGroup

Method GetGroup

backend/store/group.go:78–96  ·  view source on GitHub ↗

GetGroup gets a group.

(ctx context.Context, find *FindGroupMessage)

Source from the content-addressed store, hash-verified

76
77// GetGroup gets a group.
78func (s *Store) GetGroup(ctx context.Context, find *FindGroupMessage) (*GroupMessage, error) {
79 if find.Email != nil && find.Workspace != "" {
80 if v, ok := s.groupCache.Get(getGroupCacheKey(find.Workspace, &GroupMessage{Email: *find.Email})); ok && s.enableCache {
81 return v, nil
82 }
83 }
84
85 groups, err := s.ListGroups(ctx, find)
86 if err != nil {
87 return nil, err
88 }
89
90 if len(groups) == 0 {
91 return nil, nil
92 } else if len(groups) > 1 {
93 return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d groups with filter %+v, expect 1", len(groups), find)}
94 }
95 return groups[0], nil
96}
97
98// ListGroups list all groups.
99func (s *Store) ListGroups(ctx context.Context, find *FindGroupMessage) ([]*GroupMessage, error) {

Callers 1

GetGroupByNameMethod · 0.95

Calls 4

ListGroupsMethod · 0.95
getGroupCacheKeyFunction · 0.85
GetMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected